From bdec105a72ef6c8d832fd2e80fabf1681a2d0616 Mon Sep 17 00:00:00 2001 From: Philipp Kolesnikov Date: Sun, 26 Jul 2020 15:13:16 +1000 Subject: [PATCH 01/16] [Cache] Fix #37667 --- .../Component/Cache/Adapter/ArrayAdapter.php | 4 ++++ .../Tests/Adapter/TagAwareAdapterTest.php | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index ff826f47a2..7e97875435 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -113,6 +113,10 @@ class ArrayAdapter implements AdapterInterface, LoggerAwareInterface, Resettable $value = $item["\0*\0value"]; $expiry = $item["\0*\0expiry"]; + if (0 === $expiry) { + $expiry = PHP_INT_MAX; + } + if (null !== $expiry && $expiry <= time()) { $this->deleteItem($key); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index 0108b9250b..11907a0313 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -14,6 +14,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use PHPUnit\Framework\MockObject\MockObject; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\AdapterInterface; +use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; @@ -255,6 +256,25 @@ class TagAwareAdapterTest extends AdapterTestCase $this->assertFalse($anotherPool->hasItem($itemKey)); } + public function testInvalidateTagsWithArrayAdapter() + { + $adapter = new TagAwareAdapter(new ArrayAdapter()); + + $item = $adapter->getItem('foo'); + + $this->assertFalse($item->isHit()); + + $item->tag('bar'); + $item->expiresAfter(100); + $adapter->save($item); + + $this->assertTrue($adapter->getItem('foo')->isHit()); + + $adapter->invalidateTags(['bar']); + + $this->assertFalse($adapter->getItem('foo')->isHit()); + } + public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemAndOnlyHasTags() { $pool = $this->createCachePool(); From cef16f591fed8cfa05c2d8c59a845a1e86283d9c Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Wed, 29 Jul 2020 17:02:56 +0200 Subject: [PATCH 02/16] [VarDumper] Improve previous fix on light array coloration --- src/Symfony/Component/VarDumper/Dumper/CliDumper.php | 7 +++++-- .../Component/VarDumper/Tests/Dumper/CliDumperTest.php | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index 881241ab3e..76737a499f 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -255,6 +255,10 @@ class CliDumper extends AbstractDumper */ public function enterHash(Cursor $cursor, $type, $class, $hasChild) { + if (null === $this->colors) { + $this->colors = $this->supportsColors(); + } + $this->dumpKey($cursor); if ($this->collapseNextHash) { @@ -268,8 +272,7 @@ class CliDumper extends AbstractDumper } elseif (Cursor::HASH_RESOURCE === $type) { $prefix = $this->style('note', $class.' resource').($hasChild ? ' {' : ' '); } else { - $unstyledPrefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? 'array:'.$class : ''; - $prefix = $this->style('note', $unstyledPrefix).($unstyledPrefix ? ' [' : '['); + $prefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? $this->style('note', 'array:'.$class).' [' : '['; } if ($cursor->softRefCount || 0 < $cursor->softRefHandle) { diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php index e7efaae95c..cefddb1908 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php @@ -578,7 +578,7 @@ EOTXT yield [ ['foo' => 'bar'], 0, -<< "\e[1;38;5;113mbar\e[0;38;5;208m"\e[m \e[0;38;5;208m]\e[m @@ -586,20 +586,20 @@ EOTXT EOTXT ]; - yield [[], AbstractDumper::DUMP_LIGHT_ARRAY, "\e[0;38;5;208m\e[38;5;38m\e[0;38;5;208m[]\e[m\n"]; + yield [[], AbstractDumper::DUMP_LIGHT_ARRAY, "\e[0;38;5;208m[]\e[m\n"]; yield [ ['foo' => 'bar'], AbstractDumper::DUMP_LIGHT_ARRAY, << "\e[1;38;5;113mbar\e[0;38;5;208m"\e[m \e[0;38;5;208m]\e[m EOTXT ]; - yield [[], 0, "\e[0;38;5;208m\e[38;5;38m\e[0;38;5;208m[]\e[m\n"]; + yield [[], 0, "\e[0;38;5;208m[]\e[m\n"]; } /** From b7d2b6042b9debc6a5cb69a1f5b943706d340fb9 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 3 Aug 2020 15:22:15 +0200 Subject: [PATCH 03/16] [Validator] sync translations --- .../Validator/Resources/translations/validators.en.xlf | 4 ++++ .../Validator/Resources/translations/validators.fr.xlf | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf index 674ccf5c30..ecc73e48aa 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf @@ -382,6 +382,10 @@ Each element of this collection should satisfy its own set of constraints. Each element of this collection should satisfy its own set of constraints. + + This value is not a valid International Securities Identification Number (ISIN). + This value is not a valid International Securities Identification Number (ISIN). + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf index c44ade69e0..a4dd54295b 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf @@ -382,6 +382,10 @@ Each element of this collection should satisfy its own set of constraints. Chaque élément de cette collection doit satisfaire à son propre jeu de contraintes. + + This value is not a valid International Securities Identification Number (ISIN). + Cette valeur n'est pas un code international de sécurité valide (ISIN). + From 38787ac7855e219ed155bfa9d62a5da5d89e0383 Mon Sep 17 00:00:00 2001 From: Alexander Janssen Date: Wed, 29 Jul 2020 17:05:52 +0200 Subject: [PATCH 04/16] [Serializer] Fix that it will never reach DOMNode --- .../Component/Serializer/Encoder/XmlEncoder.php | 6 +++--- .../Serializer/Tests/Encoder/XmlEncoderTest.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index dc932222e9..fc4cbe5d83 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -488,6 +488,9 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec $node->appendChild($child); } elseif ($val instanceof \Traversable) { $this->buildXml($node, $val); + } elseif ($val instanceof \DOMNode) { + $child = $this->dom->importNode($val, true); + $node->appendChild($child); } elseif (\is_object($val)) { if (null === $this->serializer) { throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used with object data.', __METHOD__)); @@ -502,9 +505,6 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec return $this->appendText($node, $val); } elseif (\is_bool($val)) { return $this->appendText($node, (int) $val); - } elseif ($val instanceof \DOMNode) { - $child = $this->dom->importNode($val, true); - $node->appendChild($child); } return true; diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index f1a8b6ab48..94f2e6c18a 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -662,6 +662,20 @@ XML; $this->assertEquals($expectedXml, $actualXml); } + public function testEncodeXmlWithDomNodeValue() + { + $expectedXml = <<<'XML' + +barfoo & bar + +XML; + $document = new \DOMDocument(); + + $actualXml = $this->encoder->encode(['foo' => $document->createTextNode('bar'), 'bar' => $document->createTextNode('foo & bar')], 'xml'); + + $this->assertEquals($expectedXml, $actualXml); + } + public function testEncodeXmlWithDateTimeObjectValue() { $xmlEncoder = $this->createXmlEncoderWithDateTimeNormalizer(); From 67102c32e68e89a66202f5bafb29038957bbf8a2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 8 Aug 2020 17:34:42 +0200 Subject: [PATCH 05/16] [Console] Make sure we pass a numeric array of arguments to call_user_func_array(). --- src/Symfony/Component/Console/Descriptor/TextDescriptor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index af9088c7c3..9600559079 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -204,7 +204,7 @@ class TextDescriptor extends Descriptor // calculate max. width based on available commands per namespace $width = $this->getColumnWidth(\call_user_func_array('array_merge', array_map(function ($namespace) use ($commands) { return array_intersect($namespace['commands'], array_keys($commands)); - }, $namespaces))); + }, array_values($namespaces)))); if ($describedNamespace) { $this->writeText(sprintf('Available commands for the "%s" namespace:', $describedNamespace), $options); From 8b801c1269964332919a59dbb72542d713f395ee Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 8 Aug 2020 21:12:02 +0200 Subject: [PATCH 06/16] The PHPUnit\Util\XML class has been removed in PHPUnit 9.3. --- .../Form/Tests/Resources/TranslationFilesTest.php | 7 ++++++- .../Security/Core/Tests/Resources/TranslationFilesTest.php | 7 ++++++- .../Validator/Tests/Resources/TranslationFilesTest.php | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php index 49e69ef190..35274af334 100644 --- a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form\Tests\Resources; use PHPUnit\Framework\TestCase; +use PHPUnit\Util\Xml\Loader; class TranslationFilesTest extends TestCase { @@ -20,7 +21,11 @@ class TranslationFilesTest extends TestCase */ public function testTranslationFileIsValid($filePath) { - \PHPUnit\Util\XML::loadfile($filePath, false, false, true); + $loader = class_exists(Loader::class) + ? [new Loader(), 'loadFile'] + : 'PHPUnit\Util\XML::loadfile'; + + $loader($filePath, false, false, true); $this->addToAssertionCount(1); } diff --git a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php index bc21d272fc..67e0ccdecb 100644 --- a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Security\Core\Tests\Resources; use PHPUnit\Framework\TestCase; +use PHPUnit\Util\Xml\Loader; class TranslationFilesTest extends TestCase { @@ -20,7 +21,11 @@ class TranslationFilesTest extends TestCase */ public function testTranslationFileIsValid($filePath) { - \PHPUnit\Util\XML::loadfile($filePath, false, false, true); + $loader = class_exists(Loader::class) + ? [new Loader(), 'loadFile'] + : 'PHPUnit\Util\XML::loadfile'; + + $loader($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 56ff24d2fd..6e903731f1 100644 --- a/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Validator\Tests\Resources; use PHPUnit\Framework\TestCase; +use PHPUnit\Util\Xml\Loader; class TranslationFilesTest extends TestCase { @@ -20,7 +21,11 @@ class TranslationFilesTest extends TestCase */ public function testTranslationFileIsValid($filePath) { - \PHPUnit\Util\XML::loadfile($filePath, false, false, true); + $loader = class_exists(Loader::class) + ? [new Loader(), 'loadFile'] + : 'PHPUnit\Util\XML::loadfile'; + + $loader($filePath, false, false, true); $this->addToAssertionCount(1); } From 8bd861bbc6ee176763eaa1982234faeb500661a8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 8 Aug 2020 21:42:49 +0200 Subject: [PATCH 07/16] [Console] The message of "class not found" errors has changed in php 8. --- .../Component/Console/Tests/ApplicationTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 8288cfd326..b6d279875e 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -1367,8 +1367,8 @@ class ApplicationTest extends TestCase $application->setCatchExceptions(false); $application->setDispatcher(new EventDispatcher()); - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { - new \UnknownClass(); + $application->register('dym')->setCode(function () { + throw new \Error('Something went wrong.'); }); $tester = new ApplicationTester($application); @@ -1377,7 +1377,7 @@ class ApplicationTest extends TestCase $tester->run(['command' => 'dym']); $this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.'); } catch (\Error $e) { - $this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found'); + $this->assertSame('Something went wrong.', $e->getMessage()); } } @@ -1702,8 +1702,8 @@ class ApplicationTest extends TestCase $application->setAutoExit(false); $application->setDispatcher(new EventDispatcher()); - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { - new \UnknownClass(); + $application->register('dym')->setCode(function () { + throw new \Error('Something went wrong.'); }); $tester = new ApplicationTester($application); @@ -1712,7 +1712,7 @@ class ApplicationTest extends TestCase $tester->run(['command' => 'dym']); $this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.'); } catch (\Error $e) { - $this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found'); + $this->assertSame('Something went wrong.', $e->getMessage()); } } } From ab417f7040f150006e399a8b4c040a3a9ab99d52 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 8 Aug 2020 16:41:28 +0200 Subject: [PATCH 08/16] Modernized deprecated PHPUnit assertion calls --- composer.json | 2 +- .../Twig/Tests/Command/LintCommandTest.php | 4 +- .../CacheClearCommandTest.php | 2 +- .../Tests/Command/RouterDebugCommandTest.php | 2 +- .../Command/TranslationDebugCommandTest.php | 20 +++++----- .../Command/TranslationUpdateCommandTest.php | 24 ++++++------ .../Tests/Resources/IconTest.php | 2 +- .../Config/Tests/Util/XmlUtilsTest.php | 2 +- .../Console/Tests/ApplicationTest.php | 38 +++++++++---------- .../Console/Tests/Command/ListCommandTest.php | 4 +- .../Debug/Tests/DebugClassLoaderTest.php | 4 +- .../Debug/Tests/ErrorHandlerTest.php | 4 +- .../ClassNotFoundFatalErrorHandlerTest.php | 2 +- .../Tests/Loader/FileLoaderTest.php | 2 +- .../Tests/Loader/XmlFileLoaderTest.php | 10 ++--- .../Tests/Loader/YamlFileLoaderTest.php | 4 +- .../Filesystem/Tests/FilesystemTest.php | 22 +++++------ .../Tests/BinaryFileResponseTest.php | 2 +- .../HttpFoundation/Tests/File/FileTest.php | 8 ++-- .../Tests/File/UploadedFileTest.php | 2 +- .../Tests/RedirectResponseTest.php | 2 +- .../Tests/ResponseHeaderBagTest.php | 2 +- .../DataCollector/ConfigDataCollectorTest.php | 4 +- .../Tests/HttpCache/HttpCacheTest.php | 20 +++++----- .../Tests/HttpCache/HttpCacheTestCase.php | 4 +- .../Component/HttpKernel/Tests/KernelTest.php | 6 +-- .../Intl/Tests/Util/GitRepositoryTest.php | 2 +- .../DigestAuthenticationEntryPointTest.php | 6 +-- .../Yaml/Tests/Command/LintCommandTest.php | 2 +- 29 files changed, 104 insertions(+), 104 deletions(-) diff --git a/composer.json b/composer.json index 5bc6183823..565d5f298f 100644 --- a/composer.json +++ b/composer.json @@ -98,7 +98,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.4.31|^4.3.4|~5.0", + "symfony/phpunit-bridge": "^5.2", "symfony/security-acl": "~2.8|~3.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0" }, diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index 84154512be..166f1d9c44 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -42,7 +42,7 @@ class LintCommandTest extends TestCase $ret = $tester->execute(['filename' => [$filename]], ['decorated' => false]); $this->assertEquals(1, $ret, 'Returns 1 in case of error'); - $this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay())); + $this->assertMatchesRegularExpression('/ERROR in \S+ \(line /', trim($tester->getDisplay())); } public function testLintFileNotReadable() @@ -63,7 +63,7 @@ class LintCommandTest extends TestCase $ret = $tester->execute(['filename' => [$filename]], ['decorated' => false]); $this->assertEquals(1, $ret, 'Returns 1 in case of error'); - $this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay())); + $this->assertMatchesRegularExpression('/ERROR in \S+ \(line /', trim($tester->getDisplay())); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php index c2cded7ab0..5168e046e5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php @@ -87,6 +87,6 @@ class CacheClearCommandTest extends TestCase } $containerRef = new \ReflectionClass(require $containerFile); $containerFile = str_replace('tes_'.\DIRECTORY_SEPARATOR, 'test'.\DIRECTORY_SEPARATOR, $containerRef->getFileName()); - $this->assertRegExp(sprintf('/\'kernel.container_class\'\s*=>\s*\'%s\'/', $containerClass), file_get_contents($containerFile), 'kernel.container_class is properly set on the dumped container'); + $this->assertMatchesRegularExpression(sprintf('/\'kernel.container_class\'\s*=>\s*\'%s\'/', $containerClass), file_get_contents($containerFile), 'kernel.container_class is properly set on the dumped container'); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php index a4842f239a..5bc80fad4b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php @@ -58,7 +58,7 @@ class RouterDebugCommandTest extends TestCase $tester->execute([]); - $this->assertRegExp('/foo\s+ANY\s+ANY\s+ANY\s+\\/foo/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/foo\s+ANY\s+ANY\s+ANY\s+\\/foo/', $tester->getDisplay()); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index b3e849b134..895c141f31 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -28,7 +28,7 @@ class TranslationDebugCommandTest extends TestCase $tester = $this->createCommandTester(['foo' => 'foo']); $tester->execute(['locale' => 'en', 'bundle' => 'foo']); - $this->assertRegExp('/missing/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/missing/', $tester->getDisplay()); } public function testDebugUnusedMessages() @@ -36,7 +36,7 @@ class TranslationDebugCommandTest extends TestCase $tester = $this->createCommandTester([], ['foo' => 'foo']); $tester->execute(['locale' => 'en', 'bundle' => 'foo']); - $this->assertRegExp('/unused/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/unused/', $tester->getDisplay()); } public function testDebugFallbackMessages() @@ -44,7 +44,7 @@ class TranslationDebugCommandTest extends TestCase $tester = $this->createCommandTester([], ['foo' => 'foo']); $tester->execute(['locale' => 'fr', 'bundle' => 'foo']); - $this->assertRegExp('/fallback/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/fallback/', $tester->getDisplay()); } public function testNoDefinedMessages() @@ -52,7 +52,7 @@ class TranslationDebugCommandTest extends TestCase $tester = $this->createCommandTester(); $tester->execute(['locale' => 'fr', 'bundle' => 'test']); - $this->assertRegExp('/No defined or extracted messages for locale "fr"/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/No defined or extracted messages for locale "fr"/', $tester->getDisplay()); } public function testDebugDefaultDirectory() @@ -60,8 +60,8 @@ class TranslationDebugCommandTest extends TestCase $tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']); $tester->execute(['locale' => 'en']); - $this->assertRegExp('/missing/', $tester->getDisplay()); - $this->assertRegExp('/unused/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/missing/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/unused/', $tester->getDisplay()); } public function testDebugDefaultRootDirectory() @@ -75,8 +75,8 @@ class TranslationDebugCommandTest extends TestCase $tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']); $tester->execute(['locale' => 'en']); - $this->assertRegExp('/missing/', $tester->getDisplay()); - $this->assertRegExp('/unused/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/missing/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/unused/', $tester->getDisplay()); } public function testDebugCustomDirectory() @@ -90,8 +90,8 @@ class TranslationDebugCommandTest extends TestCase $tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar'], $kernel); $tester->execute(['locale' => 'en', 'bundle' => $this->translationDir]); - $this->assertRegExp('/missing/', $tester->getDisplay()); - $this->assertRegExp('/unused/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/missing/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/unused/', $tester->getDisplay()); } public function testDebugInvalidDirectory() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index 8483f0f0da..ea3ff56dd3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -27,8 +27,8 @@ class TranslationUpdateCommandTest extends TestCase { $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]); - $this->assertRegExp('/foo/', $tester->getDisplay()); - $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/foo/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay()); } public function testDumpMessagesAndCleanInRootDirectory() @@ -40,32 +40,32 @@ class TranslationUpdateCommandTest extends TestCase $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); $tester->execute(['command' => 'translation:update', 'locale' => 'en', '--dump-messages' => true, '--clean' => true]); - $this->assertRegExp('/foo/', $tester->getDisplay()); - $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/foo/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay()); } public function testDumpTwoMessagesAndClean() { $tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'bar' => 'bar']]); $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]); - $this->assertRegExp('/foo/', $tester->getDisplay()); - $this->assertRegExp('/bar/', $tester->getDisplay()); - $this->assertRegExp('/2 messages were successfully extracted/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/foo/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/bar/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/2 messages were successfully extracted/', $tester->getDisplay()); } public function testDumpMessagesForSpecificDomain() { $tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]); $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--domain' => 'mydomain']); - $this->assertRegExp('/bar/', $tester->getDisplay()); - $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/bar/', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay()); } public function testWriteMessages() { $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true]); - $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay()); } public function testWriteMessagesInRootDirectory() @@ -77,14 +77,14 @@ class TranslationUpdateCommandTest extends TestCase $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); $tester->execute(['command' => 'translation:update', 'locale' => 'en', '--force' => true]); - $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay()); } public function testWriteMessagesForSpecificDomain() { $tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]); $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true, '--domain' => 'mydomain']); - $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); + $this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay()); } protected function setUp() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php index c3d691d4d3..a690721ebc 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php @@ -20,7 +20,7 @@ class IconTest extends TestCase */ public function testIconFileContents($iconFilePath) { - $this->assertRegExp('~.*~s', file_get_contents($iconFilePath), sprintf('The SVG metadata of the %s icon is different than expected (use the same as the other icons).', $iconFilePath)); + $this->assertMatchesRegularExpression('~.*~s', file_get_contents($iconFilePath), sprintf('The SVG metadata of the %s icon is different than expected (use the same as the other icons).', $iconFilePath)); } public function provideIconFilePaths() diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index 2aecdf8259..ffd017267a 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -81,7 +81,7 @@ class XmlUtilsTest extends TestCase XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate']); $this->fail(); } catch (\InvalidArgumentException $e) { - $this->assertRegExp('/The XML file ".+" is not valid\./', $e->getMessage()); + $this->assertMatchesRegularExpression('/The XML file ".+" is not valid\./', $e->getMessage()); } $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate'])); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 8288cfd326..b073665e6c 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -501,9 +501,9 @@ class ApplicationTest extends TestCase $this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); - $this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); - $this->assertRegExp('/foo1:bar/', $e->getMessage()); - $this->assertRegExp('/foo:bar/', $e->getMessage()); + $this->assertMatchesRegularExpression('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertMatchesRegularExpression('/foo1:bar/', $e->getMessage()); + $this->assertMatchesRegularExpression('/foo:bar/', $e->getMessage()); } // Namespace + plural @@ -512,8 +512,8 @@ class ApplicationTest extends TestCase $this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); - $this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); - $this->assertRegExp('/foo1/', $e->getMessage()); + $this->assertMatchesRegularExpression('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertMatchesRegularExpression('/foo1/', $e->getMessage()); } $application->add(new \Foo3Command()); @@ -525,8 +525,8 @@ class ApplicationTest extends TestCase $this->fail('->find() should throw an Symfony\Component\Console\Exception\CommandNotFoundException if a command is ambiguous because of a subnamespace, with alternatives'); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e); - $this->assertRegExp('/foo3:bar/', $e->getMessage()); - $this->assertRegExp('/foo3:bar:toh/', $e->getMessage()); + $this->assertMatchesRegularExpression('/foo3:bar/', $e->getMessage()); + $this->assertMatchesRegularExpression('/foo3:bar:toh/', $e->getMessage()); } } @@ -555,10 +555,10 @@ class ApplicationTest extends TestCase } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist'); $this->assertSame(['afoobar1', 'foo:bar1'], $e->getAlternatives()); - $this->assertRegExp(sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); - $this->assertRegExp('/afoobar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "afoobar1"'); - $this->assertRegExp('/foo:bar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "foo:bar1"'); - $this->assertNotRegExp('/foo:bar(?!1)/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without "foo:bar" alternative'); + $this->assertMatchesRegularExpression(sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertMatchesRegularExpression('/afoobar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "afoobar1"'); + $this->assertMatchesRegularExpression('/foo:bar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "foo:bar1"'); + $this->assertDoesNotMatchRegularExpression('/foo:bar(?!1)/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without "foo:bar" alternative'); } } @@ -605,10 +605,10 @@ class ApplicationTest extends TestCase $this->assertContains('foo', $e->getAlternatives()); $this->assertContains('foo1', $e->getAlternatives()); $this->assertContains('foo3', $e->getAlternatives()); - $this->assertRegExp('/There are no commands defined in the "foo2" namespace./', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative'); - $this->assertRegExp('/foo/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo"'); - $this->assertRegExp('/foo1/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo1"'); - $this->assertRegExp('/foo3/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo3"'); + $this->assertMatchesRegularExpression('/There are no commands defined in the "foo2" namespace./', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative'); + $this->assertMatchesRegularExpression('/foo/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo"'); + $this->assertMatchesRegularExpression('/foo1/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo1"'); + $this->assertMatchesRegularExpression('/foo3/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo3"'); } } @@ -639,7 +639,7 @@ class ApplicationTest extends TestCase $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command is not defined'); $this->assertSame($expectedAlternatives, $e->getAlternatives()); - $this->assertRegExp('/Command "foo" is not defined\..*Did you mean one of these\?.*/Ums', $e->getMessage()); + $this->assertMatchesRegularExpression('/Command "foo" is not defined\..*Did you mean one of these\?.*/Ums', $e->getMessage()); } } @@ -721,9 +721,9 @@ class ApplicationTest extends TestCase $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions'); $tester->run(['command' => 'foo3:bar'], ['decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]); - $this->assertRegExp('/\[Exception\]\s*First exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is default and verbosity is verbose'); - $this->assertRegExp('/\[Exception\]\s*Second exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is 0 and verbosity is verbose'); - $this->assertRegExp('/\[Exception \(404\)\]\s*Third exception/', $tester->getDisplay(), '->renderException() renders a pretty exception with code exception when code exception is 404 and verbosity is verbose'); + $this->assertMatchesRegularExpression('/\[Exception\]\s*First exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is default and verbosity is verbose'); + $this->assertMatchesRegularExpression('/\[Exception\]\s*Second exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is 0 and verbosity is verbose'); + $this->assertMatchesRegularExpression('/\[Exception \(404\)\]\s*Third exception/', $tester->getDisplay(), '->renderException() renders a pretty exception with code exception when code exception is 404 and verbosity is verbose'); $tester->run(['command' => 'foo3:bar'], ['decorated' => true]); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index 57687d4c60..3908ca5bb2 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -23,7 +23,7 @@ class ListCommandTest extends TestCase $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(['command' => $command->getName()], ['decorated' => false]); - $this->assertRegExp('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands'); + $this->assertMatchesRegularExpression('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands'); } public function testExecuteListsCommandsWithXmlOption() @@ -31,7 +31,7 @@ class ListCommandTest extends TestCase $application = new Application(); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(['command' => $command->getName(), '--format' => 'xml']); - $this->assertRegExp('/