From dfa1b61069146626f16debae3e152bd7c33a871b Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Thu, 23 Apr 2020 09:31:24 +0200 Subject: [PATCH 1/3] fix compatibility with phpunit 9 --- Legacy/SymfonyTestsListenerTrait.php | 7 +++++-- bin/simple-phpunit | 4 ++++ composer.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Legacy/SymfonyTestsListenerTrait.php b/Legacy/SymfonyTestsListenerTrait.php index 69bbcfc0..77693421 100644 --- a/Legacy/SymfonyTestsListenerTrait.php +++ b/Legacy/SymfonyTestsListenerTrait.php @@ -46,9 +46,12 @@ class SymfonyTestsListenerTrait public function __construct(array $mockedNamespaces = array()) { if (class_exists('PHPUnit_Util_Blacklist')) { - \PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2; + \PHPUnit_Util_Blacklist::$blacklistedClassNames[__CLASS__] = 2; + } elseif (method_exists(Blacklist::class, 'addDirectory')) { + (new BlackList())->getBlacklistedDirectories(); + Blacklist::addDirectory(\dirname(\dirname((new \ReflectionClass(__CLASS__))->getFileName()))); } else { - Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2; + Blacklist::$blacklistedClassNames[__CLASS__] = 2; } $warn = false; diff --git a/bin/simple-phpunit b/bin/simple-phpunit index d2c23f20..3043daab 100755 --- a/bin/simple-phpunit +++ b/bin/simple-phpunit @@ -126,6 +126,10 @@ if (!class_exists('SymfonyBlacklistPhpunit', false)) { if (class_exists('PHPUnit_Util_Blacklist')) { PHPUnit_Util_Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1; PHPUnit_Util_Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1; +} elseif (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) { + (new PHPUnit\Util\BlackList())->getBlacklistedDirectories(); + PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistPhpunit'))->getFileName())); + PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistSimplePhpunit'))->getFileName())); } else { PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1; PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1; diff --git a/composer.json b/composer.json index f7d94926..30b3cc23 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "symfony/debug": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0|<6.4,>=6.0" + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0|<6.4,>=6.0|9.1.2" }, "autoload": { "files": [ "bootstrap.php" ], From 0b83e8ad3247d1ebac4797ce90a0c56a0140be44 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 24 Apr 2020 14:56:41 +0200 Subject: [PATCH 2/3] [PhpUnitBridge] Use COMPOSER_BINARY env var if available --- bin/simple-phpunit | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/simple-phpunit b/bin/simple-phpunit index 3043daab..92d4d699 100755 --- a/bin/simple-phpunit +++ b/bin/simple-phpunit @@ -65,11 +65,13 @@ foreach ($defaultEnvs as $envName => $envValue) { } } -$COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar') - || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) - || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`)) - ? (file_get_contents($COMPOSER, false, null, 0, 18) === '#!/usr/bin/env php' ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang - : 'composer'; +if (false === $COMPOSER = \getenv('COMPOSER_BINARY')) { + $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar') + || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) + || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`)) + ? (file_get_contents($COMPOSER, false, null, 0, 18) === '#!/usr/bin/env php' ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang + : 'composer'; +} if (false === $SYMFONY_PHPUNIT_REMOVE = getenv('SYMFONY_PHPUNIT_REMOVE')) { $SYMFONY_PHPUNIT_REMOVE = 'phpspec/prophecy symfony/yaml'; From 8287ac11395d48805d02061ad774066d103bfc0f Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Fri, 24 Apr 2020 16:08:51 +0200 Subject: [PATCH 3/3] Improve dirname usage --- Legacy/SymfonyTestsListenerTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Legacy/SymfonyTestsListenerTrait.php b/Legacy/SymfonyTestsListenerTrait.php index 77693421..e260fb8d 100644 --- a/Legacy/SymfonyTestsListenerTrait.php +++ b/Legacy/SymfonyTestsListenerTrait.php @@ -49,7 +49,7 @@ public function __construct(array $mockedNamespaces = array()) \PHPUnit_Util_Blacklist::$blacklistedClassNames[__CLASS__] = 2; } elseif (method_exists(Blacklist::class, 'addDirectory')) { (new BlackList())->getBlacklistedDirectories(); - Blacklist::addDirectory(\dirname(\dirname((new \ReflectionClass(__CLASS__))->getFileName()))); + Blacklist::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2)); } else { Blacklist::$blacklistedClassNames[__CLASS__] = 2; }