Skip to content

Commit ab8a247

Browse files
staabmsebastianbergmann
authored andcommitted
separated assertions for process isolated case
1 parent 6c76c33 commit ab8a247

File tree

2 files changed

+94
-11
lines changed

2 files changed

+94
-11
lines changed

tests/end-to-end/regression/5592-process-isolation.phpt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ https://github.com/sebastianbergmann/phpunit/pull/5592
55
$_SERVER['argv'][] = '--do-not-cache-result';
66
$_SERVER['argv'][] = '--no-configuration';
77
$_SERVER['argv'][] = '--process-isolation';
8-
$_SERVER['argv'][] = __DIR__ . '/5592/Issue5592Test.php';
8+
$_SERVER['argv'][] = __DIR__ . '/5592/Issue5592TestIsolation.php';
99

1010
set_exception_handler(static fn () => null);
1111

@@ -22,34 +22,34 @@ Time: %s, Memory: %s
2222

2323
There were 4 failures:
2424

25-
1) PHPUnit\TestFixture\Issue5592Test::testAddedErrorHandler
25+
1) PHPUnit\TestFixture\Issue5592TestIsolation::testAddedErrorHandler
2626
Failed asserting that false is true.
2727

28-
%sIssue5592Test.php:%i
28+
%sIssue5592TestIsolation.php:%i
2929

30-
2) PHPUnit\TestFixture\Issue5592Test::testRemovedErrorHandler
30+
2) PHPUnit\TestFixture\Issue5592TestIsolation::testRemovedErrorHandler
3131
Failed asserting that false is true.
3232

33-
%sIssue5592Test.php:%i
33+
%sIssue5592TestIsolation.php:%i
3434

35-
3) PHPUnit\TestFixture\Issue5592Test::testAddedExceptionHandler
35+
3) PHPUnit\TestFixture\Issue5592TestIsolation::testAddedExceptionHandler
3636
Failed asserting that false is true.
3737

38-
%sIssue5592Test.php:%i
38+
%sIssue5592TestIsolation.php:%i
3939

40-
4) PHPUnit\TestFixture\Issue5592Test::testRemovedExceptionHandler
40+
4) PHPUnit\TestFixture\Issue5592TestIsolation::testRemovedExceptionHandler
4141
Failed asserting that false is true.
4242

43-
%sIssue5592Test.php:%i
43+
%sIssue5592TestIsolation.php:%i
4444

4545
--
4646

4747
There was 1 risky test:
4848

49-
1) PHPUnit\TestFixture\Issue5592Test::testRemovedErrorHandler
49+
1) PHPUnit\TestFixture\Issue5592TestIsolation::testRemovedErrorHandler
5050
Test code or tested code removed error handlers other than its own
5151

52-
%sIssue5592Test.php:%i
52+
%sIssue5592TestIsolation.php:%i
5353

5454
FAILURES!
5555
Tests: 6, Assertions: 10, Failures: 4, Risky: 1.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture;
11+
12+
use function restore_error_handler;
13+
use function restore_exception_handler;
14+
use function set_error_handler;
15+
use function set_exception_handler;
16+
use PHPUnit\Framework\TestCase;
17+
use PHPUnit\Runner\ErrorHandler;
18+
use Throwable;
19+
20+
class Issue5592TestIsolation extends TestCase
21+
{
22+
public function testAddedAndRemovedErrorHandler(): void
23+
{
24+
$previous = set_error_handler([$this, 'addedAndRemovedErrorHandler']);
25+
restore_error_handler();
26+
27+
$this->assertInstanceOf(ErrorHandler::class, $previous);
28+
$this->assertTrue(true);
29+
}
30+
31+
public function testAddedErrorHandler(): void
32+
{
33+
$previous = set_error_handler([$this, 'addedErrorHandler']);
34+
35+
$this->assertInstanceOf(ErrorHandler::class, $previous);
36+
$this->assertTrue(false);
37+
}
38+
39+
public function testRemovedErrorHandler(): void
40+
{
41+
restore_error_handler();
42+
$this->assertTrue(false);
43+
}
44+
45+
public function testAddedAndRemovedExceptionHandler(): void
46+
{
47+
$previous = set_exception_handler([$this, 'addedAndRemovedExceptionHandler']);
48+
restore_exception_handler();
49+
50+
$this->assertNull($previous);
51+
$this->assertTrue(true);
52+
}
53+
54+
public function testAddedExceptionHandler(): void
55+
{
56+
$previous = set_exception_handler([$this, 'addedExceptionHandler']);
57+
58+
$this->assertNull($previous);
59+
$this->assertTrue(false);
60+
}
61+
62+
public function testRemovedExceptionHandler(): void
63+
{
64+
restore_exception_handler();
65+
$this->assertTrue(false);
66+
}
67+
68+
public function addedAndRemovedErrorHandler($errno, $errstr, $errfile, $errline): void
69+
{
70+
}
71+
72+
public function addedErrorHandler($errno, $errstr, $errfile, $errline): void
73+
{
74+
}
75+
76+
public function addedAndRemovedExceptionHandler(Throwable $exception): void
77+
{
78+
}
79+
80+
public function addedExceptionHandler(Throwable $exception): void
81+
{
82+
}
83+
}

0 commit comments

Comments
 (0)