Skip to content

Commit

Permalink
Fixes #433 for failing tests that expect output to be produced
Browse files Browse the repository at this point in the history
  • Loading branch information
edorian committed Dec 13, 2011
1 parent 29a481c commit 11b9153
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions PHPUnit/Framework/TestCase.php
Expand Up @@ -889,15 +889,15 @@ public function runBare()
if (!isset($e)) {
try {
if ($this->outputExpectedRegex !== NULL) {
$this->hasPerformedExpectationsOnOutput = TRUE;
$this->assertRegExp($this->outputExpectedRegex, $this->output);
$this->outputExpectedRegex = NULL;
$this->hasPerformedExpectationsOnOutput = TRUE;
}

else if ($this->outputExpectedString !== NULL) {
$this->hasPerformedExpectationsOnOutput = TRUE;
$this->assertEquals($this->outputExpectedString, $this->output);
$this->outputExpectedString = NULL;
$this->hasPerformedExpectationsOnOutput = TRUE;
}
}

Expand Down
18 changes: 16 additions & 2 deletions Tests/Regression/GitHub/433.phpt
Expand Up @@ -13,8 +13,22 @@ PHPUnit_TextUI_Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann.

..
..F

Time: %i %s, Memory: %sMb

OK (2 tests, 2 assertions)
There was 1 failure:

1) Issue433Test::testNotMatchingOutput
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'foo'
+'bar'

%s:%i

FAILURES!
Tests: 3, Assertions: 3, Failures: 1.

5 changes: 5 additions & 0 deletions Tests/Regression/GitHub/433/Issue433Test.php
Expand Up @@ -12,5 +12,10 @@ public function testOutputWithExpectationAfter() {
$this->expectOutputString('test');
}

public function testNotMatchingOutput() {
echo 'bar';
$this->expectOutputString('foo');
}

}

0 comments on commit 11b9153

Please sign in to comment.