From 567e0ab7e67fd7a8f47a658c47aa71bec63de858 Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Mon, 11 Dec 2017 19:55:31 -0200 Subject: [PATCH 1/8] Refactoring tests. --- .../CompleteConfigurationTest.php | 2 +- .../MainConfigurationTest.php | 4 +-- .../Config/Tests/ConfigCacheTest.php | 4 +-- .../Builder/ArrayNodeDefinitionTest.php | 2 +- .../Tests/Resource/DirectoryResourceTest.php | 2 +- .../Tests/XPath/TranslatorTest.php | 2 +- .../Tests/ContainerBuilderTest.php | 16 ++++++------ .../Tests/ContainerTest.php | 14 +++++----- .../Tests/Loader/XmlFileLoaderTest.php | 26 +++++++++---------- .../Tests/Loader/YamlFileLoaderTest.php | 10 +++---- .../DomCrawler/Tests/CrawlerTest.php | 2 +- .../Component/DomCrawler/Tests/FormTest.php | 6 ++--- .../ContainerAwareEventDispatcherTest.php | 2 +- .../Tests/GenericEventTest.php | 4 +-- .../Filesystem/Tests/FilesystemTest.php | 24 ++++++++--------- .../Component/Form/Tests/CompoundFormTest.php | 4 +-- .../Extension/Core/Type/ChoiceTypeTest.php | 12 ++++----- .../Core/Type/CollectionTypeTest.php | 6 ++--- .../Extension/Core/Type/DateTimeTypeTest.php | 6 ++--- .../Extension/Core/Type/DateTypeTest.php | 8 +++--- .../Extension/Core/Type/TimeTypeTest.php | 2 +- .../Csrf/Type/FormTypeCsrfExtensionTest.php | 10 +++---- .../ViolationMapper/ViolationPathTest.php | 2 +- .../Form/Tests/Util/OrderedHashMapTest.php | 6 ++--- .../HttpFoundation/Tests/HeaderBagTest.php | 2 +- .../HttpFoundation/Tests/ParameterBagTest.php | 2 +- .../Tests/ResponseHeaderBagTest.php | 18 ++++++------- .../HttpFoundation/Tests/ServerBagTest.php | 8 +++--- .../Session/Attribute/AttributeBagTest.php | 2 +- .../Storage/NativeSessionStorageTest.php | 2 +- .../Storage/PhpBridgeSessionStorageTest.php | 8 +++--- .../DataCollector/DumpDataCollectorTest.php | 2 +- .../Tests/HttpCache/HttpCacheTest.php | 18 ++++++------- .../Profiler/AbstractProfilerStorageTest.php | 12 ++++----- .../HttpKernel/Tests/UriSignerTest.php | 2 +- .../Bundle/Reader/IntlBundleReaderTest.php | 12 ++++----- .../Bundle/Reader/JsonBundleReaderTest.php | 2 +- .../Bundle/Reader/PhpBundleReaderTest.php | 2 +- .../Intl/Tests/Data/Util/RingBufferTest.php | 16 ++++++------ .../Locale/Tests/Stub/StubLocaleTest.php | 2 +- .../Tests/LegacyOptionsResolverTest.php | 4 +-- .../Tests/OptionsResolver2Dot6Test.php | 12 ++++----- .../Component/Process/Tests/ProcessTest.php | 2 +- .../Acl/Tests/Dbal/MutableAclProviderTest.php | 26 +++++++++---------- .../Acl/Tests/Permission/MaskBuilderTest.php | 2 +- .../AuthorizationCheckerTest.php | 6 ++--- .../Core/Tests/LegacySecurityContextTest.php | 2 +- .../Templating/Tests/Helper/HelperTest.php | 2 +- .../Tests/Loader/CacheLoaderTest.php | 2 +- .../Templating/Tests/PhpEngineTest.php | 4 +-- .../Tests/Dumper/CsvFileDumperTest.php | 2 +- .../Tests/Dumper/IcuResFileDumperTest.php | 2 +- .../Tests/Dumper/IniFileDumperTest.php | 2 +- .../Tests/Dumper/JsonFileDumperTest.php | 2 +- .../Tests/Dumper/MoFileDumperTest.php | 2 +- .../Tests/Dumper/PhpFileDumperTest.php | 2 +- .../Tests/Dumper/PoFileDumperTest.php | 2 +- .../Tests/Dumper/QtFileDumperTest.php | 2 +- .../Tests/Dumper/XliffFileDumperTest.php | 5 +--- .../Tests/Dumper/YamlFileDumperTest.php | 2 +- .../Tests/ConstraintViolationListTest.php | 6 ++--- .../Tests/Constraints/GroupSequenceTest.php | 10 +++---- 62 files changed, 192 insertions(+), 195 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index 6da50316a4..e731101486 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -143,7 +143,7 @@ abstract class CompleteConfigurationTest extends TestCase list($matcherId, $attributes, $channel) = $rule; $requestMatcher = $container->getDefinition($matcherId); - $this->assertFalse(isset($matcherIds[$matcherId])); + $this->assertArrayNotHasKey($matcherId, $matcherIds); $matcherIds[$matcherId] = true; $i = count($matcherIds); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php index c56a4d8bcb..3aac20301f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php @@ -84,9 +84,9 @@ class MainConfigurationTest extends TestCase $processor = new Processor(); $configuration = new MainConfiguration(array(), array()); $processedConfig = $processor->processConfiguration($configuration, array($config)); - $this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_generator'])); + $this->assertArrayHasKey('csrf_token_generator', $processedConfig['firewalls']['stub']['logout']); $this->assertEquals('a_token_generator', $processedConfig['firewalls']['stub']['logout']['csrf_token_generator']); - $this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_id'])); + $this->assertArrayHasKey('csrf_token_id', $processedConfig['firewalls']['stub']['logout']); $this->assertEquals('a_token_id', $processedConfig['firewalls']['stub']['logout']['csrf_token_id']); } diff --git a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php index e6bcd19a8a..74fd0993a9 100644 --- a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php +++ b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php @@ -112,7 +112,7 @@ class ConfigCacheTest extends TestCase $cache->write('FOOBAR'); $this->assertFileExists($this->cacheFile, 'Cache file is created'); - $this->assertSame('FOOBAR', file_get_contents($this->cacheFile)); + $this->assertStringEqualsFile($this->cacheFile, 'FOOBAR'); $this->assertFileNotExists($this->metaFile, 'Meta file is not created'); } @@ -128,7 +128,7 @@ class ConfigCacheTest extends TestCase $this->assertFileExists($this->cacheFile, 'Cache file is created'); $this->assertFileExists($this->metaFile, 'Meta file is created'); - $this->assertSame(serialize($metadata), file_get_contents($this->metaFile)); + $this->assertStringEqualsFile($this->metaFile, serialize($metadata)); } private function makeCacheFresh() diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php index 63efd719b5..16a38c30b0 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -32,7 +32,7 @@ class ArrayNodeDefinitionTest extends TestCase ->append($child); $this->assertCount(3, $this->getField($parent, 'children')); - $this->assertTrue(in_array($child, $this->getField($parent, 'children'))); + $this->assertContains($child, $this->getField($parent, 'children')); } /** diff --git a/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php index 60bd616a41..91e7206326 100644 --- a/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php @@ -164,6 +164,6 @@ class DirectoryResourceTest extends TestCase $resourceA = new DirectoryResource($this->directory, '/.xml$/'); $resourceB = new DirectoryResource($this->directory, '/.yaml$/'); - $this->assertEquals(2, count(array_unique(array($resourceA, $resourceB)))); + $this->assertCount(2, array_unique(array($resourceA, $resourceB))); } } diff --git a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php index 79e2da14bb..218a3b43c1 100644 --- a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php +++ b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php @@ -37,7 +37,7 @@ class TranslatorTest extends TestCase $translator = new Translator(); $document = new \SimpleXMLElement(file_get_contents(__DIR__.'/Fixtures/lang.xml')); $elements = $document->xpath($translator->cssToXPath($css)); - $this->assertEquals(count($elementsId), count($elements)); + $this->assertCount(count($elementsId), $elements); foreach ($elements as $element) { $this->assertTrue(in_array($element->attributes()->id, $elementsId)); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 32e1b99adb..89ce96cc7c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -49,7 +49,7 @@ class ContainerBuilderTest extends TestCase $builder->setDefinition('foobar', $foo = new Definition('FooBarClass')); $this->assertEquals($foo, $builder->getDefinition('foobar'), '->getDefinition() returns a service definition if defined'); - $this->assertTrue($builder->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fluid interface by returning the service reference'); + $this->assertSame($builder->setDefinition('foobar', $foo = new Definition('FooBarClass')), $foo, '->setDefinition() implements a fluid interface by returning the service reference'); $builder->addDefinitions($defs = array('foobar' => new Definition('FooBarClass'))); $this->assertEquals(array_merge($definitions, $defs), $builder->getDefinitions(), '->addDefinitions() adds the service definitions'); @@ -163,7 +163,7 @@ class ContainerBuilderTest extends TestCase $this->assertFalse($builder->hasAlias('foobar'), '->hasAlias() returns false if the alias does not exist'); $this->assertEquals('foo', (string) $builder->getAlias('bar'), '->getAlias() returns the aliased service'); $this->assertTrue($builder->has('bar'), '->setAlias() defines a new service'); - $this->assertTrue($builder->get('bar') === $builder->get('foo'), '->setAlias() creates a service that is an alias to another one'); + $this->assertSame($builder->get('bar'), $builder->get('foo'), '->setAlias() creates a service that is an alias to another one'); try { $builder->setAlias('foobar', 'foobar'); @@ -208,8 +208,8 @@ class ContainerBuilderTest extends TestCase $builder->setAliases(array('bar' => 'foo', 'foobar' => 'foo')); $aliases = $builder->getAliases(); - $this->assertTrue(isset($aliases['bar'])); - $this->assertTrue(isset($aliases['foobar'])); + $this->assertArrayHasKey('bar', $aliases); + $this->assertArrayHasKey('foobar', $aliases); } public function testAddAliases() @@ -219,8 +219,8 @@ class ContainerBuilderTest extends TestCase $builder->addAliases(array('foobar' => 'foo')); $aliases = $builder->getAliases(); - $this->assertTrue(isset($aliases['bar'])); - $this->assertTrue(isset($aliases['foobar'])); + $this->assertArrayHasKey('bar', $aliases); + $this->assertArrayHasKey('foobar', $aliases); } public function testSetReplacesAlias() @@ -480,7 +480,7 @@ class ContainerBuilderTest extends TestCase $this->assertEquals(array('foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones'); $aliases = $container->getAliases(); - $this->assertTrue(isset($aliases['alias_for_foo'])); + $this->assertArrayHasKey('alias_for_foo', $aliases); $this->assertEquals('foo', (string) $aliases['alias_for_foo']); $container = new ContainerBuilder(); @@ -619,7 +619,7 @@ class ContainerBuilderTest extends TestCase $container->setResourceTracking(false); $container->registerExtension($extension = new \ProjectExtension()); - $this->assertTrue($container->getExtension('project') === $extension, '->registerExtension() registers an extension'); + $this->assertSame($container->getExtension('project'), $extension, '->registerExtension() registers an extension'); $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException'); $container->getExtension('no_registered'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index 5ec0deed3d..129b701d80 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -172,7 +172,7 @@ class ContainerTest extends TestCase $c->set('foo', $foo = new \stdClass(), 'foo'); $scoped = $this->getField($c, 'scopedServices'); - $this->assertTrue(isset($scoped['foo']['foo']), '->set() sets a scoped service'); + $this->assertArrayHasKey('foo', $scoped['foo'], '->set() sets a scoped service'); $this->assertSame($foo, $scoped['foo']['foo'], '->set() sets a scoped service'); } @@ -340,14 +340,14 @@ class ContainerTest extends TestCase $container->set('a', $a, 'bar'); $scoped = $this->getField($container, 'scopedServices'); - $this->assertTrue(isset($scoped['bar']['a'])); + $this->assertArrayHasKey('a', $scoped['bar']); $this->assertSame($a, $scoped['bar']['a']); $this->assertTrue($container->has('a')); $container->leaveScope('foo'); $scoped = $this->getField($container, 'scopedServices'); - $this->assertFalse(isset($scoped['bar'])); + $this->assertArrayNotHasKey('bar', $scoped); $this->assertFalse($container->isScopeActive('foo')); $this->assertFalse($container->has('a')); } @@ -370,14 +370,14 @@ class ContainerTest extends TestCase $container->set('a', $a, 'foo'); $scoped = $this->getField($container, 'scopedServices'); - $this->assertTrue(isset($scoped['foo']['a'])); + $this->assertArrayHasKey('a', $scoped['foo']); $this->assertSame($a, $scoped['foo']['a']); $this->assertTrue($container->has('a')); $container->enterScope('foo'); $scoped = $this->getField($container, 'scopedServices'); - $this->assertFalse(isset($scoped['a'])); + $this->assertArrayNotHasKey('a', $scoped); $this->assertTrue($container->isScopeActive('foo')); $this->assertFalse($container->isScopeActive('bar')); $this->assertFalse($container->has('a')); @@ -409,14 +409,14 @@ class ContainerTest extends TestCase $container->set('a', $a, 'bar'); $scoped = $this->getField($container, 'scopedServices'); - $this->assertTrue(isset($scoped['bar']['a'])); + $this->assertArrayHasKey('a', $scoped['bar']); $this->assertSame($a, $scoped['bar']['a']); $this->assertTrue($container->has('a')); $container->enterScope('bar'); $scoped = $this->getField($container, 'scopedServices'); - $this->assertFalse(isset($scoped['a'])); + $this->assertArrayNotHasKey('a', $scoped); $this->assertTrue($container->isScopeActive('foo')); $this->assertTrue($container->isScopeActive('bar')); $this->assertFalse($container->has('a')); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index 82cef6f127..ca2ad7d0ea 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -94,7 +94,7 @@ class XmlFileLoaderTest extends TestCase libxml_disable_entity_loader($disableEntities); - $this->assertTrue(count($containerBuilder->getParameterBag()->all()) > 0, 'Parameters can be read from the config file.'); + $this->assertGreaterThan(0, $containerBuilder->getParameterBag()->all(), 'Parameters can be read from the config file.'); } public function testLoadParameters() @@ -182,7 +182,7 @@ class XmlFileLoaderTest extends TestCase $args = $services['foo']->getArguments(); $this->assertCount(1, $args, '->load() references anonymous services as "normal" ones'); $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services'); - $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); + $this->assertArrayHasKey((string) $args[0], $services, '->load() makes a reference to the created ones'); $inner = $services[(string) $args[0]]; $this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); $this->assertFalse($inner->isPublic()); @@ -191,7 +191,7 @@ class XmlFileLoaderTest extends TestCase $args = $inner->getArguments(); $this->assertCount(1, $args, '->load() references anonymous services as "normal" ones'); $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services'); - $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); + $this->assertArrayHasKey((string) $args[0], $services, '->load() makes a reference to the created ones'); $inner = $services[(string) $args[0]]; $this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); $this->assertFalse($inner->isPublic()); @@ -200,7 +200,7 @@ class XmlFileLoaderTest extends TestCase $properties = $services['foo']->getProperties(); $property = $properties['p']; $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $property, '->load() converts anonymous services to references to "normal" services'); - $this->assertTrue(isset($services[(string) $property]), '->load() makes a reference to the created ones'); + $this->assertArrayHasKey((string) $property, $services, '->load() makes a reference to the created ones'); $inner = $services[(string) $property]; $this->assertEquals('BuzClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); $this->assertFalse($inner->isPublic()); @@ -249,7 +249,7 @@ class XmlFileLoaderTest extends TestCase $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); $loader->load('services6.xml'); $services = $container->getDefinitions(); - $this->assertTrue(isset($services['foo']), '->load() parses elements'); + $this->assertArrayHasKey('foo', $services, '->load() parses elements'); $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts element to Definition instances'); $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertEquals('container', $services['scope.container']->getScope()); @@ -267,10 +267,10 @@ class XmlFileLoaderTest extends TestCase $this->assertEquals(array('BazClass', 'getInstance'), $services['new_factory3']->getFactory(), '->load() parses the factory tag'); $aliases = $container->getAliases(); - $this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses elements'); + $this->assertArrayHasKey('alias_for_foo', $aliases, '->load() parses elements'); $this->assertEquals('foo', (string) $aliases['alias_for_foo'], '->load() parses aliases'); $this->assertTrue($aliases['alias_for_foo']->isPublic()); - $this->assertTrue(isset($aliases['another_alias_for_foo'])); + $this->assertArrayHasKey('another_alias_for_foo', $aliases); $this->assertEquals('foo', (string) $aliases['another_alias_for_foo']); $this->assertFalse($aliases['another_alias_for_foo']->isPublic()); @@ -366,8 +366,8 @@ class XmlFileLoaderTest extends TestCase $services = $container->getDefinitions(); $parameters = $container->getParameterBag()->all(); - $this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements'); - $this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); + $this->assertArrayHasKey('project.service.bar', $services, '->load() parses extension elements'); + $this->assertArrayHasKey('project.parameter.bar', $parameters, '->load() parses extension elements'); $this->assertEquals('BAR', $services['project.service.foo']->getClass(), '->load() parses extension elements'); $this->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements'); @@ -382,8 +382,8 @@ class XmlFileLoaderTest extends TestCase $services = $container->getDefinitions(); $parameters = $container->getParameterBag()->all(); - $this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements'); - $this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); + $this->assertArrayHasKey('project.service.bar', $services, '->load() parses extension elements'); + $this->assertArrayHasKey('project.parameter.bar', $parameters, '->load() parses extension elements'); $this->assertEquals('BAR', $services['project.service.foo']->getClass(), '->load() parses extension elements'); $this->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements'); @@ -504,8 +504,8 @@ class XmlFileLoaderTest extends TestCase $loader->load('namespaces.xml'); $services = $container->getDefinitions(); - $this->assertTrue(isset($services['foo']), '->load() parses elements'); - $this->assertEquals(1, count($services['foo']->getTag('foo.tag')), '->load parses elements'); + $this->assertArrayHasKey('foo', $services, '->load() parses elements'); + $this->assertCount(1, $services['foo']->getTag('foo.tag'), '->load parses elements'); $this->assertEquals(array(array('setBar', array('foo'))), $services['foo']->getMethodCalls(), '->load() parses the tag'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 644c8711b7..85c74b572d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -142,7 +142,7 @@ class YamlFileLoaderTest extends TestCase $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('services6.yml'); $services = $container->getDefinitions(); - $this->assertTrue(isset($services['foo']), '->load() parses service elements'); + $this->assertArrayHasKey('foo', $services, '->load() parses service elements'); $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts service element to Definition instances'); $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertEquals('container', $services['scope.container']->getScope()); @@ -160,10 +160,10 @@ class YamlFileLoaderTest extends TestCase $this->assertEquals(array('BazClass', 'getInstance'), $services['new_factory3']->getFactory(), '->load() parses the factory tag'); $aliases = $container->getAliases(); - $this->assertTrue(isset($aliases['alias_for_foo']), '->load() parses aliases'); + $this->assertArrayHasKey('alias_for_foo', $aliases, '->load() parses aliases'); $this->assertEquals('foo', (string) $aliases['alias_for_foo'], '->load() parses aliases'); $this->assertTrue($aliases['alias_for_foo']->isPublic()); - $this->assertTrue(isset($aliases['another_alias_for_foo'])); + $this->assertArrayHasKey('another_alias_for_foo', $aliases); $this->assertEquals('foo', (string) $aliases['another_alias_for_foo']); $this->assertFalse($aliases['another_alias_for_foo']->isPublic()); @@ -192,8 +192,8 @@ class YamlFileLoaderTest extends TestCase $services = $container->getDefinitions(); $parameters = $container->getParameterBag()->all(); - $this->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements'); - $this->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements'); + $this->assertArrayHasKey('project.service.bar', $services, '->load() parses extension elements'); + $this->assertArrayHasKey('project.parameter.bar', $parameters, '->load() parses extension elements'); $this->assertEquals('BAR', $services['project.service.foo']->getClass(), '->load() parses extension elements'); $this->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements'); diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 335406ab24..3ba9247618 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -172,7 +172,7 @@ EOF EOF , 'UTF-8'); - $this->assertTrue(count(libxml_get_errors()) > 1); + $this->assertGreaterThan(1, libxml_get_errors()); libxml_clear_errors(); libxml_use_internal_errors($internalErrors); diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 437a5ddaf0..258a997a28 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -370,15 +370,15 @@ class FormTest extends TestCase { $form = $this->createForm('
'); unset($form['foo']); - $this->assertFalse(isset($form['foo']), '->offsetUnset() removes a field'); + $this->assertArrayNotHasKey('foo', $form, '->offsetUnset() removes a field'); } public function testOffsetExists() { $form = $this->createForm('
'); - $this->assertTrue(isset($form['foo']), '->offsetExists() return true if the field exists'); - $this->assertFalse(isset($form['bar']), '->offsetExists() return false if the field does not exist'); + $this->assertArrayHasKey('foo', $form, '->offsetExists() return true if the field exists'); + $this->assertArrayNotHasKey('bar', $form, '->offsetExists() return false if the field does not exist'); } public function testGetValues() diff --git a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php index 18aac429d4..b71f72da51 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php @@ -206,7 +206,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest $listeners = $dispatcher->getListeners(); - $this->assertTrue(isset($listeners['onEvent'])); + $this->assertArrayHasKey('onEvent', $listeners); $this->assertCount(1, $dispatcher->getListeners('onEvent')); } diff --git a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php index c84d3ac24c..9cf68c987f 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php @@ -114,8 +114,8 @@ class GenericEventTest extends TestCase public function testOffsetIsset() { - $this->assertTrue(isset($this->event['name'])); - $this->assertFalse(isset($this->event['nameNotExist'])); + $this->assertArrayHasKey('name', $this->event); + $this->assertArrayNotHasKey('nameNotExist', $this->event); } public function testHasArgument() diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 3c50131db2..9172dd7877 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -26,7 +26,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->copy($sourceFilePath, $targetFilePath); $this->assertFileExists($targetFilePath); - $this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath)); + $this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE'); } /** @@ -73,7 +73,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->copy($sourceFilePath, $targetFilePath); $this->assertFileExists($targetFilePath); - $this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath)); + $this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE'); } public function testCopyDoesNotOverrideExistingFileByDefault() @@ -92,7 +92,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->copy($sourceFilePath, $targetFilePath); $this->assertFileExists($targetFilePath); - $this->assertEquals('TARGET FILE', file_get_contents($targetFilePath)); + $this->assertStringEqualsFile($targetFilePath, 'TARGET FILE'); } public function testCopyOverridesExistingFileIfForced() @@ -111,7 +111,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->copy($sourceFilePath, $targetFilePath, true); $this->assertFileExists($targetFilePath); - $this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath)); + $this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE'); } /** @@ -153,7 +153,7 @@ class FilesystemTest extends FilesystemTestCase $this->assertTrue(is_dir($targetFileDirectory)); $this->assertFileExists($targetFilePath); - $this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath)); + $this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE'); } /** @@ -772,9 +772,9 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->remove($link); - $this->assertTrue(!is_link($link)); - $this->assertTrue(!is_file($link)); - $this->assertTrue(!is_dir($link)); + $this->assertFalse(is_link($link)); + $this->assertFalse(is_file($link)); + $this->assertFalse(is_dir($link)); } public function testSymlinkIsOverwrittenIfPointsToDifferentTarget() @@ -1095,7 +1095,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->dumpFile($filename, 'bar'); $this->assertFileExists($filename); - $this->assertSame('bar', file_get_contents($filename)); + $this->assertStringEqualsFile($filename, 'bar'); } /** @@ -1108,7 +1108,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->dumpFile($filename, 'bar', 0753); $this->assertFileExists($filename); - $this->assertSame('bar', file_get_contents($filename)); + $this->assertStringEqualsFile($filename, 'bar'); // skip mode check on Windows if ('\\' !== DIRECTORY_SEPARATOR) { @@ -1123,7 +1123,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->dumpFile($filename, 'bar', null); $this->assertFileExists($filename); - $this->assertSame('bar', file_get_contents($filename)); + $this->assertStringEqualsFile($filename, 'bar'); // skip mode check on Windows if ('\\' !== DIRECTORY_SEPARATOR) { @@ -1139,7 +1139,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->dumpFile($filename, 'bar'); $this->assertFileExists($filename); - $this->assertSame('bar', file_get_contents($filename)); + $this->assertStringEqualsFile($filename, 'bar'); } public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile() diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index b9b93e54c1..5f638b68fe 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -309,12 +309,12 @@ class CompoundFormTest extends AbstractFormTest $this->form[] = $child; - $this->assertTrue(isset($this->form['foo'])); + $this->assertArrayHasKey('foo', $this->form); $this->assertSame($child, $this->form['foo']); unset($this->form['foo']); - $this->assertFalse(isset($this->form['foo'])); + $this->assertArrayNotHasKey('foo', $this->form); } public function testCountable() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 3e36c7dd29..9b0983eac5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -243,7 +243,7 @@ class ChoiceTypeTest extends BaseTypeTest 'choices_as_values' => true, )); - $this->assertTrue(isset($form['placeholder'])); + $this->assertArrayHasKey('placeholder', $form); $this->assertCount(count($this->choices) + 1, $form, 'Each choice should become a new field'); } @@ -257,7 +257,7 @@ class ChoiceTypeTest extends BaseTypeTest 'choices_as_values' => true, )); - $this->assertFalse(isset($form['placeholder'])); + $this->assertArrayNotHasKey('placeholder', $form); $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); } @@ -271,7 +271,7 @@ class ChoiceTypeTest extends BaseTypeTest 'choices_as_values' => true, )); - $this->assertFalse(isset($form['placeholder'])); + $this->assertArrayNotHasKey('placeholder', $form); $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); } @@ -288,7 +288,7 @@ class ChoiceTypeTest extends BaseTypeTest 'choices_as_values' => true, )); - $this->assertFalse(isset($form['placeholder'])); + $this->assertArrayNotHasKey('placeholder', $form); $this->assertCount(2, $form, 'Each choice should become a new field'); } @@ -348,7 +348,7 @@ class ChoiceTypeTest extends BaseTypeTest 'choices_as_values' => true, )); - $this->assertTrue(isset($form['placeholder']), 'Placeholder should be set'); + $this->assertArrayHasKey('placeholder', $form, 'Placeholder should be set'); $this->assertCount(3, $form, 'Each choice should become a new field, placeholder included'); $view = $form->createView(); @@ -373,7 +373,7 @@ class ChoiceTypeTest extends BaseTypeTest 'choices_as_values' => true, )); - $this->assertTrue(isset($form['placeholder']), 'Placeholder should be set'); + $this->assertArrayHasKey('placeholder', $form, 'Placeholder should be set'); $this->assertCount(3, $form, 'Each choice should become a new field, placeholder included'); $view = $form->createView(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php index 34851d316d..b52b1650ce 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -49,7 +49,7 @@ class CollectionTypeTest extends BaseTypeTest $form->setData(array('foo@baz.com')); $this->assertInstanceOf('Symfony\Component\Form\Form', $form[0]); - $this->assertFalse(isset($form[1])); + $this->assertArrayNotHasKey(1, $form); $this->assertCount(1, $form); $this->assertEquals('foo@baz.com', $form[0]->getData()); $formAttrs0 = $form[0]->getConfig()->getOption('attr'); @@ -228,7 +228,7 @@ class CollectionTypeTest extends BaseTypeTest )); $data = $form->getData(); - $this->assertFalse(isset($data['__name__'])); + $this->assertArrayNotHasKey('__name__', $data); } public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet() @@ -241,7 +241,7 @@ class CollectionTypeTest extends BaseTypeTest $form->setData(array('foobar.png')); $data = $form->getData(); - $this->assertFalse(isset($data['__name__'])); + $this->assertArrayNotHasKey('__name__', $data); } public function testPrototypeNameOption() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php index 9a80bdd87b..48c1b764bd 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -444,7 +444,7 @@ class DateTimeTypeTest extends BaseTypeTest )) ->createView(); - $this->assertFalse(isset($view->vars['type'])); + $this->assertArrayNotHasKey('type', $view->vars); } public function testDontPassHtml5TypeIfNotHtml5Format() @@ -455,7 +455,7 @@ class DateTimeTypeTest extends BaseTypeTest )) ->createView(); - $this->assertFalse(isset($view->vars['type'])); + $this->assertArrayNotHasKey('type', $view->vars); } public function testDontPassHtml5TypeIfNotSingleText() @@ -465,7 +465,7 @@ class DateTimeTypeTest extends BaseTypeTest )) ->createView(); - $this->assertFalse(isset($view->vars['type'])); + $this->assertArrayNotHasKey('type', $view->vars); } public function testDateTypeChoiceErrorsBubbleUp() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php index 6c3806d23c..21962d12ad 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -678,7 +678,7 @@ class DateTypeTest extends BaseTypeTest )) ->createView(); - $this->assertFalse(isset($view->vars['date_pattern'])); + $this->assertArrayNotHasKey('date_pattern', $view->vars); } public function testDatePatternFormatWithQuotedStrings() @@ -844,7 +844,7 @@ class DateTypeTest extends BaseTypeTest )) ->createView(); - $this->assertFalse(isset($view->vars['type'])); + $this->assertArrayNotHasKey('type', $view->vars); } public function testDontPassHtml5TypeIfNotHtml5Format() @@ -855,7 +855,7 @@ class DateTypeTest extends BaseTypeTest )) ->createView(); - $this->assertFalse(isset($view->vars['type'])); + $this->assertArrayNotHasKey('type', $view->vars); } public function testDontPassHtml5TypeIfNotSingleText() @@ -865,7 +865,7 @@ class DateTypeTest extends BaseTypeTest )) ->createView(); - $this->assertFalse(isset($view->vars['type'])); + $this->assertArrayNotHasKey('type', $view->vars); } public function provideCompoundWidgets() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php index 48fd5964db..8f7d13961f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -536,7 +536,7 @@ class TimeTypeTest extends BaseTypeTest )); $view = $form->createView(); - $this->assertFalse(isset($view->vars['type'])); + $this->assertArrayNotHasKey('type', $view->vars); } public function testPassDefaultPlaceholderToViewIfNotRequired() diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php index 4a88d18d71..7ac00c350d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -77,7 +77,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase )) ->createView(); - $this->assertTrue(isset($view['csrf'])); + $this->assertArrayHasKey('csrf', $view); } public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot() @@ -94,7 +94,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase ->get('form') ->createView(); - $this->assertFalse(isset($view['csrf'])); + $this->assertArrayNotHasKey('csrf', $view); } public function testNoCsrfProtectionByDefaultIfRootButNotCompound() @@ -106,7 +106,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase )) ->createView(); - $this->assertFalse(isset($view['csrf'])); + $this->assertArrayNotHasKey('csrf', $view); } public function testCsrfProtectionCanBeDisabled() @@ -119,7 +119,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase )) ->createView(); - $this->assertFalse(isset($view['csrf'])); + $this->assertArrayNotHasKey('csrf', $view); } public function testGenerateCsrfToken() @@ -362,7 +362,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase ->createView() ->vars['prototype']; - $this->assertFalse(isset($prototypeView['csrf'])); + $this->assertArrayNotHasKey('csrf', $prototypeView); $this->assertCount(1, $prototypeView); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php index 31377dec3e..88d5169cd7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php @@ -96,7 +96,7 @@ class ViolationPathTest extends TestCase $path = new ViolationPath($string); $this->assertSame($slicedPath, $path->__toString()); - $this->assertSame(count($entries), count($path->getElements())); + $this->assertCount(count($entries), $path->getElements()); $this->assertSame(count($entries), $path->getLength()); foreach ($entries as $index => $entry) { diff --git a/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php b/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php index fe922e9239..8ce3f8fc82 100644 --- a/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php +++ b/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php @@ -91,14 +91,14 @@ class OrderedHashMapTest extends TestCase $map = new OrderedHashMap(); $map['first'] = 1; - $this->assertTrue(isset($map['first'])); + $this->assertArrayHasKey('first', $map); } public function testIssetReturnsFalseForNonExisting() { $map = new OrderedHashMap(); - $this->assertFalse(isset($map['first'])); + $this->assertArrayNotHasKey('first', $map); } public function testIssetReturnsFalseForNull() @@ -106,7 +106,7 @@ class OrderedHashMapTest extends TestCase $map = new OrderedHashMap(); $map['first'] = null; - $this->assertFalse(isset($map['first'])); + $this->assertArrayNotHasKey('first', $map); } public function testUnset() diff --git a/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php index e5b1b38fdd..683ef47b27 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php @@ -191,6 +191,6 @@ class HeaderBagTest extends TestCase $headers = array('foo' => 'bar', 'HELLO' => 'WORLD'); $headerBag = new HeaderBag($headers); - $this->assertEquals(count($headers), count($headerBag)); + $this->assertCount(count($headers), $headerBag); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php index 5ee2954db9..83f49f695f 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php @@ -210,7 +210,7 @@ class ParameterBagTest extends TestCase $parameters = array('foo' => 'bar', 'hello' => 'world'); $bag = new ParameterBag($parameters); - $this->assertEquals(count($parameters), count($bag)); + $this->assertCount(count($parameters), $bag); } public function testGetBoolean() diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index c55a7f6a51..48be572962 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -183,10 +183,10 @@ class ResponseHeaderBagTest extends TestCase $this->assertSetCookieHeader('foo=bar; path=/; httponly', $bag); $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertTrue(isset($cookies['foo.bar']['/path/foo']['foo'])); - $this->assertTrue(isset($cookies['foo.bar']['/path/bar']['foo'])); - $this->assertTrue(isset($cookies['bar.foo']['/path/bar']['foo'])); - $this->assertTrue(isset($cookies['']['/']['foo'])); + $this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/foo']); + $this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/bar']); + $this->assertArrayHasKey('foo', $cookies['bar.foo']['/path/bar']); + $this->assertArrayHasKey('foo', $cookies['']['/']); } public function testRemoveCookie() @@ -196,17 +196,17 @@ class ResponseHeaderBagTest extends TestCase $bag->setCookie(new Cookie('bar', 'foo', 0, '/path/bar', 'foo.bar')); $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertTrue(isset($cookies['foo.bar']['/path/foo'])); + $this->assertArrayHasKey('/path/foo', $cookies['foo.bar']); $bag->removeCookie('foo', '/path/foo', 'foo.bar'); $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertFalse(isset($cookies['foo.bar']['/path/foo'])); + $this->assertArrayNotHasKey('/path/foo', $cookies['foo.bar']); $bag->removeCookie('bar', '/path/bar', 'foo.bar'); $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertFalse(isset($cookies['foo.bar'])); + $this->assertArrayNotHasKey('foo.bar', $cookies); } public function testRemoveCookieWithNullRemove() @@ -216,11 +216,11 @@ class ResponseHeaderBagTest extends TestCase $bag->setCookie(new Cookie('bar', 'foo', 0)); $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertTrue(isset($cookies['']['/'])); + $this->assertArrayHasKey('/', $cookies['']); $bag->removeCookie('foo', null); $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertFalse(isset($cookies['']['/']['foo'])); + $this->assertArrayNotHasKey('foo', $cookies['']['/']); $bag->removeCookie('bar', null); $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php index c1d9d12a65..f8becec5a9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php @@ -74,8 +74,8 @@ class ServerBagTest extends TestCase // Username and passwords should not be set as the header is bogus $headers = $bag->getHeaders(); - $this->assertFalse(isset($headers['PHP_AUTH_USER'])); - $this->assertFalse(isset($headers['PHP_AUTH_PW'])); + $this->assertArrayNotHasKey('PHP_AUTH_USER', $headers); + $this->assertArrayNotHasKey('PHP_AUTH_PW', $headers); } public function testHttpBasicAuthWithPhpCgiRedirect() @@ -118,8 +118,8 @@ class ServerBagTest extends TestCase // Username and passwords should not be set as the header is bogus $headers = $bag->getHeaders(); - $this->assertFalse(isset($headers['PHP_AUTH_USER'])); - $this->assertFalse(isset($headers['PHP_AUTH_PW'])); + $this->assertArrayNotHasKey('PHP_AUTH_USER', $headers); + $this->assertArrayNotHasKey('PHP_AUTH_PW', $headers); } public function testHttpDigestAuthWithPhpCgiRedirect() diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php index 655c26a9c2..724a0b9844 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php @@ -181,6 +181,6 @@ class AttributeBagTest extends TestCase public function testCount() { - $this->assertEquals(count($this->array), count($this->bag)); + $this->assertCount(count($this->array), $this->bag); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 7eb7e56478..3501f74784 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -255,7 +255,7 @@ class NativeSessionStorageTest extends TestCase $this->assertFalse($storage->isStarted()); $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertFalse(isset($_SESSION[$key])); + $this->assertArrayNotHasKey($key, $_SESSION); $storage->start(); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index 5cfb328d30..384ad7b038 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -79,9 +79,9 @@ class PhpBridgeSessionStorageTest extends TestCase $this->assertFalse($storage->isStarted()); $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertFalse(isset($_SESSION[$key])); + $this->assertArrayNotHasKey($key, $_SESSION); $storage->start(); - $this->assertTrue(isset($_SESSION[$key])); + $this->assertArrayHasKey($key, $_SESSION); } /** @@ -102,9 +102,9 @@ class PhpBridgeSessionStorageTest extends TestCase $this->assertFalse($storage->isStarted()); $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertFalse(isset($_SESSION[$key])); + $this->assertArrayNotHasKey($key, $_SESSION); $storage->start(); - $this->assertTrue(isset($_SESSION[$key])); + $this->assertArrayHasKey($key, $_SESSION); } public function testClear() diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php index 91f4b2e6f2..23b1d87d1c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php @@ -35,7 +35,7 @@ class DumpDataCollectorTest extends TestCase $this->assertSame(1, $collector->getDumpsCount()); $dump = $collector->getDumps('html'); - $this->assertTrue(isset($dump[0]['data'])); + $this->assertArrayHasKey('data', $dump[0]); $dump[0]['data'] = preg_replace('/^.*?
request('GET', '/');
         $this->assertHttpKernelIsNotCalled();
         $this->assertEquals(200, $this->response->getStatusCode());
-        $this->assertTrue(strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')) < 2);
-        $this->assertTrue($this->response->headers->get('Age') > 0);
+        $this->assertLessThan(2, strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')));
+        $this->assertGreaterThan(0, $this->response->headers->get('Age'));
         $this->assertNotNull($this->response->headers->get('X-Content-Digest'));
         $this->assertTraceContains('fresh');
         $this->assertTraceNotContains('store');
@@ -554,8 +554,8 @@ class HttpCacheTest extends HttpCacheTestCase
         $this->request('GET', '/');
         $this->assertHttpKernelIsNotCalled();
         $this->assertEquals(200, $this->response->getStatusCode());
-        $this->assertTrue(strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')) < 2);
-        $this->assertTrue($this->response->headers->get('Age') > 0);
+        $this->assertLessThan(2, strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')));
+        $this->assertGreaterThan(0, $this->response->headers->get('Age'));
         $this->assertNotNull($this->response->headers->get('X-Content-Digest'));
         $this->assertTraceContains('fresh');
         $this->assertTraceNotContains('store');
@@ -578,8 +578,8 @@ class HttpCacheTest extends HttpCacheTestCase
         $this->request('GET', '/');
         $this->assertHttpKernelIsNotCalled();
         $this->assertEquals(200, $this->response->getStatusCode());
-        $this->assertTrue(strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')) < 2);
-        $this->assertTrue($this->response->headers->get('Age') > 0);
+        $this->assertLessThan(2, strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')));
+        $this->assertGreaterThan(0, $this->response->headers->get('Age'));
         $this->assertNotNull($this->response->headers->get('X-Content-Digest'));
         $this->assertTraceContains('fresh');
         $this->assertTraceNotContains('store');
@@ -753,7 +753,7 @@ class HttpCacheTest extends HttpCacheTestCase
         $this->request('GET', '/');
         $this->assertHttpKernelIsCalled();
         $this->assertEquals(200, $this->response->getStatusCode());
-        $this->assertTrue($this->response->headers->get('Age') <= 1);
+        $this->assertLessThanOrEqual(1, $this->response->headers->get('Age'));
         $this->assertNotNull($this->response->headers->get('X-Content-Digest'));
         $this->assertTraceContains('stale');
         $this->assertTraceNotContains('fresh');
@@ -791,7 +791,7 @@ class HttpCacheTest extends HttpCacheTestCase
         $this->assertEquals(200, $this->response->getStatusCode());
         $this->assertNotNull($this->response->headers->get('Last-Modified'));
         $this->assertNotNull($this->response->headers->get('X-Content-Digest'));
-        $this->assertTrue($this->response->headers->get('Age') <= 1);
+        $this->assertLessThanOrEqual(1, $this->response->headers->get('Age'));
         $this->assertEquals('Hello World', $this->response->getContent());
         $this->assertTraceContains('stale');
         $this->assertTraceContains('valid');
@@ -841,7 +841,7 @@ class HttpCacheTest extends HttpCacheTestCase
         $this->assertEquals(200, $this->response->getStatusCode());
         $this->assertNotNull($this->response->headers->get('ETag'));
         $this->assertNotNull($this->response->headers->get('X-Content-Digest'));
-        $this->assertTrue($this->response->headers->get('Age') <= 1);
+        $this->assertLessThanOrEqual(1, $this->response->headers->get('Age'));
         $this->assertEquals('Hello World', $this->response->getContent());
         $this->assertTraceContains('stale');
         $this->assertTraceContains('valid');
diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php
index f3557eedcb..e9dfccbc51 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php
@@ -64,22 +64,22 @@ abstract class AbstractProfilerStorageTest extends TestCase
         $profile = new Profile('simple_quote');
         $profile->setUrl('http://foo.bar/\'');
         $this->getStorage()->write($profile);
-        $this->assertTrue(false !== $this->getStorage()->read('simple_quote'), '->write() accepts single quotes in URL');
+        $this->assertNotFalse($this->getStorage()->read('simple_quote'), '->write() accepts single quotes in URL');
 
         $profile = new Profile('double_quote');
         $profile->setUrl('http://foo.bar/"');
         $this->getStorage()->write($profile);
-        $this->assertTrue(false !== $this->getStorage()->read('double_quote'), '->write() accepts double quotes in URL');
+        $this->assertNotFalse($this->getStorage()->read('double_quote'), '->write() accepts double quotes in URL');
 
         $profile = new Profile('backslash');
         $profile->setUrl('http://foo.bar/\\');
         $this->getStorage()->write($profile);
-        $this->assertTrue(false !== $this->getStorage()->read('backslash'), '->write() accepts backslash in URL');
+        $this->assertNotFalse($this->getStorage()->read('backslash'), '->write() accepts backslash in URL');
 
         $profile = new Profile('comma');
         $profile->setUrl('http://foo.bar/,');
         $this->getStorage()->write($profile);
-        $this->assertTrue(false !== $this->getStorage()->read('comma'), '->write() accepts comma in URL');
+        $this->assertNotFalse($this->getStorage()->read('comma'), '->write() accepts comma in URL');
     }
 
     public function testStoreDuplicateToken()
@@ -214,7 +214,7 @@ abstract class AbstractProfilerStorageTest extends TestCase
         $profile->setMethod('GET');
         $this->getStorage()->write($profile);
 
-        $this->assertTrue(false !== $this->getStorage()->read('token1'));
+        $this->assertNotFalse($this->getStorage()->read('token1'));
         $this->assertCount(1, $this->getStorage()->find('127.0.0.1', '', 10, 'GET'));
 
         $profile = new Profile('token2');
@@ -223,7 +223,7 @@ abstract class AbstractProfilerStorageTest extends TestCase
         $profile->setMethod('GET');
         $this->getStorage()->write($profile);
 
-        $this->assertTrue(false !== $this->getStorage()->read('token2'));
+        $this->assertNotFalse($this->getStorage()->read('token2'));
         $this->assertCount(2, $this->getStorage()->find('127.0.0.1', '', 10, 'GET'));
 
         $this->getStorage()->purge();
diff --git a/src/Symfony/Component/HttpKernel/Tests/UriSignerTest.php b/src/Symfony/Component/HttpKernel/Tests/UriSignerTest.php
index 06de8902dc..1304b219e7 100644
--- a/src/Symfony/Component/HttpKernel/Tests/UriSignerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/UriSignerTest.php
@@ -36,7 +36,7 @@ class UriSignerTest extends TestCase
         $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar')));
         $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&0=integer')));
 
-        $this->assertTrue($signer->sign('http://example.com/foo?foo=bar&bar=foo') === $signer->sign('http://example.com/foo?bar=foo&foo=bar'));
+        $this->assertSame($signer->sign('http://example.com/foo?foo=bar&bar=foo'), $signer->sign('http://example.com/foo?bar=foo&foo=bar'));
     }
 
     public function testCheckWithDifferentArgSeparator()
diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php
index 76543d3f0a..34328770ef 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php
@@ -36,7 +36,7 @@ class IntlBundleReaderTest extends TestCase
 
         $this->assertInstanceOf('\ArrayAccess', $data);
         $this->assertSame('Bar', $data['Foo']);
-        $this->assertFalse(isset($data['ExistsNot']));
+        $this->assertArrayNotHasKey('ExistsNot', $data);
     }
 
     public function testReadFollowsAlias()
@@ -46,7 +46,7 @@ class IntlBundleReaderTest extends TestCase
 
         $this->assertInstanceOf('\ArrayAccess', $data);
         $this->assertSame('Bar', $data['Foo']);
-        $this->assertFalse(isset($data['ExistsNot']));
+        $this->assertArrayNotHasKey('ExistsNot', $data);
     }
 
     public function testReadDoesNotFollowFallback()
@@ -64,9 +64,9 @@ class IntlBundleReaderTest extends TestCase
 
         $this->assertInstanceOf('\ArrayAccess', $data);
         $this->assertSame('Bam', $data['Baz']);
-        $this->assertFalse(isset($data['Foo']));
+        $this->assertArrayNotHasKey('Foo', $data);
         $this->assertNull($data['Foo']);
-        $this->assertFalse(isset($data['ExistsNot']));
+        $this->assertArrayNotHasKey('ExistsNot', $data);
     }
 
     public function testReadDoesNotFollowFallbackAlias()
@@ -84,9 +84,9 @@ class IntlBundleReaderTest extends TestCase
 
         $this->assertInstanceOf('\ArrayAccess', $data);
         $this->assertSame('Bam', $data['Baz'], 'data from the aliased locale can be accessed');
-        $this->assertFalse(isset($data['Foo']));
+        $this->assertArrayNotHasKey('Foo', $data);
         $this->assertNull($data['Foo']);
-        $this->assertFalse(isset($data['ExistsNot']));
+        $this->assertArrayNotHasKey('ExistsNot', $data);
     }
 
     /**
diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php
index 2b6e6c4169..dd0cf9cd87 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php
@@ -35,7 +35,7 @@ class JsonBundleReaderTest extends TestCase
 
         $this->assertInternalType('array', $data);
         $this->assertSame('Bar', $data['Foo']);
-        $this->assertFalse(isset($data['ExistsNot']));
+        $this->assertArrayNotHasKey('ExistsNot', $data);
     }
 
     /**
diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php
index 954e2f0423..f6adae9b7d 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php
@@ -35,7 +35,7 @@ class PhpBundleReaderTest extends TestCase
 
         $this->assertInternalType('array', $data);
         $this->assertSame('Bar', $data['Foo']);
-        $this->assertFalse(isset($data['ExistsNot']));
+        $this->assertArrayNotHasKey('ExistsNot', $data);
     }
 
     /**
diff --git a/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php b/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php
index bbaecfcbd6..f13bf36c96 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php
@@ -34,8 +34,8 @@ class RingBufferTest extends TestCase
         $this->buffer[0] = 'foo';
         $this->buffer['bar'] = 'baz';
 
-        $this->assertTrue(isset($this->buffer[0]));
-        $this->assertTrue(isset($this->buffer['bar']));
+        $this->assertArrayHasKey(0, $this->buffer);
+        $this->assertArrayHasKey('bar', $this->buffer);
         $this->assertSame('foo', $this->buffer[0]);
         $this->assertSame('baz', $this->buffer['bar']);
     }
@@ -46,8 +46,8 @@ class RingBufferTest extends TestCase
         $this->buffer['bar'] = 'baz';
         $this->buffer[2] = 'bam';
 
-        $this->assertTrue(isset($this->buffer['bar']));
-        $this->assertTrue(isset($this->buffer[2]));
+        $this->assertArrayHasKey('bar', $this->buffer);
+        $this->assertArrayHasKey(2, $this->buffer);
         $this->assertSame('baz', $this->buffer['bar']);
         $this->assertSame('bam', $this->buffer[2]);
     }
@@ -62,14 +62,14 @@ class RingBufferTest extends TestCase
 
     public function testQueryNonExisting()
     {
-        $this->assertFalse(isset($this->buffer['foo']));
+        $this->assertArrayNotHasKey('foo', $this->buffer);
     }
 
     public function testUnsetNonExistingSucceeds()
     {
         unset($this->buffer['foo']);
 
-        $this->assertFalse(isset($this->buffer['foo']));
+        $this->assertArrayNotHasKey('foo', $this->buffer);
     }
 
     /**
@@ -86,7 +86,7 @@ class RingBufferTest extends TestCase
 
     public function testQueryOverwritten()
     {
-        $this->assertFalse(isset($this->buffer[0]));
+        $this->assertArrayNotHasKey(0, $this->buffer);
     }
 
     public function testUnsetOverwrittenSucceeds()
@@ -97,6 +97,6 @@ class RingBufferTest extends TestCase
 
         unset($this->buffer[0]);
 
-        $this->assertFalse(isset($this->buffer[0]));
+        $this->assertArrayNotHasKey(0, $this->buffer);
     }
 }
diff --git a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php
index 4d82b42881..674472bd8e 100644
--- a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php
+++ b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php
@@ -43,6 +43,6 @@ class StubLocaleTest extends TestCase
     public function testGetCurrencies()
     {
         $currencies = StubLocale::getCurrencies();
-        $this->assertTrue(in_array('BRL', $currencies));
+        $this->assertContains('BRL', $currencies);
     }
 }
diff --git a/src/Symfony/Component/OptionsResolver/Tests/LegacyOptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/LegacyOptionsResolverTest.php
index 44e07b7726..1b42814ea7 100644
--- a/src/Symfony/Component/OptionsResolver/Tests/LegacyOptionsResolverTest.php
+++ b/src/Symfony/Component/OptionsResolver/Tests/LegacyOptionsResolverTest.php
@@ -124,7 +124,7 @@ class LegacyOptionsResolverTest extends TestCase
         $this->resolver->setDefaults(array(
             'two' => function (Options $options) use ($test) {
                 /* @var TestCase $test */
-                $test->assertFalse(isset($options['one']));
+                $test->assertArrayNotHasKey('one', $options);
 
                 return '2';
             },
@@ -148,7 +148,7 @@ class LegacyOptionsResolverTest extends TestCase
         $this->resolver->setDefaults(array(
             'two' => function (Options $options) use ($test) {
                 /* @var TestCase $test */
-                $test->assertTrue(isset($options['one']));
+                $test->assertArrayHasKey('one', $options);
 
                 return $options['one'].'2';
             },
diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php
index c548f16ba6..ffa2872243 100644
--- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php
+++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php
@@ -1419,12 +1419,12 @@ class OptionsResolver2Dot6Test extends TestCase
         });
 
         $this->resolver->setDefault('lazy2', function (Options $options) {
-            Assert::assertTrue(isset($options['default1']));
-            Assert::assertTrue(isset($options['default2']));
-            Assert::assertTrue(isset($options['required']));
-            Assert::assertTrue(isset($options['lazy1']));
-            Assert::assertTrue(isset($options['lazy2']));
-            Assert::assertFalse(isset($options['defined']));
+            Assert::assertArrayHasKey('default1', $options);
+            Assert::assertArrayHasKey('default2', $options);
+            Assert::assertArrayHasKey('required', $options);
+            Assert::assertArrayHasKey('lazy1', $options);
+            Assert::assertArrayHasKey('lazy2', $options);
+            Assert::assertArrayNotHasKey('defined', $options);
 
             Assert::assertSame(0, $options['default1']);
             Assert::assertSame(42, $options['default2']);
diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php
index 3240aa7954..c614b3aa40 100644
--- a/src/Symfony/Component/Process/Tests/ProcessTest.php
+++ b/src/Symfony/Component/Process/Tests/ProcessTest.php
@@ -567,7 +567,7 @@ class ProcessTest extends TestCase
     {
         $process = $this->getProcess('echo foo');
         $process->run();
-        $this->assertTrue(strlen($process->getOutput()) > 0);
+        $this->assertGreaterThan(0, strlen($process->getOutput()));
     }
 
     public function testGetExitCodeIsNullOnStart()
diff --git a/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php b/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php
index 56aff2ff40..a1ff9186c0 100644
--- a/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php
+++ b/src/Symfony/Component/Security/Acl/Tests/Dbal/MutableAclProviderTest.php
@@ -181,7 +181,7 @@ class MutableAclProviderTest extends TestCase
 
         $provider->propertyChanged($acl, 'entriesInheriting', false, true);
         $changes = $propertyChanges->offsetGet($acl);
-        $this->assertTrue(isset($changes['entriesInheriting']));
+        $this->assertArrayHasKey('entriesInheriting', $changes);
         $this->assertFalse($changes['entriesInheriting'][0]);
         $this->assertTrue($changes['entriesInheriting'][1]);
 
@@ -189,7 +189,7 @@ class MutableAclProviderTest extends TestCase
         $provider->propertyChanged($acl, 'entriesInheriting', false, true);
         $provider->propertyChanged($acl, 'entriesInheriting', true, false);
         $changes = $propertyChanges->offsetGet($acl);
-        $this->assertFalse(isset($changes['entriesInheriting']));
+        $this->assertArrayNotHasKey('entriesInheriting', $changes);
     }
 
     public function testPropertyChangedTracksChangesToAceProperties()
@@ -202,42 +202,42 @@ class MutableAclProviderTest extends TestCase
 
         $provider->propertyChanged($ace, 'mask', 1, 3);
         $changes = $propertyChanges->offsetGet($acl);
-        $this->assertTrue(isset($changes['aces']));
+        $this->assertArrayHasKey('aces', $changes);
         $this->assertInstanceOf('\SplObjectStorage', $changes['aces']);
         $this->assertTrue($changes['aces']->contains($ace));
         $aceChanges = $changes['aces']->offsetGet($ace);
-        $this->assertTrue(isset($aceChanges['mask']));
+        $this->assertArrayHasKey('mask', $aceChanges);
         $this->assertEquals(1, $aceChanges['mask'][0]);
         $this->assertEquals(3, $aceChanges['mask'][1]);
 
         $provider->propertyChanged($ace, 'strategy', 'all', 'any');
         $changes = $propertyChanges->offsetGet($acl);
-        $this->assertTrue(isset($changes['aces']));
+        $this->assertArrayHasKey('aces', $changes);
         $this->assertInstanceOf('\SplObjectStorage', $changes['aces']);
         $this->assertTrue($changes['aces']->contains($ace));
         $aceChanges = $changes['aces']->offsetGet($ace);
-        $this->assertTrue(isset($aceChanges['mask']));
-        $this->assertTrue(isset($aceChanges['strategy']));
+        $this->assertArrayHasKey('mask', $aceChanges);
+        $this->assertArrayHasKey('strategy', $aceChanges);
         $this->assertEquals('all', $aceChanges['strategy'][0]);
         $this->assertEquals('any', $aceChanges['strategy'][1]);
 
         $provider->propertyChanged($ace, 'mask', 3, 1);
         $changes = $propertyChanges->offsetGet($acl);
         $aceChanges = $changes['aces']->offsetGet($ace);
-        $this->assertFalse(isset($aceChanges['mask']));
-        $this->assertTrue(isset($aceChanges['strategy']));
+        $this->assertArrayNotHasKey('mask', $aceChanges);
+        $this->assertArrayHasKey('strategy', $aceChanges);
 
         $provider->propertyChanged($ace2, 'mask', 1, 3);
         $provider->propertyChanged($ace, 'strategy', 'any', 'all');
         $changes = $propertyChanges->offsetGet($acl);
-        $this->assertTrue(isset($changes['aces']));
+        $this->assertArrayHasKey('aces', $changes);
         $this->assertFalse($changes['aces']->contains($ace));
         $this->assertTrue($changes['aces']->contains($ace2));
 
         $provider->propertyChanged($ace2, 'mask', 3, 4);
         $provider->propertyChanged($ace2, 'mask', 4, 1);
         $changes = $propertyChanges->offsetGet($acl);
-        $this->assertFalse(isset($changes['aces']));
+        $this->assertArrayNotHasKey('aces', $changes);
     }
 
     /**
@@ -319,7 +319,7 @@ class MutableAclProviderTest extends TestCase
 
         $aces = $acl->getObjectAces();
         $reloadedAces = $reloadedAcl->getObjectAces();
-        $this->assertEquals(count($aces), count($reloadedAces));
+        $this->assertCount(count($aces), $reloadedAces);
         foreach ($aces as $index => $ace) {
             $this->assertAceEquals($ace, $reloadedAces[$index]);
         }
@@ -437,7 +437,7 @@ class MutableAclProviderTest extends TestCase
 
         $aces = $acl->getObjectAces();
         $reloadedAces = $reloadedAcl->getObjectAces();
-        $this->assertEquals(count($aces), count($reloadedAces));
+        $this->assertCount(count($aces), $reloadedAces);
         foreach ($reloadedAces as $ace) {
             $this->assertTrue($ace->getSecurityIdentity()->equals($newSid));
         }
diff --git a/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php b/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php
index 6e34e6d5e7..eed0090dfc 100644
--- a/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php
+++ b/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php
@@ -96,7 +96,7 @@ class MaskBuilderTest extends TestCase
         $this->assertEquals(0, $builder->get());
 
         $builder->add('view');
-        $this->assertTrue($builder->get() > 0);
+        $this->assertGreaterThan(0, $builder->get());
 
         $builder->reset();
         $this->assertEquals(0, $builder->get());
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
index ca28d53c5c..e3e1c447af 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
@@ -61,9 +61,9 @@ class AuthorizationCheckerTest extends TestCase
             ->will($this->returnValue(true));
 
         // first run the token has not been re-authenticated yet, after isGranted is called, it should be equal
-        $this->assertFalse($newToken === $this->tokenStorage->getToken());
+        $this->assertNotSame($newToken, $this->tokenStorage->getToken());
         $this->assertTrue($this->authorizationChecker->isGranted('foo'));
-        $this->assertTrue($newToken === $this->tokenStorage->getToken());
+        $this->assertSame($newToken, $this->tokenStorage->getToken());
     }
 
     /**
@@ -90,7 +90,7 @@ class AuthorizationCheckerTest extends TestCase
             ->method('decide')
             ->will($this->returnValue($decide));
         $this->tokenStorage->setToken($token);
-        $this->assertTrue($decide === $this->authorizationChecker->isGranted('ROLE_FOO'));
+        $this->assertSame($decide, $this->authorizationChecker->isGranted('ROLE_FOO'));
     }
 
     public function isGrantedProvider()
diff --git a/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php
index 3c842aae76..aa521ce8ed 100644
--- a/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php
@@ -39,7 +39,7 @@ class LegacySecurityContextTest extends TestCase
             ->method('getToken')
             ->will($this->returnValue($token));
 
-        $this->assertTrue($token === $this->securityContext->getToken());
+        $this->assertSame($token, $this->securityContext->getToken());
     }
 
     public function testSetTokenDelegation()
diff --git a/src/Symfony/Component/Templating/Tests/Helper/HelperTest.php b/src/Symfony/Component/Templating/Tests/Helper/HelperTest.php
index 8921ff19c8..dec9082efc 100644
--- a/src/Symfony/Component/Templating/Tests/Helper/HelperTest.php
+++ b/src/Symfony/Component/Templating/Tests/Helper/HelperTest.php
@@ -20,7 +20,7 @@ class HelperTest extends TestCase
     {
         $helper = new ProjectTemplateHelper();
         $helper->setCharset('ISO-8859-1');
-        $this->assertTrue('ISO-8859-1' === $helper->getCharset(), '->setCharset() sets the charset set related to this helper');
+        $this->assertSame('ISO-8859-1', $helper->getCharset(), '->setCharset() sets the charset set related to this helper');
     }
 }
 
diff --git a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php
index b4bf42b572..c889d21817 100644
--- a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php
+++ b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php
@@ -23,7 +23,7 @@ class CacheLoaderTest extends TestCase
     public function testConstructor()
     {
         $loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), sys_get_temp_dir());
-        $this->assertTrue($loader->getLoader() === $varLoader, '__construct() takes a template loader as its first argument');
+        $this->assertSame($loader->getLoader(), $varLoader, '__construct() takes a template loader as its first argument');
         $this->assertEquals(sys_get_temp_dir(), $loader->getDir(), '__construct() takes a directory where to store the cache as its second argument');
     }
 
diff --git a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php
index 4481c2abf5..abbb6b583c 100644
--- a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php
+++ b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php
@@ -65,7 +65,7 @@ class PhpEngineTest extends TestCase
         $engine[$foo] = 'bar';
         $this->assertEquals($foo, $engine->get('bar'), '->set() takes an alias as a second argument');
 
-        $this->assertTrue(isset($engine['bar']));
+        $this->assertArrayHasKey('bar', $engine);
 
         try {
             $engine->get('foobar');
@@ -75,7 +75,7 @@ class PhpEngineTest extends TestCase
             $this->assertEquals('The helper "foobar" is not defined.', $e->getMessage(), '->get() throws an InvalidArgumentException if the helper is not defined');
         }
 
-        $this->assertTrue(isset($engine['bar']));
+        $this->assertArrayHasKey('bar', $engine);
         $this->assertTrue($engine->has('foo'), '->has() returns true if the helper exists');
         $this->assertFalse($engine->has('foobar'), '->has() returns false if the helper does not exist');
     }
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/CsvFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/CsvFileDumperTest.php
index 39b1d64eb7..f9c4b1d8af 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/CsvFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/CsvFileDumperTest.php
@@ -27,7 +27,7 @@ foo', 'foo;foo' => 'bar'));
         $dumper = new CsvFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir));
 
-        $this->assertEquals(file_get_contents(__DIR__.'/../fixtures/valid.csv'), file_get_contents($tempDir.'/messages.en.csv'));
+        $this->assertFileEquals(__DIR__.'/../fixtures/valid.csv', $tempDir.'/messages.en.csv');
 
         unlink($tempDir.'/messages.en.csv');
     }
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php
index 5d2037c3f7..da5474e4cf 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php
@@ -29,7 +29,7 @@ class IcuResFileDumperTest extends TestCase
         $dumper = new IcuResFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir));
 
-        $this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resourcebundle/res/en.res'), file_get_contents($tempDir.'/messages/en.res'));
+        $this->assertFileEquals(__DIR__.'/../fixtures/resourcebundle/res/en.res', $tempDir.'/messages/en.res');
 
         @unlink($tempDir.'/messages/en.res');
         @rmdir($tempDir.'/messages');
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/IniFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/IniFileDumperTest.php
index efbdfa2c29..2b9876f4d2 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/IniFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/IniFileDumperTest.php
@@ -26,7 +26,7 @@ class IniFileDumperTest extends TestCase
         $dumper = new IniFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir));
 
-        $this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.ini'), file_get_contents($tempDir.'/messages.en.ini'));
+        $this->assertFileEquals(__DIR__.'/../fixtures/resources.ini', $tempDir.'/messages.en.ini');
 
         unlink($tempDir.'/messages.en.ini');
     }
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php
index 74d1c27b64..f3a746c051 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php
@@ -30,7 +30,7 @@ class JsonFileDumperTest extends TestCase
         $dumper = new JsonFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir));
 
-        $this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.json'), file_get_contents($tempDir.'/messages.en.json'));
+        $this->assertFileEquals(__DIR__.'/../fixtures/resources.json', $tempDir.'/messages.en.json');
 
         unlink($tempDir.'/messages.en.json');
     }
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/MoFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/MoFileDumperTest.php
index 6ac9b94002..f64d5c516d 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/MoFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/MoFileDumperTest.php
@@ -25,7 +25,7 @@ class MoFileDumperTest extends TestCase
         $tempDir = sys_get_temp_dir();
         $dumper = new MoFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir));
-        $this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.mo'), file_get_contents($tempDir.'/messages.en.mo'));
+        $this->assertFileEquals(__DIR__.'/../fixtures/resources.mo', $tempDir.'/messages.en.mo');
 
         unlink($tempDir.'/messages.en.mo');
     }
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/PhpFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/PhpFileDumperTest.php
index 5c5073c7ed..04a92e5cd4 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/PhpFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/PhpFileDumperTest.php
@@ -26,7 +26,7 @@ class PhpFileDumperTest extends TestCase
         $dumper = new PhpFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir));
 
-        $this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.php'), file_get_contents($tempDir.'/messages.en.php'));
+        $this->assertFileEquals(__DIR__.'/../fixtures/resources.php', $tempDir.'/messages.en.php');
 
         unlink($tempDir.'/messages.en.php');
     }
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/PoFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/PoFileDumperTest.php
index 03469770a3..1e84bfaefe 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/PoFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/PoFileDumperTest.php
@@ -25,7 +25,7 @@ class PoFileDumperTest extends TestCase
         $tempDir = sys_get_temp_dir();
         $dumper = new PoFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir));
-        $this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.po'), file_get_contents($tempDir.'/messages.en.po'));
+        $this->assertFileEquals(__DIR__.'/../fixtures/resources.po', $tempDir.'/messages.en.po');
 
         unlink($tempDir.'/messages.en.po');
     }
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/QtFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/QtFileDumperTest.php
index 3b7337d3f1..425b5987f9 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/QtFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/QtFileDumperTest.php
@@ -26,7 +26,7 @@ class QtFileDumperTest extends TestCase
         $dumper = new QtFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir));
 
-        $this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.ts'), file_get_contents($tempDir.'/resources.en.ts'));
+        $this->assertFileEquals(__DIR__.'/../fixtures/resources.ts', $tempDir.'/resources.en.ts');
 
         unlink($tempDir.'/resources.en.ts');
     }
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php
index 07411a0117..462ba9917c 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php
@@ -32,10 +32,7 @@ class XliffFileDumperTest extends TestCase
         $dumper = new XliffFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir, 'default_locale' => 'fr_FR'));
 
-        $this->assertEquals(
-            file_get_contents(__DIR__.'/../fixtures/resources-clean.xlf'),
-            file_get_contents($tempDir.'/messages.en_US.xlf')
-        );
+        $this->assertFileEquals(__DIR__.'/../fixtures/resources-clean.xlf', $tempDir.'/messages.en_US.xlf');
 
         unlink($tempDir.'/messages.en_US.xlf');
     }
diff --git a/src/Symfony/Component/Translation/Tests/Dumper/YamlFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/YamlFileDumperTest.php
index ae036bc3e9..dfd02b3253 100644
--- a/src/Symfony/Component/Translation/Tests/Dumper/YamlFileDumperTest.php
+++ b/src/Symfony/Component/Translation/Tests/Dumper/YamlFileDumperTest.php
@@ -26,7 +26,7 @@ class YamlFileDumperTest extends TestCase
         $dumper = new YamlFileDumper();
         $dumper->dump($catalogue, array('path' => $tempDir));
 
-        $this->assertEquals(file_get_contents(__DIR__.'/../fixtures/resources.yml'), file_get_contents($tempDir.'/messages.en.yml'));
+        $this->assertFileEquals(__DIR__.'/../fixtures/resources.yml', $tempDir.'/messages.en.yml');
 
         unlink($tempDir.'/messages.en.yml');
     }
diff --git a/src/Symfony/Component/Validator/Tests/ConstraintViolationListTest.php b/src/Symfony/Component/Validator/Tests/ConstraintViolationListTest.php
index 6f4518cab3..a35a1cd171 100644
--- a/src/Symfony/Component/Validator/Tests/ConstraintViolationListTest.php
+++ b/src/Symfony/Component/Validator/Tests/ConstraintViolationListTest.php
@@ -89,16 +89,16 @@ class ConstraintViolationListTest extends TestCase
         $this->list[] = $violation;
 
         $this->assertSame($violation, $this->list[0]);
-        $this->assertTrue(isset($this->list[0]));
+        $this->assertArrayHasKey(0, $this->list);
 
         unset($this->list[0]);
 
-        $this->assertFalse(isset($this->list[0]));
+        $this->assertArrayNotHasKey(0, $this->list);
 
         $this->list[10] = $violation;
 
         $this->assertSame($violation, $this->list[10]);
-        $this->assertTrue(isset($this->list[10]));
+        $this->assertArrayHasKey(10, $this->list);
     }
 
     public function testToString()
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php
index f298cd27e6..2b906a918f 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php
@@ -62,15 +62,15 @@ class GroupSequenceTest extends TestCase
 
         $this->assertSame('Group 1', $sequence[0]);
         $this->assertSame('Group 2', $sequence[1]);
-        $this->assertTrue(isset($sequence[0]));
-        $this->assertFalse(isset($sequence[2]));
+        $this->assertArrayHasKey(0, $sequence);
+        $this->assertArrayNotHasKey(2, $sequence);
         unset($sequence[0]);
-        $this->assertFalse(isset($sequence[0]));
+        $this->assertArrayNotHasKey(0, $sequence);
         $sequence[] = 'Group 3';
-        $this->assertTrue(isset($sequence[2]));
+        $this->assertArrayHasKey(2, $sequence);
         $this->assertSame('Group 3', $sequence[2]);
         $sequence[0] = 'Group 1';
-        $this->assertTrue(isset($sequence[0]));
+        $this->assertArrayHasKey(0, $sequence);
         $this->assertSame('Group 1', $sequence[0]);
     }
 

From ef6adb89efd1711d0dc0e13e1ba790b2f539eab6 Mon Sep 17 00:00:00 2001
From: Robin Chalas 
Date: Tue, 12 Dec 2017 12:55:28 +0100
Subject: [PATCH 2/8] Fix tests

---
 .../HttpFoundation/Tests/ResponseHeaderBagTest.php        | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
index 922093e549..d15e49ebdb 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
@@ -199,10 +199,10 @@ class ResponseHeaderBagTest extends TestCase
 
         $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
 
-        $this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/foo']));
-        $this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/bar']));
-        $this->assertArrayHasKey('foo', $cookies['bar.foo']['/path/bar']));
-        $this->assertArrayHasKey('foo', $cookies['']['/']));
+        $this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/foo']);
+        $this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/bar']);
+        $this->assertArrayHasKey('foo', $cookies['bar.foo']['/path/bar']);
+        $this->assertArrayHasKey('foo', $cookies['']['/']);
     }
 
     public function testRemoveCookie()

From 79b64ce328898547e2f59fe03868f62596df0c15 Mon Sep 17 00:00:00 2001
From: Nicolas Grekas 
Date: Tue, 12 Dec 2017 13:01:02 +0100
Subject: [PATCH 3/8] fix merge

---
 src/Symfony/Component/Filesystem/Tests/FilesystemTest.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
index a6e859493b..52e0d4e766 100644
--- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
@@ -169,7 +169,7 @@ class FilesystemTest extends FilesystemTestCase
         $this->filesystem->copy($sourceFilePath, $targetFilePath, false);
 
         $this->assertFileExists($targetFilePath);
-        $this->assertFileEquals($sourceFilePath, $targetFilePath);
+        $this->assertEquals(file_get_contents($sourceFilePath), file_get_contents($targetFilePath));
     }
 
     public function testMkdirCreatesDirectoriesRecursively()
@@ -1518,7 +1518,7 @@ class FilesystemTest extends FilesystemTestCase
         $this->filesystem->appendToFile($filename, 'bar');
 
         $this->assertFileExists($filename);
-        $this->assertStringEqualsFile($filename, 'bar');
+        $this->assertStringEqualsFile($filename, 'foobar');
 
         // skip mode check on Windows
         if ('\\' !== DIRECTORY_SEPARATOR) {

From 97c3f429eb0e5fea990849aca022c3f30419bcc3 Mon Sep 17 00:00:00 2001
From: Jonathan Johnson 
Date: Sun, 10 Dec 2017 13:39:54 -0800
Subject: [PATCH 4/8] Take advantage of
 AnnotationRegistry::registerUniqueLoader

This method will only add 'class_exists' as an autoloader if it has not
already been added. This helps alleviate a performance issue when the
same loader is added many times in tests.
---
 .../PhpUnit/Legacy/SymfonyTestsListenerTrait.php |  6 +++++-
 src/Symfony/Bridge/PhpUnit/bootstrap.php         |  6 +++++-
 .../DependencyInjection/FrameworkExtension.php   |  6 ++++++
 .../Resources/config/annotations.xml             | 16 ++++++++--------
 4 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
index 655687575d..d2ddddf3f2 100644
--- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
+++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
@@ -120,7 +120,11 @@ class SymfonyTestsListenerTrait
             $this->state = 0;
 
             if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
-                AnnotationRegistry::registerLoader('class_exists');
+                if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
+                    AnnotationRegistry::registerUniqueLoader('class_exists');
+                } else {
+                    AnnotationRegistry::registerLoader('class_exists');
+                }
             }
 
             if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) {
diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php
index a265a129e6..5de9467891 100644
--- a/src/Symfony/Bridge/PhpUnit/bootstrap.php
+++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php
@@ -28,7 +28,11 @@ if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Comman
 setlocale(LC_ALL, 'C');
 
 if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
-    AnnotationRegistry::registerLoader('class_exists');
+    if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
+        AnnotationRegistry::registerUniqueLoader('class_exists');
+    } else {
+        AnnotationRegistry::registerLoader('class_exists');
+    }
 }
 
 if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 8b21f6c644..e4c3b08d93 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -12,6 +12,7 @@
 namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
 
 use Doctrine\Common\Annotations\Reader;
+use Doctrine\Common\Annotations\AnnotationRegistry;
 use Symfony\Bridge\Monolog\Processor\DebugProcessor;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@@ -1087,6 +1088,11 @@ class FrameworkExtension extends Extension
 
         $loader->load('annotations.xml');
 
+        if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
+            $container->getDefinition('annotations.dummy_registry')
+                ->setMethodCalls(array(array('registerLoader', array('class_exists'))));
+        }
+
         if ('none' !== $config['cache']) {
             $cacheService = $config['cache'];
 
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
index 15bf002954..b751fe3a3d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
@@ -10,14 +10,14 @@
         
             
                 required
-                
-                    
-                    
-                        
-                            class_exists
-                        
-                    
-                
+                
+                
+            
+        
+
+        
+            
+                class_exists
             
         
 

From e7d8e1783b16d09f3aebaf19075abad1348a84f1 Mon Sep 17 00:00:00 2001
From: Christian Flothmann 
Date: Wed, 13 Dec 2017 08:51:34 +0100
Subject: [PATCH 5/8] add missing validation options to XSD file

---
 .../Resources/config/schema/symfony-1.0.xsd        |  2 ++
 .../Fixtures/php/validation_strict_email.php       |  7 +++++++
 .../Fixtures/php/validation_translation_domain.php |  7 +++++++
 .../Fixtures/xml/validation_strict_email.xml       | 11 +++++++++++
 .../Fixtures/xml/validation_translation_domain.xml | 11 +++++++++++
 .../Fixtures/yml/validation_strict_email.yml       |  3 +++
 .../Fixtures/yml/validation_translation_domain.yml |  3 +++
 .../DependencyInjection/FrameworkExtensionTest.php | 14 ++++++++++++++
 8 files changed, 58 insertions(+)
 create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_strict_email.php
 create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php
 create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_strict_email.xml
 create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_translation_domain.xml
 create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_strict_email.yml
 create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_translation_domain.yml

diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
index 2d866ff1b5..cfcfb34da8 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
@@ -204,6 +204,8 @@
         
         
         
+        
+        
         
     
 
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_strict_email.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_strict_email.php
new file mode 100644
index 0000000000..64a47a2322
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_strict_email.php
@@ -0,0 +1,7 @@
+loadFromExtension('framework', array(
+    'validation' => array(
+        'strict_email' => true,
+    ),
+));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php
new file mode 100644
index 0000000000..40a81d4936
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php
@@ -0,0 +1,7 @@
+loadFromExtension('framework', array(
+    'validation' => array(
+        'translation_domain' => 'messages',
+    ),
+));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_strict_email.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_strict_email.xml
new file mode 100644
index 0000000000..5b4aba1b70
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_strict_email.xml
@@ -0,0 +1,11 @@
+
+
+
+    
+        
+    
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_translation_domain.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_translation_domain.xml
new file mode 100644
index 0000000000..733d5fa683
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_translation_domain.xml
@@ -0,0 +1,11 @@
+
+
+
+    
+        
+    
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_strict_email.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_strict_email.yml
new file mode 100644
index 0000000000..1c805f9b92
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_strict_email.yml
@@ -0,0 +1,3 @@
+framework:
+    validation:
+        strict_email: true
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_translation_domain.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_translation_domain.yml
new file mode 100644
index 0000000000..167b5fcce8
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_translation_domain.yml
@@ -0,0 +1,3 @@
+framework:
+    validation:
+        translation_domain: messages
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 5601e6a88b..34a4e2dccd 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -420,6 +420,20 @@ abstract class FrameworkExtensionTest extends TestCase
         // no cache, no annotations, no static methods
     }
 
+    public function testValidationTranslationDomain()
+    {
+        $container = $this->createContainerFromFile('validation_translation_domain');
+
+        $this->assertSame('messages', $container->getParameter('validator.translation_domain'));
+    }
+
+    public function testValidationStrictEmail()
+    {
+        $container = $this->createContainerFromFile('validation_strict_email');
+
+        $this->assertTrue($container->getDefinition('validator.email')->getArgument(0));
+    }
+
     public function testFormsCanBeEnabledWithoutCsrfProtection()
     {
         $container = $this->createContainerFromFile('form_no_csrf');

From a8871de263d7f1bc7bc659cada4cb98a98ac7469 Mon Sep 17 00:00:00 2001
From: Amrouche Hamza 
Date: Wed, 13 Dec 2017 19:55:05 +0100
Subject: [PATCH 6/8] [Console] Fix a bug when passing a letter that could be
 an alias

---
 src/Symfony/Component/Console/Input/ArgvInput.php           | 2 ++
 src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php
index 4493a5bafc..23430edde6 100644
--- a/src/Symfony/Component/Console/Input/ArgvInput.php
+++ b/src/Symfony/Component/Console/Input/ArgvInput.php
@@ -284,6 +284,8 @@ class ArgvInput extends Input
                 }
 
                 if (0 === strpos($token, '-') && 0 !== strpos($token, '--')) {
+                    $noValue = explode('=', $token);
+                    $token = $noValue[0];
                     $searchableToken = str_replace('-', '', $token);
                     $searchableValue = str_replace('-', '', $value);
                     if ('' !== $searchableToken && '' !== $searchableValue && false !== strpos($searchableToken, $searchableValue)) {
diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php
index 85fb533715..8ded178bbe 100644
--- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php
+++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php
@@ -299,6 +299,9 @@ class ArgvInputTest extends TestCase
         $input = new ArgvInput(array('cli.php', '-fh'));
         $this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
 
+        $input = new ArgvInput(array('cli.php', '-e=test'));
+        $this->assertFalse($input->hasParameterOption('-s'), '->hasParameterOption() returns true if the given short option is in the raw input');
+
         $input = new ArgvInput(array('cli.php', '--foo', 'foo'));
         $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
 

From 8146510304297ad7d5abf9c54fa2b96de759f254 Mon Sep 17 00:00:00 2001
From: Matthias Pigulla 
Date: Sun, 10 Dec 2017 23:33:15 +0100
Subject: [PATCH 7/8] Preserve percent-encoding in URLs when performing
 redirects in the UrlMatcher

---
 .../Matcher/Dumper/PhpMatcherDumper.php       |  8 +--
 .../Tests/Fixtures/dumper/url_matcher1.php    |  4 +-
 .../Tests/Fixtures/dumper/url_matcher2.php    | 14 ++--
 .../Tests/Fixtures/dumper/url_matcher3.php    |  4 +-
 .../Matcher/Dumper/PhpMatcherDumperTest.php   | 72 +++++++++++++++++++
 .../Matcher/RedirectableUrlMatcherTest.php    | 10 +++
 6 files changed, 97 insertions(+), 15 deletions(-)

diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php
index 48187c0e3f..016021e259 100644
--- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php
+++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php
@@ -96,10 +96,10 @@ EOF;
         $code = rtrim($this->compileRoutes($this->getRoutes(), $supportsRedirections), "\n");
 
         return <<context;
         \$request = \$this->request;
 
@@ -284,7 +284,7 @@ EOF;
         if ($hasTrailingSlash) {
             $code .= <<redirect(\$pathinfo.'/', '$name');
+                return \$this->redirect(\$rawPathinfo.'/', '$name');
             }
 
 
@@ -299,7 +299,7 @@ EOF;
             $code .= <<context->getScheme()])) {
-                return \$this->redirect(\$pathinfo, '$name', key(\$requiredSchemes));
+                return \$this->redirect(\$rawPathinfo, '$name', key(\$requiredSchemes));
             }
 
 
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php
index 8ab42890aa..6451192d18 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php
@@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
         $this->context = $context;
     }
 
-    public function match($pathinfo)
+    public function match($rawPathinfo)
     {
         $allow = array();
-        $pathinfo = rawurldecode($pathinfo);
+        $pathinfo = rawurldecode($rawPathinfo);
         $context = $this->context;
         $request = $this->request;
 
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php
index 0f4b33b3c1..9b44eb920d 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php
@@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
         $this->context = $context;
     }
 
-    public function match($pathinfo)
+    public function match($rawPathinfo)
     {
         $allow = array();
-        $pathinfo = rawurldecode($pathinfo);
+        $pathinfo = rawurldecode($rawPathinfo);
         $context = $this->context;
         $request = $this->request;
 
@@ -67,7 +67,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
                 // baz3
                 if ('/test/baz3' === rtrim($pathinfo, '/')) {
                     if (substr($pathinfo, -1) !== '/') {
-                        return $this->redirect($pathinfo.'/', 'baz3');
+                        return $this->redirect($rawPathinfo.'/', 'baz3');
                     }
 
                     return array('_route' => 'baz3');
@@ -78,7 +78,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // baz4
             if (preg_match('#^/test/(?P[^/]++)/?$#s', $pathinfo, $matches)) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'baz4');
+                    return $this->redirect($rawPathinfo.'/', 'baz4');
                 }
 
                 return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
@@ -171,7 +171,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // hey
             if ('/multi/hey' === rtrim($pathinfo, '/')) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'hey');
+                    return $this->redirect($rawPathinfo.'/', 'hey');
                 }
 
                 return array('_route' => 'hey');
@@ -318,7 +318,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
         if ('/secure' === $pathinfo) {
             $requiredSchemes = array (  'https' => 0,);
             if (!isset($requiredSchemes[$this->context->getScheme()])) {
-                return $this->redirect($pathinfo, 'secure', key($requiredSchemes));
+                return $this->redirect($rawPathinfo, 'secure', key($requiredSchemes));
             }
 
             return array('_route' => 'secure');
@@ -328,7 +328,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
         if ('/nonsecure' === $pathinfo) {
             $requiredSchemes = array (  'http' => 0,);
             if (!isset($requiredSchemes[$this->context->getScheme()])) {
-                return $this->redirect($pathinfo, 'nonsecure', key($requiredSchemes));
+                return $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes));
             }
 
             return array('_route' => 'nonsecure');
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php
index 031b366b6c..04043273df 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php
@@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
         $this->context = $context;
     }
 
-    public function match($pathinfo)
+    public function match($rawPathinfo)
     {
         $allow = array();
-        $pathinfo = rawurldecode($pathinfo);
+        $pathinfo = rawurldecode($rawPathinfo);
         $context = $this->context;
         $request = $this->request;
 
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php
index cb3a144165..da90bc4fdf 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php
@@ -13,11 +13,39 @@ namespace Symfony\Component\Routing\Tests\Matcher\Dumper;
 
 use PHPUnit\Framework\TestCase;
 use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
+use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
+use Symfony\Component\Routing\Matcher\UrlMatcher;
+use Symfony\Component\Routing\RequestContext;
 use Symfony\Component\Routing\Route;
 use Symfony\Component\Routing\RouteCollection;
 
 class PhpMatcherDumperTest extends TestCase
 {
+    /**
+     * @var string
+     */
+    private $matcherClass;
+
+    /**
+     * @var string
+     */
+    private $dumpPath;
+
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $this->matcherClass = uniqid('ProjectUrlMatcher');
+        $this->dumpPath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_matcher.'.$this->matcherClass.'.php';
+    }
+
+    protected function tearDown()
+    {
+        parent::tearDown();
+
+        @unlink($this->dumpPath);
+    }
+
     /**
      * @expectedException \LogicException
      */
@@ -36,6 +64,23 @@ class PhpMatcherDumperTest extends TestCase
         $dumper->dump();
     }
 
+    public function testRedirectPreservesUrlEncoding()
+    {
+        $collection = new RouteCollection();
+        $collection->add('foo', new Route('/foo:bar/'));
+
+        $class = $this->generateDumpedMatcher($collection, true);
+
+        $matcher = $this->getMockBuilder($class)
+                        ->setMethods(array('redirect'))
+                        ->setConstructorArgs(array(new RequestContext()))
+                        ->getMock();
+        
+        $matcher->expects($this->once())->method('redirect')->with('/foo%3Abar/', 'foo');
+
+        $matcher->match('/foo%3Abar');
+    }
+
     /**
      * @dataProvider getRouteCollections
      */
@@ -285,4 +330,31 @@ class PhpMatcherDumperTest extends TestCase
            array($rootprefixCollection, 'url_matcher3.php', array()),
         );
     }
+
+    /**
+     * @param $dumper
+     */
+    private function generateDumpedMatcher(RouteCollection $collection, $redirectableStub = false)
+    {
+        $options = array('class' => $this->matcherClass);
+
+        if ($redirectableStub) {
+            $options['base_class'] = '\Symfony\Component\Routing\Tests\Matcher\Dumper\RedirectableUrlMatcherStub';
+        }
+
+        $dumper = new PhpMatcherDumper($collection);
+        $code = $dumper->dump($options);
+
+        file_put_contents($this->dumpPath, $code);
+        include $this->dumpPath;
+
+        return $this->matcherClass;
+    }
+}
+
+abstract class RedirectableUrlMatcherStub extends UrlMatcher implements RedirectableUrlMatcherInterface
+{
+    public function redirect($path, $route, $scheme = null)
+    {
+    }
 }
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
index ba4c6e972f..0b5bb0dc78 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
@@ -69,4 +69,14 @@ class RedirectableUrlMatcherTest extends TestCase
         ;
         $matcher->match('/foo');
     }
+
+    public function testRedirectPreservesUrlEncoding()
+    {
+        $coll = new RouteCollection();
+        $coll->add('foo', new Route('/foo:bar/'));
+
+        $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext()));
+        $matcher->expects($this->once())->method('redirect')->with('/foo%3Abar/');
+        $matcher->match('/foo%3Abar');
+    }
 }

From f5f3dd7878f73585de83022b708c4de4f3d7f0f9 Mon Sep 17 00:00:00 2001
From: Fabien Potencier 
Date: Thu, 14 Dec 2017 11:33:46 -0800
Subject: [PATCH 8/8] [Routing] fixed tests

---
 .../Tests/Fixtures/dumper/url_matcher4.php    |  4 ++--
 .../Tests/Fixtures/dumper/url_matcher5.php    | 22 +++++++++----------
 .../Tests/Fixtures/dumper/url_matcher6.php    |  4 ++--
 .../Tests/Fixtures/dumper/url_matcher7.php    | 16 +++++++-------
 4 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php
index 6aefd69382..50da489fb2 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php
@@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
         $this->context = $context;
     }
 
-    public function match($pathinfo)
+    public function match($rawPathinfo)
     {
         $allow = array();
-        $pathinfo = rawurldecode($pathinfo);
+        $pathinfo = rawurldecode($rawPathinfo);
         $trimmedPathinfo = rtrim($pathinfo, '/');
         $context = $this->context;
         $request = $this->request;
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php
index 1884df1c45..14c5f5bdf9 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php
@@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
         $this->context = $context;
     }
 
-    public function match($pathinfo)
+    public function match($rawPathinfo)
     {
         $allow = array();
-        $pathinfo = rawurldecode($pathinfo);
+        $pathinfo = rawurldecode($rawPathinfo);
         $trimmedPathinfo = rtrim($pathinfo, '/');
         $context = $this->context;
         $request = $this->request;
@@ -57,7 +57,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // a_fourth
             if ('/a/44' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'a_fourth');
+                    return $this->redirect($rawPathinfo.'/', 'a_fourth');
                 }
 
                 return array('_route' => 'a_fourth');
@@ -66,7 +66,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // a_fifth
             if ('/a/55' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'a_fifth');
+                    return $this->redirect($rawPathinfo.'/', 'a_fifth');
                 }
 
                 return array('_route' => 'a_fifth');
@@ -75,7 +75,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // a_sixth
             if ('/a/66' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'a_sixth');
+                    return $this->redirect($rawPathinfo.'/', 'a_sixth');
                 }
 
                 return array('_route' => 'a_sixth');
@@ -92,7 +92,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // nested_a
             if ('/nested/group/a' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'nested_a');
+                    return $this->redirect($rawPathinfo.'/', 'nested_a');
                 }
 
                 return array('_route' => 'nested_a');
@@ -101,7 +101,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // nested_b
             if ('/nested/group/b' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'nested_b');
+                    return $this->redirect($rawPathinfo.'/', 'nested_b');
                 }
 
                 return array('_route' => 'nested_b');
@@ -110,7 +110,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // nested_c
             if ('/nested/group/c' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'nested_c');
+                    return $this->redirect($rawPathinfo.'/', 'nested_c');
                 }
 
                 return array('_route' => 'nested_c');
@@ -122,7 +122,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // slashed_a
             if ('/slashed/group' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'slashed_a');
+                    return $this->redirect($rawPathinfo.'/', 'slashed_a');
                 }
 
                 return array('_route' => 'slashed_a');
@@ -131,7 +131,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // slashed_b
             if ('/slashed/group/b' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'slashed_b');
+                    return $this->redirect($rawPathinfo.'/', 'slashed_b');
                 }
 
                 return array('_route' => 'slashed_b');
@@ -140,7 +140,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // slashed_c
             if ('/slashed/group/c' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'slashed_c');
+                    return $this->redirect($rawPathinfo.'/', 'slashed_c');
                 }
 
                 return array('_route' => 'slashed_c');
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php
index bb9d80b551..933525699c 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php
@@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
         $this->context = $context;
     }
 
-    public function match($pathinfo)
+    public function match($rawPathinfo)
     {
         $allow = array();
-        $pathinfo = rawurldecode($pathinfo);
+        $pathinfo = rawurldecode($rawPathinfo);
         $trimmedPathinfo = rtrim($pathinfo, '/');
         $context = $this->context;
         $request = $this->request;
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php
index 404d462ed5..3306bb124e 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php
@@ -15,10 +15,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
         $this->context = $context;
     }
 
-    public function match($pathinfo)
+    public function match($rawPathinfo)
     {
         $allow = array();
-        $pathinfo = rawurldecode($pathinfo);
+        $pathinfo = rawurldecode($rawPathinfo);
         $trimmedPathinfo = rtrim($pathinfo, '/');
         $context = $this->context;
         $request = $this->request;
@@ -34,7 +34,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // simple_trailing_slash_no_methods
             if ('/trailing/simple/no-methods' === $trimmedPathinfo) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'simple_trailing_slash_no_methods');
+                    return $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_no_methods');
                 }
 
                 return array('_route' => 'simple_trailing_slash_no_methods');
@@ -48,7 +48,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
                 }
 
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'simple_trailing_slash_GET_method');
+                    return $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_GET_method');
                 }
 
                 return array('_route' => 'simple_trailing_slash_GET_method');
@@ -63,7 +63,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
                 }
 
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'simple_trailing_slash_HEAD_method');
+                    return $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_HEAD_method');
                 }
 
                 return array('_route' => 'simple_trailing_slash_HEAD_method');
@@ -87,7 +87,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
             // regex_trailing_slash_no_methods
             if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P[^/]++)/?$#s', $pathinfo, $matches)) {
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'regex_trailing_slash_no_methods');
+                    return $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_no_methods');
                 }
 
                 return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ());
@@ -101,7 +101,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
                 }
 
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'regex_trailing_slash_GET_method');
+                    return $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_GET_method');
                 }
 
                 return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
@@ -116,7 +116,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
                 }
 
                 if (substr($pathinfo, -1) !== '/') {
-                    return $this->redirect($pathinfo.'/', 'regex_trailing_slash_HEAD_method');
+                    return $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_HEAD_method');
                 }
 
                 return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());