Open
Description
Q | A |
---|---|
PHPUnit version | 11.5.2 |
PHP version | 8.3.9 |
Installation Method | Composer |
Summary
expectUserDeprecationMessage*()
fails when test is run in separate process.
Current behavior
A test like this
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
class ExpectDeprecationTest extends TestCase {
/**
* Tests expectDeprecation.
*/
public function testExpectDeprecation(): void {
$this->expectUserDeprecationMessage('Test deprecation');
@trigger_error('Test deprecation', E_USER_DEPRECATED);
}
/**
* Tests expectDeprecation in isolated test.
*/
#[RunInSeparateProcess]
public function testExpectDeprecationInIsolation(): void {
$this->expectUserDeprecationMessage('Test isolated deprecation');
@trigger_error('Test isolated deprecation', E_USER_DEPRECATED);
}
}
leads to an EventFacadeIsSealedException
error reported by the runner:
PHPUnit 11.5.2 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.9
Configuration: /Users/xxx/Dev/drupal/core/phpunit.xml.dist
DE 2 / 2 (100%)
Time: 00:01.879, Memory: 14.00 MB
There was 1 error:
1) ExpectDeprecationTest::testExpectDeprecationInIsolation
PHPUnit\Event\EventFacadeIsSealedException:
--
2 tests triggered 2 deprecations:
1) /Users/xxx/Dev/drupal/core/tests/Drupal/Tests/ExpectDeprecationTest.php:15
Test deprecation
2) /Users/xxx/Dev/drupal/core/tests/Drupal/Tests/ExpectDeprecationTest.php:24
Test isolated deprecation
ERRORS!
Tests: 2, Assertions: 2, Errors: 1, Deprecations: 2.
How to reproduce
See above
Expected behavior
No exception reported, only the deprecations.