sebastianbergmann/phpunit — Issue #445: expectOutputString() in strict mode not working in 3.6.5
Author: nijel
Created: 2011-12-20 09:03:47+00:00
State: open

This is followup to bug #371.

When running example test in strict mode, I get two failures.

Test case:

```php
expectOutputString('foo');
print 'foo';
}

public function testExpectBarActualBaz()
{
$this->expectOutputString('bar');
print 'baz';
}
}
?>
```

Output:

```
PHPUnit 3.6.5 by Sebastian Bergmann.

FF

Time: 0 seconds, Memory: 6.00Mb

There were 2 failures:

1) Sample_test::testExpectFooActualFoo
This test printed output: foo

2) Sample_test::testExpectBarActualBaz
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'bar'
+'baz'

FAILURES!
Tests: 2, Assertions: 2, Failures: 2.
```

The first test should not fail.

After applying following fix, it works as expected.

```patch
--- Framework/TestCase.php.orig	2011-12-20 10:01:40.000000000 +0100
+++ Framework/TestCase.php	2011-12-20 10:02:20.000000000 +0100
@@ -407,8 +407,8 @@
return FALSE;
}

- if ($this->outputExpectedString !== NULL ||
- $this->outputExpectedRegex !== NULL) {
+ if (is_null($this->outputExpectedString) &&
+ is_null($this->outputExpectedRegex)) {
return FALSE;
}

```

Output with patch:

```
PHPUnit 3.6.5 by Sebastian Bergmann.

.F

Time: 0 seconds, Memory: 5.75Mb

There was 1 failure:

1) Sample_test::testExpectBarActualBaz
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'bar'
+'baz'

FAILURES!
Tests: 2, Assertions: 2, Failures: 1.
```