-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register deprecation triggers in process isolation
When process isolation is used, the deprecation triggers are not registered on the ErrorHandler.
- Loading branch information
1 parent
bc822c6
commit 563604b
Showing
5 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/end-to-end/deprecation-trigger/_files/details-process-isolation/phpunit.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd" | ||
cacheResult="false" | ||
processIsolation="true" | ||
> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<source> | ||
<deprecationTrigger> | ||
<method>PHPUnit\TestFixture\DeprecationTrigger\Test::triggerDeprecation</method> | ||
<function>PHPUnit\TestFixture\DeprecationTrigger\triggerDeprecation</function> | ||
</deprecationTrigger> | ||
</source> | ||
</phpunit> |
35 changes: 35 additions & 0 deletions
35
tests/end-to-end/deprecation-trigger/_files/details-process-isolation/tests/Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\TestFixture\DeprecationTrigger; | ||
|
||
use const E_USER_DEPRECATED; | ||
use function trigger_error; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class Test extends TestCase | ||
{ | ||
public static function triggerDeprecation(): void | ||
{ | ||
trigger_error('deprecation triggered by method', E_USER_DEPRECATED); | ||
} | ||
|
||
public function testDeprecation(): void | ||
{ | ||
self::triggerDeprecation(); | ||
triggerDeprecation(); | ||
|
||
$this->assertTrue(true); | ||
} | ||
} | ||
|
||
function triggerDeprecation(): void | ||
{ | ||
trigger_error('deprecation triggered by function', E_USER_DEPRECATED); | ||
} |
42 changes: 42 additions & 0 deletions
42
tests/end-to-end/deprecation-trigger/details-process-isolation.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--TEST-- | ||
Configured deprecation triggers are filtered when displaying deprecation details in process isolation | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
$_SERVER['argv'][] = '--do-not-cache-result'; | ||
$_SERVER['argv'][] = '--configuration'; | ||
$_SERVER['argv'][] = __DIR__ . '/_files/details-process-isolation/phpunit.xml'; | ||
$_SERVER['argv'][] = '--display-deprecations'; | ||
|
||
require __DIR__ . '/../../bootstrap.php'; | ||
|
||
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']); | ||
--EXPECTF-- | ||
PHPUnit %s by Sebastian Bergmann and contributors. | ||
|
||
Runtime: %s | ||
Configuration: %s | ||
|
||
D 1 / 1 (100%) | ||
|
||
Time: %s, Memory: %s | ||
|
||
1 test triggered 2 deprecations: | ||
|
||
1) %sTest.php:25 | ||
deprecation triggered by method | ||
|
||
Triggered by: | ||
|
||
* PHPUnit\TestFixture\DeprecationTrigger\Test::testDeprecation | ||
%sTest.php:23 | ||
|
||
2) %sTest.php:26 | ||
deprecation triggered by function | ||
|
||
Triggered by: | ||
|
||
* PHPUnit\TestFixture\DeprecationTrigger\Test::testDeprecation | ||
%sTest.php:23 | ||
|
||
OK, but there were issues! | ||
Tests: 1, Assertions: 1, Deprecations: 2. |