Skip to content

Commit

Permalink
Added test for Codeception#3686, minor refactoring (Codeception#3697)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik authored Nov 9, 2016
1 parent a480bf2 commit 8735ae8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Codeception/Module/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function seeFileFound($filename, $path = '')
\PHPUnit_Framework_Assert::assertFileExists($file);
return;
}
$this->fail("$filename in $path");
$this->fail("File \"$filename\" not found at \"$path\"");
}

/**
Expand Down
13 changes: 7 additions & 6 deletions src/Codeception/Subscriber/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ public function startTest(TestEvent $e)
public function afterStep(StepEvent $e)
{
$step = $e->getStep();
if ($step->hasFailed()) {
if ($step instanceof Step\ConditionalAssertion) {
$this->conditionalFails[] = $step;
} else {
$this->failedStep = $step;
}
if (!$step->hasFailed()) {
return;
}
if ($step instanceof Step\ConditionalAssertion) {
$this->conditionalFails[] = $step;
return;
}
$this->failedStep = $step;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/cli/RunCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,13 @@ public function runTestWithAnnotationExamplesFromGroupFileTest(CliGuy $I)
$I->executeCommand('run scenario -g groupFileTest1 --steps');
$I->seeInShellOutput('OK (3 tests');
}

public function testsWithConditionalFails(CliGuy $I)
{
$I->executeCommand('run scenario ConditionalCept --no-exit');
$I->seeInShellOutput('There were 3 failures');
$I->seeInShellOutput('Fail File "not-a-file" not found');
$I->seeInShellOutput('Fail File "not-a-dir" not found');
$I->seeInShellOutput('Fail File "nothing" not found');
}
}
6 changes: 6 additions & 0 deletions tests/data/claypit/tests/scenario/ConditionalCept.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
$I = new ScenarioGuy($scenario);
$I->amInPath('.');
$I->canSeeFileFound('not-a-file');
$I->canSeeFileFound('not-a-dir');
$I->canSeeFileFound('nothing');

0 comments on commit 8735ae8

Please sign in to comment.