From 3d308cdd3060b4f7e62df61788c45d6019f1f88b Mon Sep 17 00:00:00 2001 From: Jan Rosier Date: Wed, 1 Jan 2020 12:03:25 +0100 Subject: [PATCH 1/9] Update year in license files --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index cf8b3ebe..684fbf94 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2019 Fabien Potencier +Copyright (c) 2014-2020 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 34f0f401940755818106d794b39a3dbe334a097d Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 3 Jan 2020 11:52:47 +0100 Subject: [PATCH 2/9] [PhpUnitBridge][SymfonyTestsListenerTrait] Remove $testsWithWarnings stack --- Legacy/SymfonyTestsListenerForV5.php | 5 ----- Legacy/SymfonyTestsListenerForV6.php | 5 ----- Legacy/SymfonyTestsListenerForV7.php | 5 ----- Legacy/SymfonyTestsListenerTrait.php | 9 --------- 4 files changed, 24 deletions(-) diff --git a/Legacy/SymfonyTestsListenerForV5.php b/Legacy/SymfonyTestsListenerForV5.php index 2da40f2c..a760d126 100644 --- a/Legacy/SymfonyTestsListenerForV5.php +++ b/Legacy/SymfonyTestsListenerForV5.php @@ -47,11 +47,6 @@ public function startTest(\PHPUnit_Framework_Test $test) $this->trait->startTest($test); } - public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) - { - $this->trait->addWarning($test, $e, $time); - } - public function endTest(\PHPUnit_Framework_Test $test, $time) { $this->trait->endTest($test, $time); diff --git a/Legacy/SymfonyTestsListenerForV6.php b/Legacy/SymfonyTestsListenerForV6.php index 5b864bfe..bcab4be4 100644 --- a/Legacy/SymfonyTestsListenerForV6.php +++ b/Legacy/SymfonyTestsListenerForV6.php @@ -52,11 +52,6 @@ public function startTest(Test $test) $this->trait->startTest($test); } - public function addWarning(Test $test, Warning $e, $time) - { - $this->trait->addWarning($test, $e, $time); - } - public function endTest(Test $test, $time) { $this->trait->endTest($test, $time); diff --git a/Legacy/SymfonyTestsListenerForV7.php b/Legacy/SymfonyTestsListenerForV7.php index 18bbdbeb..0c2069c6 100644 --- a/Legacy/SymfonyTestsListenerForV7.php +++ b/Legacy/SymfonyTestsListenerForV7.php @@ -55,11 +55,6 @@ public function startTest(Test $test): void $this->trait->startTest($test); } - public function addWarning(Test $test, Warning $e, float $time): void - { - $this->trait->addWarning($test, $e, $time); - } - public function endTest(Test $test, float $time): void { $this->trait->endTest($test, $time); diff --git a/Legacy/SymfonyTestsListenerTrait.php b/Legacy/SymfonyTestsListenerTrait.php index ed84eedf..36d866b7 100644 --- a/Legacy/SymfonyTestsListenerTrait.php +++ b/Legacy/SymfonyTestsListenerTrait.php @@ -37,7 +37,6 @@ class SymfonyTestsListenerTrait private $expectedDeprecations = array(); private $gatheredDeprecations = array(); private $previousErrorHandler; - private $testsWithWarnings; private $reportUselessTests; private $error; private $runsInSeparateProcess = false; @@ -114,7 +113,6 @@ public function startTestSuite($suite) $Test = 'PHPUnit\Util\Test'; } $suiteName = $suite->getName(); - $this->testsWithWarnings = array(); foreach ($suite->tests() as $test) { if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { @@ -245,13 +243,6 @@ public function startTest($test) } } - public function addWarning($test, $e, $time) - { - if ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) { - $this->testsWithWarnings[$test->getName()] = true; - } - } - public function endTest($test, $time) { if (class_exists('PHPUnit_Util_Blacklist', false)) { From e1abdf2abdee6ba95a3334dbd63929c4f5dc0867 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 3 Jan 2020 12:08:23 +0100 Subject: [PATCH 3/9] [PhpUnitBridge] Add test case for @expectedDeprecation annotation --- Tests/ExpectedDeprecationAnnotationTest.php | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Tests/ExpectedDeprecationAnnotationTest.php diff --git a/Tests/ExpectedDeprecationAnnotationTest.php b/Tests/ExpectedDeprecationAnnotationTest.php new file mode 100644 index 00000000..259c9916 --- /dev/null +++ b/Tests/ExpectedDeprecationAnnotationTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Tests; + +use PHPUnit\Framework\TestCase; + +final class ExpectedDeprecationAnnotationTest extends TestCase +{ + /** + * Do not remove this test in the next major versions. + * + * @group legacy + * + * @expectedDeprecation foo + */ + public function testOne() + { + @trigger_error('foo', E_USER_DEPRECATED); + } + + /** + * Do not remove this test in the next major versions. + * + * @group legacy + * + * @expectedDeprecation foo + * @expectedDeprecation bar + */ + public function testMany() + { + @trigger_error('foo', E_USER_DEPRECATED); + @trigger_error('bar', E_USER_DEPRECATED); + } +} From eb1ea840f1b16e89ebddd910c6f666dd3e8cc251 Mon Sep 17 00:00:00 2001 From: Oleg Andreyev Date: Tue, 7 Jan 2020 00:31:32 +0200 Subject: [PATCH 4/9] [PhpUnitBridge] When using phpenv + phpenv-composer plugin, composer executable is wrapped into a bash script --- bin/simple-phpunit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/simple-phpunit b/bin/simple-phpunit index 262fdd9d..da99873a 100755 --- a/bin/simple-phpunit +++ b/bin/simple-phpunit @@ -60,7 +60,7 @@ 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`)) - ? $PHP.' '.escapeshellarg($COMPOSER) + ? (file_get_contents($COMPOSER, 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')) { From 2315f6b72c0842a0e73f6b7a214c1ef12f195872 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 8 Jan 2020 14:37:17 +0100 Subject: [PATCH 5/9] [PHPUnit-Bridge] Fail-fast in simple-phpunit if one of the passthru() commands fails --- bin/simple-phpunit | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/simple-phpunit b/bin/simple-phpunit index da99873a..2bdd705e 100755 --- a/bin/simple-phpunit +++ b/bin/simple-phpunit @@ -15,6 +15,14 @@ error_reporting(-1); +$passthruOrFail = function ($command) { + passthru($command, $status); + + if ($status) { + exit($status); + } +}; + if (PHP_VERSION_ID >= 70200) { // PHPUnit 6 is required for PHP 7.2+ $PHPUNIT_VERSION = getenv('SYMFONY_PHPUNIT_VERSION') ?: '6.5'; @@ -77,25 +85,25 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__ rename("phpunit-$PHPUNIT_VERSION", "phpunit-$PHPUNIT_VERSION.old"); passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION.old")); } - passthru("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\""); + $passthruOrFail("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\""); @copy("phpunit-$PHPUNIT_VERSION/phpunit.xsd", 'phpunit.xsd'); chdir("phpunit-$PHPUNIT_VERSION"); if ($SYMFONY_PHPUNIT_REMOVE) { - passthru("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE); + $passthruOrFail("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE); } if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) { - passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); + $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); } - passthru("$COMPOSER config --unset platform"); + $passthruOrFail("$COMPOSER config --unset platform"); if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) { - passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); - passthru("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); + $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); + $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); if ('\\' === DIRECTORY_SEPARATOR) { file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json'))); } } else { - passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*\""); + $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*\""); } $prevRoot = getenv('COMPOSER_ROOT_VERSION'); putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99"); From 86436e216b0aecf2286202dfb4201e49db9da812 Mon Sep 17 00:00:00 2001 From: Pablo Lozano Date: Thu, 9 Jan 2020 09:55:05 +0100 Subject: [PATCH 6/9] [PHPUnitBridge] file_get_contents() expects parameter 3 to be resource --- bin/simple-phpunit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/simple-phpunit b/bin/simple-phpunit index da99873a..0366b07c 100755 --- a/bin/simple-phpunit +++ b/bin/simple-phpunit @@ -60,7 +60,7 @@ 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, null, 0, 18) === '#!/usr/bin/env php' ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang + ? (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')) { From 4ec4a2399d0a3e2d7e1498053adf0892efb6461d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 9 Jan 2020 13:44:20 +0100 Subject: [PATCH 7/9] fix tests --- bin/simple-phpunit | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/simple-phpunit b/bin/simple-phpunit index 3fb5d4bf..f726a7cf 100755 --- a/bin/simple-phpunit +++ b/bin/simple-phpunit @@ -95,7 +95,9 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__ $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); } - $passthruOrFail("$COMPOSER config --unset platform"); + if (PHP_VERSION_ID >= 70000) { + $passthruOrFail("$COMPOSER config --unset platform"); + } if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) { $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); From 5ef67a3f7a26eb24b9796b5cdfd3df50c3ef7efb Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 9 Jan 2020 14:36:09 +0100 Subject: [PATCH 8/9] [PhpUnitBridge] fix compat with older versions of composer --- bin/simple-phpunit | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/simple-phpunit b/bin/simple-phpunit index f726a7cf..11a40d55 100755 --- a/bin/simple-phpunit +++ b/bin/simple-phpunit @@ -95,9 +95,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__ $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); } - if (PHP_VERSION_ID >= 70000) { - $passthruOrFail("$COMPOSER config --unset platform"); - } + $passthruOrFail("$COMPOSER config --unset platform.php"); if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) { $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); From ebfd1b428ffc14306e843092763f228bfba168d0 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 2 Jan 2020 19:17:31 +0100 Subject: [PATCH 9/9] [PhpUnitBridge][SymfonyTestsListenerTrait] Remove some unneeded code --- Legacy/SymfonyTestsListenerTrait.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Legacy/SymfonyTestsListenerTrait.php b/Legacy/SymfonyTestsListenerTrait.php index 4591f67e..54c15b67 100644 --- a/Legacy/SymfonyTestsListenerTrait.php +++ b/Legacy/SymfonyTestsListenerTrait.php @@ -37,7 +37,6 @@ class SymfonyTestsListenerTrait private $gatheredDeprecations = array(); private $previousErrorHandler; private $testsWithWarnings; - private $reportUselessTests; private $error; private $runsInSeparateProcess = false; @@ -198,10 +197,6 @@ public function addSkippedTest($test, \Exception $e, $time) public function startTest($test) { if (-2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { - if (null !== $test->getTestResultObject()) { - $this->reportUselessTests = $test->getTestResultObject()->isStrictAboutTestsThatDoNotTestAnything(); - } - // This event is triggered before the test is re-run in isolation if ($this->willBeIsolated($test)) { $this->runsInSeparateProcess = tempnam(sys_get_temp_dir(), 'deprec'); @@ -267,11 +262,6 @@ public function endTest($test, $time) $classGroups = $Test::getGroups($className); $groups = $Test::getGroups($className, $test->getName(false)); - if (null !== $this->reportUselessTests) { - $test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything($this->reportUselessTests); - $this->reportUselessTests = null; - } - if ($errored = null !== $this->error) { $test->getTestResultObject()->addError($test, $this->error, 0); $this->error = null;