Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bridge\PhpUnit] Add "disabled" mode to SYMFONY_DEPRECATIONS_HELPER
- Loading branch information
1 parent
83ebf97
commit 2e0fa55
Showing
7 changed files
with
188 additions
and
8 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
64 changes: 64 additions & 0 deletions
64
src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.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,64 @@ | ||
--TEST-- | ||
Test DeprecationErrorHandler in default mode | ||
--FILE-- | ||
<?php | ||
|
||
putenv('SYMFONY_DEPRECATIONS_HELPER'); | ||
|
||
$vendor = __DIR__; | ||
while (!file_exists($vendor.'/vendor')) { | ||
$vendor = dirname($vendor); | ||
} | ||
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); | ||
require PHPUNIT_COMPOSER_INSTALL; | ||
|
||
@trigger_error('root deprecation', E_USER_DEPRECATED); | ||
|
||
class PHPUnit_Util_Test | ||
{ | ||
public static function getGroups() | ||
{ | ||
return array(); | ||
} | ||
} | ||
|
||
class FooTestCase | ||
{ | ||
public function testLegacyFoo() | ||
{ | ||
@trigger_error('silenced foo deprecation', E_USER_DEPRECATED); | ||
trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); | ||
} | ||
|
||
public function testNonLegacyBar() | ||
{ | ||
@trigger_error('silenced bar deprecation', E_USER_DEPRECATED); | ||
trigger_error('unsilenced bar deprecation', E_USER_DEPRECATED); | ||
} | ||
} | ||
|
||
$foo = new FooTestCase(); | ||
$foo->testLegacyFoo(); | ||
$foo->testNonLegacyBar(); | ||
|
||
?> | ||
--EXPECTF-- | ||
Unsilenced deprecation notices (2) | ||
|
||
unsilenced foo deprecation: 1x | ||
1x in FooTestCase::testLegacyFoo | ||
|
||
unsilenced bar deprecation: 1x | ||
1x in FooTestCase::testNonLegacyBar | ||
|
||
Remaining deprecation notices (1) | ||
|
||
silenced bar deprecation: 1x | ||
1x in FooTestCase::testNonLegacyBar | ||
|
||
Legacy deprecation notices (1) | ||
|
||
Other deprecation notices (1) | ||
|
||
root deprecation: 1x | ||
|
20 changes: 20 additions & 0 deletions
20
src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled.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,20 @@ | ||
--TEST-- | ||
Test DeprecationErrorHandler in weak mode | ||
--FILE-- | ||
<?php | ||
|
||
putenv('SYMFONY_DEPRECATIONS_HELPER=disabled'); | ||
|
||
$vendor = __DIR__; | ||
while (!file_exists($vendor.'/vendor')) { | ||
$vendor = dirname($vendor); | ||
} | ||
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); | ||
require PHPUNIT_COMPOSER_INSTALL; | ||
|
||
echo (int) set_error_handler('var_dump'); | ||
echo (int) class_exists('Symfony\Bridge\PhpUnit\DeprecationErrorHandler', false); | ||
|
||
?> | ||
--EXPECTF-- | ||
00 |
37 changes: 37 additions & 0 deletions
37
src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/regexp.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,37 @@ | ||
--TEST-- | ||
Test DeprecationErrorHandler in weak mode | ||
--FILE-- | ||
<?php | ||
|
||
putenv('SYMFONY_DEPRECATIONS_HELPER=/foo/'); | ||
|
||
$vendor = __DIR__; | ||
while (!file_exists($vendor.'/vendor')) { | ||
$vendor = dirname($vendor); | ||
} | ||
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); | ||
require PHPUNIT_COMPOSER_INSTALL; | ||
|
||
@trigger_error('root deprecation', E_USER_DEPRECATED); | ||
|
||
class FooTestCase | ||
{ | ||
public function testLegacyFoo() | ||
{ | ||
@trigger_error('silenced foo deprecation', E_USER_DEPRECATED); | ||
trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); | ||
} | ||
} | ||
|
||
$foo = new FooTestCase(); | ||
$foo->testLegacyFoo(); | ||
|
||
?> | ||
--EXPECTF-- | ||
Legacy deprecation triggered by FooTestCase::testLegacyFoo: | ||
silenced foo deprecation | ||
Stack trace: | ||
#0 -(13): trigger_error() | ||
#1 -(19): FooTestCase->testLegacyFoo() | ||
#2 {main} | ||
|
34 changes: 34 additions & 0 deletions
34
src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.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,34 @@ | ||
--TEST-- | ||
Test DeprecationErrorHandler in weak mode | ||
--FILE-- | ||
<?php | ||
|
||
putenv('SYMFONY_DEPRECATIONS_HELPER=weak'); | ||
|
||
$vendor = __DIR__; | ||
while (!file_exists($vendor.'/vendor')) { | ||
$vendor = dirname($vendor); | ||
} | ||
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); | ||
require PHPUNIT_COMPOSER_INSTALL; | ||
|
||
@trigger_error('root deprecation', E_USER_DEPRECATED); | ||
|
||
class FooTestCase | ||
{ | ||
public function testLegacyFoo() | ||
{ | ||
@trigger_error('silenced foo deprecation', E_USER_DEPRECATED); | ||
trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED); | ||
} | ||
} | ||
|
||
$foo = new FooTestCase(); | ||
$foo->testLegacyFoo(); | ||
|
||
?> | ||
--EXPECTF-- | ||
Unsilenced deprecation notices (1) | ||
|
||
Legacy deprecation notices (1) | ||
|
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