phpunit: Test does not complete when using ob_start and fpassthru
Q | A |
---|---|
PHPUnit version | 10.4.x |
PHP version | PHP8.3.0RC4 (alpine and github actions) |
Installation Method | Composer |
Summary
The test works:
- with all versions of PHP8.1 until the recent PHP8.3.0RC4 in PHPUnit.
- Outside of PHPUnit the code works as expected.
- Test also work with PHPUnit 10.3.1 (I checked the results of the github action)
Current behaviour
The test never ends nor report any failure.
How to reproduce
public function testOutputDoesNotStripBOM(): void
{
$raw_csv = "\xEF\xBB\xBFjohn,doe,john.doe@example.com\njane,doe,jane.doe@example.com\n";
$stream = fopen('php://temp', 'r+');
fwrite($stream, $raw_csv);
ob_start();
rewind($stream);
echo "\xFE\xFF";
fpassthru($stream);
$result = ob_get_clean();
fclose($stream);
self::assertStringContainsString("\xFE\xFF", $result);
self::assertStringContainsString("\xEF\xBB\xBF", $result);
self::assertTrue(str_starts_with($result, "\xFE\xFF\xEF\xBB\xBF"));
}
Expected behavior
Works in PHP8.1+ with PHPUnit 10.4.0 the test ends and pass successfully
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 1
- Comments: 16 (8 by maintainers)
Sorry for the delay. I have just opened a PR to fix this bug: https://github.com/php/php-src/pull/12541
I have reported this bug for PHP and will now close this ticket.
using your settings I have the following
So the test passes but the result is never returned
☝🏾 The following never happened