Open
Description
Q | A |
---|---|
PHPUnit version | 10.x |
PHP version | 8.1.13 |
Installation Method | PHAR |
Summary
Starting with 10.0, tests with headers_sent()
have a different behavior now.
Current behavior
The headers_sent()
result differs from PHPUnit 9 to 10.
How to reproduce
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class BasicTest extends TestCase
{
public function testEqual(): void
{
$string = 'a';
if (!headers_sent()) {
$string = 'b';
}
$this->assertSame($string, 'a');
}
}
Expected behavior
The check for headers_sent()
does not change from PHPUnit 9 to 10.
For reference, the results when testing with the original phar of PHPUnit 9.6.22 and 10.5.44:
php.exe .\phpunit-10.5.44.phar ./BasicTest.php
PHPUnit 10.5.44 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.13
F 1 / 1 (100%)
Time: 00:00.039, Memory: 26.00 MB
There was 1 failure:
1) BasicTest::testEqual
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'b'
+'a'
...\BasicTest.php:14
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
php.exe .\phpunit-9.6.22.phar ./BasicTest.php
PHPUnit 9.6.22 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 00:00.006, Memory: 26.00 MB
OK (1 test, 1 assertion)
I already tested and this affects every PHPUnit 10 version, including 10.0.0.
I checked the changelog and issues, so far I found no changes that could lead to this.
Activity