Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bridge\PhpUnit] Add "disabled" mode to SYMFONY_DEPRECATIONS_HELPER #18232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ services:
- redis-server

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

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
class DeprecationErrorHandler
{
const MODE_WEAK = 'weak';
const MODE_DISABLED = 'disabled';

private static $isRegistered = false;

Expand Down Expand Up @@ -67,11 +68,10 @@ public static function register($mode = 0)
'other' => array(),
);
$deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations, $getMode) {
if (E_USER_DEPRECATED !== $type) {
if (E_USER_DEPRECATED !== $type || DeprecationErrorHandler::MODE_DISABLED === $mode = $getMode()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is $mode used?

return \PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
}

$mode = $getMode();
$trace = debug_backtrace(true);
$group = 'other';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
Test DeprecationErrorHandler in weak mode
--FILE--
<?php

putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
putenv('ANSICON');
putenv('ConEmuANSI');
putenv('TERM');

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = dirname($vendor);
}
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
require_once __DIR__.'/../../bootstrap.php';

echo (int) set_error_handler('var_dump');
echo (int) class_exists('Symfony\Bridge\PhpUnit\DeprecationErrorHandler', false);

?>
--EXPECTF--
00
2 changes: 0 additions & 2 deletions src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

use Symfony\Bridge\PhpUnit\DnsMock;

require_once __DIR__.'/../DnsMock.php';

class DnsMockTest extends \PHPUnit_Framework_TestCase
{
protected function tearDown()
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Bridge/PhpUnit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@
AnnotationRegistry::registerLoader('class_exists');
}

DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
}