I have a code to test:
class ToTest
{
public function testMe()
{
echo 'test';
}
}
class TestTest extends \PHPUnit\Framework\TestCase
{
public function testX()
{
ob_start();
(new ToTest())->testMe();
$c = ob_get_clean();
$this->assertSame('test', $c);
}
}
this passes but marked as risky test:
Test code or tested code did not (only) close its own output buffers
to me, it looks I handled output buffering well...
There must be some code under test interfering with the buffer. For example, if the code under test opens a buffer and doesn't close it for some reason, then you will end up with an open buffer.
The following will cause the a risky test:
The first thing to do is use the PHPUnit output testing assertions:
Once you do that, you will know for sure that the code under test is opening a buffer somewhere and not closing it.