Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 64fe539

Browse filesBrowse files
[Bridge\PhpUnit] Add "disabled" mode to SYMFONY_DEPRECATIONS_HELPER
1 parent a4af637 commit 64fe539
Copy full SHA for 64fe539

File tree

Expand file treeCollapse file tree

5 files changed

+31
-8
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+31
-8
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ services:
3737
- redis-server
3838

3939
before_install:
40+
- mkdir /tmp/slapd
41+
- slapd -f src/Symfony/Component/Ldap/Tests/Fixtures/conf/slapd.conf -h ldap://localhost:3389 &
4042
# Matrix lines for intermediate PHP versions are skipped for pull requests
4143
- if [[ ! $deps && ! $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && $TRAVIS_PHP_VERSION != hhvm && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; fi;
4244
# A sigchild-enabled-PHP is used to test the Process component on the lowest PHP matrix line
@@ -57,9 +59,6 @@ before_install:
5759
- if [[ $deps != skip && $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer/* ~/.composer/; composer global install; fi;
5860
- if [[ $deps != skip ]]; then ./phpunit install; fi;
5961
- export PHPUNIT=$(readlink -f ./phpunit)
60-
- mkdir /tmp/slapd
61-
- slapd -f src/Symfony/Component/Ldap/Tests/Fixtures/conf/slapd.conf -h ldap://localhost:3389 &
62-
- sleep 3
6362
- ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/base.ldif
6463
- ldapadd -h localhost:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif
6564

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
class DeprecationErrorHandler
2020
{
2121
const MODE_WEAK = 'weak';
22+
const MODE_DISABLED = 'disabled';
2223

2324
private static $isRegistered = false;
2425

@@ -67,11 +68,10 @@ public static function register($mode = 0)
6768
'other' => array(),
6869
);
6970
$deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations, $getMode) {
70-
if (E_USER_DEPRECATED !== $type) {
71+
if (E_USER_DEPRECATED !== $type || DeprecationErrorHandler::MODE_DISABLED === $mode = $getMode()) {
7172
return \PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
7273
}
7374

74-
$mode = $getMode();
7575
$trace = debug_backtrace(true);
7676
$group = 'other';
7777

+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Test DeprecationErrorHandler in weak mode
3+
--FILE--
4+
<?php
5+
6+
putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
7+
putenv('ANSICON');
8+
putenv('ConEmuANSI');
9+
putenv('TERM');
10+
11+
$vendor = __DIR__;
12+
while (!file_exists($vendor.'/vendor')) {
13+
$vendor = dirname($vendor);
14+
}
15+
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
16+
require PHPUNIT_COMPOSER_INSTALL;
17+
require_once __DIR__.'/../../bootstrap.php';
18+
19+
echo (int) set_error_handler('var_dump');
20+
echo (int) class_exists('Symfony\Bridge\PhpUnit\DeprecationErrorHandler', false);
21+
22+
?>
23+
--EXPECTF--
24+
00

‎src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
use Symfony\Bridge\PhpUnit\DnsMock;
1515

16-
require_once __DIR__.'/../DnsMock.php';
17-
1816
class DnsMockTest extends \PHPUnit_Framework_TestCase
1917
{
2018
protected function tearDown()

‎src/Symfony/Bridge/PhpUnit/bootstrap.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/bootstrap.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@
2424
AnnotationRegistry::registerLoader('class_exists');
2525
}
2626

27-
DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
27+
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
28+
DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
29+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.