When running a PHPUnit test, I would like to be able to dump output so I can debug one or two things.
I have tried the following (similar to the PHPUnit Manual example);
class theTest extends PHPUnit_Framework_TestCase
{
/**
* @outputBuffering disabled
*/
public function testOutput() {
print_r("Hello World");
print "Ping";
echo "Pong";
$out = "Foo";
var_dump($out);
}
}
With the following result:
PHPUnit @package_version@ by Sebastian Bergmann.
.
Time: 0 seconds, Memory: 3.00Mb
OK (1 test, 0 assertions)
Notice there is none of the expected output.
I'm using the HEAD versions of the git repos as of September 19th, 2011.
Output of php -version
:
$ php -version
PHP 5.2.9 (cli) (built: Dec 8 2010 11:36:37)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
Is there anything I'm doing wrong, or is this potentially a PHPUnit bug?
testOutput()
method? – Derrick Tucker Sep 20 '11 at 23:52phpunit /path/to/tests/theTest.php
(if the above class were in the filetheTest.php
). – Jess Telford Sep 20 '11 at 23:57ob_get_level()
returns1
. However, this is contradicted by the following code:while (ob_get_level() > 0) { ob_end_flush(); }
which errors withob_end_clean(): failed to delete buffer. No buffer to delete.
. Curiouser and curiouser. – Jess Telford Sep 21 '11 at 0:05