-
- Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
feature/assertionIssues related to assertions and expectationsIssues related to assertions and expectationsfeature/process-isolationIssues related to running tests in separate PHP processesIssues related to running tests in separate PHP processesfeature/test-runnerCLI test runnerCLI test runnertype/bugSomething is brokenSomething is brokenversion/11Something affects PHPUnit 11Something affects PHPUnit 11version/12Something affects PHPUnit 12Something affects PHPUnit 12
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.
Metadata
Metadata
Assignees
Labels
feature/assertionIssues related to assertions and expectationsIssues related to assertions and expectationsfeature/process-isolationIssues related to running tests in separate PHP processesIssues related to running tests in separate PHP processesfeature/test-runnerCLI test runnerCLI test runnertype/bugSomething is brokenSomething is brokenversion/11Something affects PHPUnit 11Something affects PHPUnit 11version/12Something affects PHPUnit 12Something affects PHPUnit 12