8000 [PHPUnitBridge] deprecations not enabled anymore when disabled=0 · symfony/symfony@76cf3d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 76cf3d2

Browse files
committed
[PHPUnitBridge] deprecations not enabled anymore when disabled=0
Allow to pass 0 or 1 to disabled to be consistent with "verbose" key behavior
1 parent 141ce4c commit 76cf3d2

File tree

4 files changed

+79
-2
lines changed

4 files changed

+79
-2
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 8000 @@ public function __construct()
4949
* Registers and configures the deprecation handler.
5050
*
5151
* The mode is a query string with options:
52-
* - "disabled" to disable the deprecation handler
52+
* - "disabled" to enable/disable the deprecation handler
5353
* - "verbose" to enable/disable displaying the deprecation report
5454
* - "max" to configure the number of deprecations to allow before exiting with a non-zero
5555
* status code; it's an array with keys "total", "self", "direct" and "indirect"

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static function fromUrlEncodedString($serializedConfiguration)
166166
}
167167
}
168168

169-
if (isset($normalizedConfiguration['disabled'])) {
169+
if (isset($normalizedConfiguration['disabled']) && '0' !== $normalizedConfiguration['disabled']) {
170170
return self::inDisabledMode();
171171
}
172172

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Test DeprecationErrorHandler in default mode
3+
--FILE--
4+
<?php
5+
6+
$k = 'SYMFONY_DEPRECATIONS_HELPER';
7+
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'disabled=0');
8+
putenv($k);
9+
putenv('ANSICON');
10+
putenv('ConEmuANSI');
11+
putenv('TERM');
12+
13+
$vendor = __DIR__;
14+
while (!file_exists($vendor.'/vendor')) {
15+
$vendor = dirname($vendor);
16+
}
17+
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
18+
require PHPUNIT_COMPOSER_INSTALL;
19+
require_once __DIR__.'/../../bootstrap.php';
20+
21+
@trigger_error('root deprecation', E_USER_DEPRECATED);
22+
23+
eval(<<<'EOPHP'
24+
namespace PHPUnit\Util;
25+
26+
class Test
27+
{
28+
public static function getGroups()
29+
{
30+
return array();
31+
}
32+
}
33+
EOPHP
34+
);
35+
?>
36+
--EXPECTF--
37+
Other deprecation notices (1)
38+
39+
1x: root deprecation
40+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Test DeprecationErrorHandler in default mode
3+
--FILE--
4+
<?php
5+
6+
$k = 'SYMFONY_DEPRECATIONS_HELPER';
7+
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'disabled=1');
8+
putenv($k);
9+
putenv('ANSICON');
10+
putenv('ConEmuANSI');
11+
putenv('TERM');
12+
13+
$vendor = __DIR__;
14+
while (!file_exists($vendor.'/vendor')) {
15+
$vendor = dirname($vendor);
16+
}
17+
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
18+
require PHPUNIT_COMPOSER_INSTALL;
19+
require_once __DIR__.'/../../bootstrap.php';
20+
21+
@trigger_error('root deprecation', E_USER_DEPRECATED);
22+
23+
eval(<<<'EOPHP'
24+
namespace PHPUnit\Util;
25+
26+
class Test
27+
{
28+
public static function getGroups()
29+
{
30+
return array();
31+
}
32+
}
33+
EOPHP
34+
);
35+
?>
36+
--EXPECTF--
37+

0 commit comments

Comments
 (0)
0