From a5122174312fb9e3ea6c5fc6c20667d55e5a0516 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 19 Nov 2017 20:49:57 +0200 Subject: [PATCH 1/2] Remove function_exists(__phpunit_run_isolated_test) checks --- src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php | 4 +--- .../Component/Routing/Tests/Fixtures/validresource.php | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php b/src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php index d338ca9d57..21e0aba17d 100644 --- a/src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php +++ b/src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php @@ -1,5 +1,3 @@ import('validpattern.php'); From 0187e9b3400e55b978901483ad71f40dc48c70ed Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 19 Nov 2017 21:42:16 +0200 Subject: [PATCH 2/2] [Bridge/PhpUnit] Fix compat with phpunit 4.8 & bridge <=3.3.13 --- composer.json | 2 +- src/Symfony/Bridge/PhpUnit/Blacklist.php | 23 ++++++++++++++----- src/Symfony/Bridge/PhpUnit/bin/simple-phpunit | 2 +- src/Symfony/Bridge/PhpUnit/bootstrap.php | 4 +++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 1c8a7027bc..202e141f36 100644 --- a/composer.json +++ b/composer.json @@ -97,7 +97,7 @@ "ocramius/proxy-manager": "~0.4|~1.0|~2.0", "predis/predis": "~1.0", "egulias/email-validator": "~1.2,>=1.2.8|~2.0", - "symfony/phpunit-bridge": "~3.2", + "symfony/phpunit-bridge": "~3.4|~4.0", "symfony/security-acl": "~2.8|~3.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0", "sensio/framework-extra-bundle": "^3.0.2" diff --git a/src/Symfony/Bridge/PhpUnit/Blacklist.php b/src/Symfony/Bridge/PhpUnit/Blacklist.php index 09ff256dec..abfd317258 100644 --- a/src/Symfony/Bridge/PhpUnit/Blacklist.php +++ b/src/Symfony/Bridge/PhpUnit/Blacklist.php @@ -23,12 +23,19 @@ class Blacklist public function getBlacklistedDirectories() { - $root = dirname(__DIR__); - while ($root !== $parent = dirname($root)) { - $root = $parent; + $blacklist = array(); + + foreach (get_declared_classes() as $class) { + if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { + $r = new \ReflectionClass($class); + $v = dirname(dirname($r->getFileName())); + if (file_exists($v.'/composer/installed.json')) { + $blacklist[] = $v; + } + } } - return array($root); + return $blacklist; } public function isBlacklisted($file) @@ -37,5 +44,9 @@ class Blacklist } } -class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit\Util\Blacklist'); -class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit_Util_Blacklist'); +if (class_exists('PHPUnit\Util\Test')) { + class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit\Util\Blacklist'); +} +if (class_exists('PHPUnit_Util_Test')) { + class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit_Util_Blacklist'); +} diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit index 728ab1913d..f7e34e048b 100755 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit @@ -68,7 +68,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__ if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) { passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); } - passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"~3.3.11@dev|~3.4.0-beta2@dev|^4.0.0-beta2@dev\""); + passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"~3.4-beta5@dev|^4.0-beta5@dev\""); $prevRoot = getenv('COMPOSER_ROOT_VERSION'); putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99"); $exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", array(), $p, getcwd(), null, array('bypass_shell' => true))); diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index 1197ab050b..8e85feaa34 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -13,7 +13,9 @@ use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Replace the native phpunit Blacklist, it's a broken artifact from the past -require_once __DIR__.'/Blacklist.php'; +if (!class_exists('Symfony\Bridge\PhpUnit\Blacklist', false)) { + require_once __DIR__.'/Blacklist.php'; +} // Detect if we need to serialize deprecations to a file. if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {