Skip to content

Commit

Permalink
Merge branch '11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 10, 2024
2 parents 072954b + de24e7e commit 2112ef4
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,9 @@ private function restoreGlobalErrorExceptionHandlers(): void

if ($activeErrorHandlers !== $this->backupGlobalErrorHandlers) {
if (count($activeErrorHandlers) > count($this->backupGlobalErrorHandlers)) {
$message = 'Test code or tested code did not remove its own error handlers';
if (!$this->inIsolation) {
$message = 'Test code or tested code did not remove its own error handlers';
}
} else {
$message = 'Test code or tested code removed error handlers other than its own';
}
Expand All @@ -1850,9 +1852,22 @@ private function restoreGlobalErrorExceptionHandlers(): void
}
}

if ($message !== null) {
Event\Facade::emitter()->testConsideredRisky(
$this->valueObjectForEvents(),
$message,
);

$this->status = TestStatus::risky($message);
}

$message = null;

if ($activeExceptionHandlers !== $this->backupGlobalExceptionHandlers) {
if (count($activeExceptionHandlers) > count($this->backupGlobalExceptionHandlers)) {
$message = 'Test code or tested code did not remove its own exception handlers';
if (!$this->inIsolation) {
$message = 'Test code or tested code did not remove its own exception handlers';
}
} else {
$message = 'Test code or tested code removed exception handlers other than its own';
}
Expand Down
55 changes: 55 additions & 0 deletions tests/end-to-end/regression/5592-process-isolation.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/pull/5592
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--process-isolation';
$_SERVER['argv'][] = __DIR__ . '/5592/Issue5592Test.php';

set_exception_handler(static fn () => null);

require_once __DIR__ . '/../../bootstrap.php';
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

.FF.FF 6 / 6 (100%)

Time: %s, Memory: %s

There were 4 failures:

1) PHPUnit\TestFixture\Issue5592Test::testAddedErrorHandler
Failed asserting that false is true.

%sIssue5592Test.php:%i

2) PHPUnit\TestFixture\Issue5592Test::testRemovedErrorHandler
Failed asserting that false is true.

%sIssue5592Test.php:%i

3) PHPUnit\TestFixture\Issue5592Test::testAddedExceptionHandler
Failed asserting that false is true.

%sIssue5592Test.php:%i

4) PHPUnit\TestFixture\Issue5592Test::testRemovedExceptionHandler
Failed asserting that false is true.

%sIssue5592Test.php:%i

--

There was 1 risky test:

1) PHPUnit\TestFixture\Issue5592Test::testRemovedErrorHandler
Test code or tested code removed error handlers other than its own

%sIssue5592Test.php:%i

FAILURES!
Tests: 6, Assertions: 6, Failures: 4, Risky: 1.

0 comments on commit 2112ef4

Please sign in to comment.