In case your test takes a long time and you would like to see the output during the process, add the following method to your test class:
protected function prontoPrint($whatever = 'I am printed!')
{
// if output buffer has not started yet
if (ob_get_level() == 0) {
// current buffer existence
$hasBuffer = false;
// start the buffer
ob_start();
} else {
// current buffer existence
$hasBuffer = true;
}
// echo to output
echo $whatever;
// flush current buffer to output stream
ob_flush();
flush();
ob_end_flush();
// if there were a buffer before this method was called
// in my version of PHPUNIT it has its own buffer running
if ($hasBuffer) {
// start the output buffer again
ob_start();
}
}
Now whenever you call $this->prontoPrint($variable)
inside your test class, it will immediately show the text in the console. I used this php.net comment to write the function.
PHPUnit 5.7.21
PHP 5.6.31 with Xdebug 2.5.5