From 797ea2e4e21af932671da04f1fad7268bede3296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Mon, 5 Aug 2019 10:06:54 +0200 Subject: [PATCH] Use namespaced Phpunit classes --- .travis.yml | 1 + .../ResolveInstanceofConditionalsPassTest.php | 4 +-- ...ContainerParametersResourceCheckerTest.php | 7 +++--- .../Tests/Resources/TranslationFilesTest.php | 6 +---- ...mptyControllerArgumentLocatorsPassTest.php | 2 +- .../AbstractNumberFormatterTest.php | 25 +++---------------- .../Tests/Resources/TranslationFilesTest.php | 6 +---- .../Tests/Resources/TranslationFilesTest.php | 6 +---- .../Component/Yaml/Tests/ParserTest.php | 4 --- 9 files changed, 15 insertions(+), 46 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e9ea20b62..fc3ff15d0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -209,6 +209,7 @@ install: git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit SYMFONY_VERSION=$(cat src/Symfony/Bridge/PhpUnit/composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*') sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_VERSION'.x@dev"/' composer.json + rm -rf .phpunit fi - | diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php index 1996216aa6..83be84bd0c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php @@ -201,7 +201,7 @@ class ResolveInstanceofConditionalsPassTest extends TestCase public function testProcessThrowsExceptionForAutoconfiguredCalls() { $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Autoconfigured instanceof for type "PHPUnit\Framework\TestCase" defines method calls but these are not supported and should be removed.'); + $this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines method calls but these are not supported and should be removed\./'); $container = new ContainerBuilder(); $container->registerForAutoconfiguration(parent::class) ->addMethodCall('setFoo'); @@ -212,7 +212,7 @@ class ResolveInstanceofConditionalsPassTest extends TestCase public function testProcessThrowsExceptionForArguments() { $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Autoconfigured instanceof for type "PHPUnit\Framework\TestCase" defines arguments but these are not supported and should be removed.'); + $this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./'); $container = new ContainerBuilder(); $container->registerForAutoconfiguration(parent::class) ->addArgument('bar'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php index eb5fc5a99d..51af451c16 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Config; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\ResourceCheckerInterface; use Symfony\Component\DependencyInjection\Config\ContainerParametersResource; @@ -52,15 +53,15 @@ class ContainerParametersResourceCheckerTest extends TestCase public function isFreshProvider() { - yield 'not fresh on missing parameter' => [function (\PHPUnit_Framework_MockObject_MockObject $container) { + yield 'not fresh on missing parameter' => [function (MockObject $container) { $container->method('hasParameter')->with('locales')->willReturn(false); }, false]; - yield 'not fresh on different value' => [function (\PHPUnit_Framework_MockObject_MockObject $container) { + yield 'not fresh on different value' => [function (MockObject $container) { $container->method('getParameter')->with('locales')->willReturn(['nl', 'es']); }, false]; - yield 'fresh on every identical parameters' => [function (\PHPUnit_Framework_MockObject_MockObject $container) { + yield 'fresh on every identical parameters' => [function (MockObject $container) { $container->expects($this->exactly(2))->method('hasParameter')->willReturn(true); $container->expects($this->exactly(2))->method('getParameter') ->withConsecutive( diff --git a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php index d0bc82e759..49e69ef190 100644 --- a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php @@ -20,11 +20,7 @@ class TranslationFilesTest extends TestCase */ public function testTranslationFileIsValid($filePath) { - if (class_exists('PHPUnit_Util_XML')) { - \PHPUnit_Util_XML::loadfile($filePath, false, false, true); - } else { - \PHPUnit\Util\XML::loadfile($filePath, false, false, true); - } + \PHPUnit\Util\XML::loadfile($filePath, false, false, true); $this->addToAssertionCount(1); } diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php index 713ab5441a..84d7351560 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php @@ -26,7 +26,7 @@ class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('stdClass', 'stdClass'); - $container->register(parent::class, 'stdClass'); + $container->register(TestCase::class, 'stdClass'); $container->register('c1', RemoveTestController1::class)->addTag('controller.service_arguments'); $container->register('c2', RemoveTestController2::class)->addTag('controller.service_arguments') ->addMethodCall('setTestCase', [new Reference('c1')]); diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 0d382341f5..464a0aac0c 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Intl\Tests\NumberFormatter; +use PHPUnit\Framework\Error\Warning; use PHPUnit\Framework\TestCase; use Symfony\Component\Intl\Globals\IntlGlobals; use Symfony\Component\Intl\NumberFormatter\NumberFormatter; @@ -323,13 +324,7 @@ abstract class AbstractNumberFormatterTest extends TestCase */ public function testFormatTypeCurrency($formatter, $value) { - $exceptionCode = 'PHPUnit\Framework\Error\Warning'; - - if (class_exists('PHPUnit_Framework_Error_Warning')) { - $exceptionCode = 'PHPUnit_Framework_Error_Warning'; - } - - $this->expectException($exceptionCode); + $this->expectException(Warning::class); $formatter->format($value, NumberFormatter::TYPE_CURRENCY); } @@ -706,13 +701,7 @@ abstract class AbstractNumberFormatterTest extends TestCase public function testParseTypeDefault() { - $exceptionCode = 'PHPUnit\Framework\Error\Warning'; - - if (class_exists('PHPUnit_Framework_Error_Warning')) { - $exceptionCode = 'PHPUnit_Framework_Error_Warning'; - } - - $this->expectException($exceptionCode); + $this->expectException(Warning::class); $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->parse('1', NumberFormatter::TYPE_DEFAULT); @@ -832,13 +821,7 @@ abstract class AbstractNumberFormatterTest extends TestCase public function testParseTypeCurrency() { - $exceptionCode = 'PHPUnit\Framework\Error\Warning'; - - if (class_exists('PHPUnit_Framework_Error_Warning')) { - $exceptionCode = 'PHPUnit_Framework_Error_Warning'; - } - - $this->expectException($exceptionCode); + $this->expectException(Warning::class); $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->parse('1', NumberFormatter::TYPE_CURRENCY); diff --git a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php index f4e0d9e6e8..bc21d272fc 100644 --- a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php @@ -20,11 +20,7 @@ class TranslationFilesTest extends TestCase */ public function testTranslationFileIsValid($filePath) { - if (class_exists('PHPUnit_Util_XML')) { - \PHPUnit_Util_XML::loadfile($filePath, false, false, true); - } else { - \PHPUnit\Util\XML::loadfile($filePath, false, false, true); - } + \PHPUnit\Util\XML::loadfile($filePath, false, false, true); $this->addToAssertionCount(1); } diff --git a/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php index 64b3f78934..56ff24d2fd 100644 --- a/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php @@ -20,11 +20,7 @@ class TranslationFilesTest extends TestCase */ public function testTranslationFileIsValid($filePath) { - if (class_exists('PHPUnit_Util_XML')) { - \PHPUnit_Util_XML::loadfile($filePath, false, false, true); - } else { - \PHPUnit\Util\XML::loadfile($filePath, false, false, true); - } + \PHPUnit\Util\XML::loadfile($filePath, false, false, true); $this->addToAssertionCount(1); } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 8cc95d7bfe..a806723025 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -45,10 +45,6 @@ class ParserTest extends TestCase if (E_USER_DEPRECATED !== $type) { restore_error_handler(); - if (class_exists('PHPUnit_Util_ErrorHandler')) { - return \call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', \func_get_args()); - } - return \call_user_func_array('PHPUnit\Util\ErrorHandler::handleError', \func_get_args()); }