Update: See rdlowrey's update below regarding the use of fwrite(STDERR, print_r($myDebugVar, TRUE));
as a much simpler work around
This behaviour is intentional (as jasonbar has pointed out). The conflicting state of the manual has been reported to PHPUnit.
A work-around is to have PHPUnit assert the expected output is empty (when infact there is output) which will trigger the unexpected output to be shown.
class theTest extends PHPUnit_Framework_TestCase
{
/**
* @outputBuffering disabled
*/
public function testOutput() {
$this->expectOutputString(''); // tell PHPUnit to expect '' as output
print_r("Hello World");
print "Ping";
echo "Pong";
$out = "Foo";
var_dump($out);
}
}
gives:
PHPUnit @package_version@ by Sebastian Bergmann.
F
Time: 1 second, Memory: 3.50Mb
There was 1 failure:
1) theTest::testOutput
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-''
+'Hello WorldPingPongstring(4) "Foo"
+'
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
Be certain to disable any other assertions you have for the test as they may fail before the output assertion is tested (and hence you wont see the output).