diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index e30ebba89c..ddac6cb379 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -66,7 +66,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE $properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames()); - if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && $metadata->embeddedClasses) { + if ($metadata instanceof ClassMetadataInfo && class_exists(\Doctrine\ORM\Mapping\Embedded::class) && $metadata->embeddedClasses) { $properties = array_filter($properties, function ($property) { return false === strpos($property, '.'); }); @@ -142,7 +142,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE )]; } - if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && isset($metadata->embeddedClasses[$property])) { + if ($metadata instanceof ClassMetadataInfo && class_exists(\Doctrine\ORM\Mapping\Embedded::class) && isset($metadata->embeddedClasses[$property])) { return [new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])]; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php index 5569316441..09a4d276ae 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -229,7 +229,7 @@ EOTXT private function createCollector($queries) { - $connection = $this->getMockBuilder('Doctrine\DBAL\Connection') + $connection = $this->getMockBuilder(\Doctrine\DBAL\Connection::class) ->disableOriginalConstructor() ->getMock(); $connection->expects($this->any()) @@ -249,7 +249,7 @@ EOTXT ->method('getConnection') ->willReturn($connection); - $logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock(); + $logger = $this->getMockBuilder(\Doctrine\DBAL\Logging\DebugStack::class)->getMock(); $logger->queries = $queries; $collector = new DoctrineDataCollector($registry); diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php index 422c459b46..94c9f0c54d 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php @@ -19,7 +19,7 @@ class ContainerAwareLoaderTest extends TestCase { public function testShouldSetContainerOnContainerAwareFixture() { - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock(); $loader = new ContainerAwareLoader($container); $fixture = new ContainerAwareFixture(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php index d8eb1d1f7a..d5f1755ff6 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php @@ -23,7 +23,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase { public function testExceptionOnAbstractTaggedSubscriber() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $container = $this->createBuilder(); $abstractDefinition = new Definition('stdClass'); @@ -37,7 +37,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase public function testExceptionOnAbstractTaggedListener() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $container = $this->createBuilder(); $abstractDefinition = new Definition('stdClass'); diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php index eed9cf3bf9..c24c4b5300 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php @@ -11,7 +11,7 @@ class RegisterMappingsPassTest extends TestCase { public function testNoDriverParmeterException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Could not find the manager name parameter in the container. Tried the following parameter names: "manager.param.one", "manager.param.two"'); $container = $this->createBuilder(); $this->process($container, [ diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 0c1a67967d..7d3149f5cd 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -31,7 +31,7 @@ class DoctrineExtensionTest extends TestCase parent::setUp(); $this->extension = $this - ->getMockBuilder('Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension') + ->getMockBuilder(\Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension::class) ->setMethods([ 'getMappingResourceConfigDirectory', 'getObjectManagerElementName', @@ -51,7 +51,7 @@ class DoctrineExtensionTest extends TestCase public function testFixManagersAutoMappingsWithTwoAutomappings() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $emConfigs = [ 'em1' => [ 'auto_mapping' => true, @@ -234,7 +234,7 @@ class DoctrineExtensionTest extends TestCase public function testUnrecognizedCacheDriverException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('"unrecognized_type" is an unrecognized Doctrine cache driver.'); $cacheName = 'metadata_cache'; $container = $this->createContainer(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php index ee9597ed49..67e9f8a625 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php @@ -75,11 +75,11 @@ class DoctrineChoiceLoaderTest extends TestCase protected function setUp(): void { - $this->factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock(); + $this->factory = $this->getMockBuilder(ChoiceListFactoryInterface::class)->getMock(); $this->om = $this->getMockBuilder(ObjectManager::class)->getMock(); $this->repository = $this->getMockBuilder(ObjectRepository::class)->getMock(); $this->class = 'stdClass'; - $this->idReader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader') + $this->idReader = $this->getMockBuilder(IdReader::class) ->disableOriginalConstructor() ->getMock(); $this->idReader->expects($this->any()) @@ -87,7 +87,7 @@ class DoctrineChoiceLoaderTest extends TestCase ->willReturn(true) ; - $this->objectLoader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface')->getMock(); + $this->objectLoader = $this->getMockBuilder(EntityLoaderInterface::class)->getMock(); $this->obj1 = (object) ['name' => 'A']; $this->obj2 = (object) ['name' => 'B']; $this->obj3 = (object) ['name' => 'C']; diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php index d846df62c8..8bb0f25697 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php @@ -33,7 +33,7 @@ class ORMQueryBuilderLoaderTest extends TestCase { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder('QueryMock') + $query = $this->getMockBuilder(\QueryMock::class) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); @@ -46,7 +46,7 @@ class ORMQueryBuilderLoaderTest extends TestCase ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2], $expectedType) ->willReturn($query); - $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') + $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) ->setMethods(['getQuery']) ->getMock(); @@ -66,7 +66,7 @@ class ORMQueryBuilderLoaderTest extends TestCase { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder('QueryMock') + $query = $this->getMockBuilder(\QueryMock::class) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); @@ -79,7 +79,7 @@ class ORMQueryBuilderLoaderTest extends TestCase ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2, 3, '9223372036854775808'], Connection::PARAM_INT_ARRAY) ->willReturn($query); - $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') + $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) ->setMethods(['getQuery']) ->getMock(); @@ -102,7 +102,7 @@ class ORMQueryBuilderLoaderTest extends TestCase { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder('QueryMock') + $query = $this->getMockBuilder(\QueryMock::class) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); @@ -115,7 +115,7 @@ class ORMQueryBuilderLoaderTest extends TestCase ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'], Connection::PARAM_STR_ARRAY) ->willReturn($query); - $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') + $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) ->setMethods(['getQuery']) ->getMock(); @@ -141,7 +141,7 @@ class ORMQueryBuilderLoaderTest extends TestCase $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder('QueryMock') + $query = $this->getMockBuilder(\QueryMock::class) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); @@ -154,7 +154,7 @@ class ORMQueryBuilderLoaderTest extends TestCase ->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', [1, 2, 3], Connection::PARAM_INT_ARRAY) ->willReturn($query); - $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') + $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class) ->setConstructorArgs([$em]) ->setMethods(['getQuery']) ->getMock(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php index 9891fb2479..4ecd501d3e 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php @@ -64,7 +64,7 @@ class CollectionToArrayTransformerTest extends TestCase public function testTransformExpectsArrayOrCollection() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->transformer->transform('Foo'); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index 50f222d8e8..79ea8a1885 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -34,21 +34,21 @@ class DoctrineOrmTypeGuesserTest extends TestCase $return = []; // Simple field, not nullable - $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); + $classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock(); $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false); $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; // Simple field, nullable - $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); + $classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock(); $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true); $return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)]; // One-to-one, nullable (by default) - $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); + $classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [[]]]; @@ -57,7 +57,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; // One-to-one, nullable (explicit) - $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); + $classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => true]]]; @@ -66,7 +66,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; // One-to-one, not nullable - $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); + $classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => false]]]; @@ -75,7 +75,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; // One-to-many, no clue - $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); + $classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false); $return[] = [$classMetadata, null]; diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php index 31fe0c5db6..22692eea43 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php @@ -32,7 +32,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase { $this->collection = new ArrayCollection(['test']); $this->dispatcher = new EventDispatcher(); - $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(); $this->form = $this->getBuilder() ->getForm(); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index f35d3f5acc..e7ce4b3ecf 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -118,13 +118,13 @@ class EntityTypeTest extends BaseTypeTest public function testClassOptionIsRequired() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class); $this->factory->createNamed('name', static::TESTED_TYPE); } public function testInvalidClassOption() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'class' => 'foo', ]); @@ -219,7 +219,7 @@ class EntityTypeTest extends BaseTypeTest public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, @@ -229,7 +229,7 @@ class EntityTypeTest extends BaseTypeTest public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, @@ -1242,7 +1242,7 @@ class EntityTypeTest extends BaseTypeTest $choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader'); $choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader'); - $this->assertInstanceOf('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface', $choiceLoader1); + $this->assertInstanceOf(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class, $choiceLoader1); $this->assertSame($choiceLoader1, $choiceLoader2); $this->assertSame($choiceLoader1, $choiceLoader3); } @@ -1302,7 +1302,7 @@ class EntityTypeTest extends BaseTypeTest $choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader'); $choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader'); - $this->assertInstanceOf('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface', $choiceLoader1); + $this->assertInstanceOf(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class, $choiceLoader1); $this->assertSame($choiceLoader1, $choiceLoader2); $this->assertSame($choiceLoader1, $choiceLoader3); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php index 10c403f461..786ed1b22c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php @@ -21,10 +21,10 @@ class DbalLoggerTest extends TestCase */ public function testLog($sql, $params, $logParams) { - $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $dbalLogger = $this - ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') + ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) ->setMethods(['log']) ->getMock() @@ -53,10 +53,10 @@ class DbalLoggerTest extends TestCase public function testLogNonUtf8() { - $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $dbalLogger = $this - ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') + ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) ->setMethods(['log']) ->getMock() @@ -76,10 +76,10 @@ class DbalLoggerTest extends TestCase public function testLogNonUtf8Array() { - $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $dbalLogger = $this - ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') + ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) ->setMethods(['log']) ->getMock() @@ -107,10 +107,10 @@ class DbalLoggerTest extends TestCase public function testLogLongString() { - $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $dbalLogger = $this - ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') + ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) ->setMethods(['log']) ->getMock() @@ -135,10 +135,10 @@ class DbalLoggerTest extends TestCase public function testLogUTF8LongString() { - $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $dbalLogger = $this - ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') + ->getMockBuilder(DbalLogger::class) ->setConstructorArgs([$logger, null]) ->setMethods(['log']) ->getMock() diff --git a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php index 81f197f93c..5ddd60df8e 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php @@ -19,7 +19,7 @@ class ManagerRegistryTest extends TestCase { public static function setUpBeforeClass(): void { - if (!class_exists('PHPUnit_Framework_TestCase')) { + if (!class_exists(\PHPUnit_Framework_TestCase::class)) { self::markTestSkipped('proxy-manager-bridge is not yet compatible with namespaced phpunit versions.'); } $test = new PhpDumperTest(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php b/src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php index 4882a1fee2..91094173b6 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php @@ -55,7 +55,7 @@ class DoctrineTransactionMiddlewareTest extends MiddlewareTestCase public function testTransactionIsRolledBackOnException() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Thrown from next middleware.'); $this->connection->expects($this->once()) ->method('beginTransaction') diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index d46ab139d4..c96c594181 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -105,7 +105,7 @@ class DoctrineExtractorTest extends TestCase private function doTestGetPropertiesWithEmbedded(bool $legacy) { - if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { + if (!class_exists(\Doctrine\ORM\Mapping\Embedded::class)) { $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); } @@ -151,7 +151,7 @@ class DoctrineExtractorTest extends TestCase private function doTestExtractWithEmbedded(bool $legacy) { - if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { + if (!class_exists(\Doctrine\ORM\Mapping\Embedded::class)) { $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 775e223a74..e0cfa07748 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -71,7 +71,7 @@ class EntityUserProviderTest extends TestCase ->with('user1') ->willReturn($user); - $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') + $em = $this->getMockBuilder(\Doctrine\ORM\EntityManager::class) ->disableOriginalConstructor() ->getMock(); $em @@ -86,7 +86,7 @@ class EntityUserProviderTest extends TestCase public function testLoadUserByUsernameWithNonUserLoaderRepositoryAndWithoutProperty() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('You must either make the "Symfony\Bridge\Doctrine\Tests\Fixtures\User" entity Doctrine Repository ("Doctrine\ORM\EntityRepository") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.'); $em = DoctrineTestHelper::createTestEntityManager(); $this->createSchema($em); @@ -107,7 +107,7 @@ class EntityUserProviderTest extends TestCase $user1 = new User(null, null, 'user1'); $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine'); $provider->refreshUser($user1); } @@ -125,7 +125,7 @@ class EntityUserProviderTest extends TestCase $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); $user2 = new User(1, 2, 'user2'); - $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class); $this->expectExceptionMessage('User with id {"id1":1,"id2":2} not found'); $provider->refreshUser($user2); @@ -168,7 +168,7 @@ class EntityUserProviderTest extends TestCase public function testLoadUserByUserNameShouldDeclineInvalidInterface() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $repository = $this->createMock(ObjectRepository::class); $provider = new EntityUserProvider( diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index 1ccc4b7cc4..4aee8ff911 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -269,7 +269,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new UniqueEntity([ 'message' => 'myMessage', 'fields' => ['name', 'name2'], @@ -578,7 +578,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testDedicatedEntityManagerNullObject() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('Object manager "foo" does not exist.'); $constraint = new UniqueEntity([ 'message' => 'myMessage', @@ -598,7 +598,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testEntityManagerNullObject() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('Unable to find the object manager associated with an entity of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity"'); $constraint = new UniqueEntity([ 'message' => 'myMessage', @@ -680,7 +680,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testInvalidateRepositoryForInheritance() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('The "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity" entity repository does not support the "Symfony\Bridge\Doctrine\Tests\Fixtures\Person" entity. The entity should be an instance of or extend "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity".'); $constraint = new UniqueEntity([ 'message' => 'myMessage', diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php index fc4559277e..49151e1428 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php @@ -46,7 +46,7 @@ class ConsoleHandlerTest extends TestCase */ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = []) { - $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $output = $this->getMockBuilder(OutputInterface::class)->getMock(); $output ->expects($this->atLeastOnce()) ->method('getVerbosity') @@ -61,7 +61,7 @@ class ConsoleHandlerTest extends TestCase $levelName = Logger::getLevelName($level); $levelName = sprintf('%-9s', $levelName); - $realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(['doWrite'])->getMock(); + $realOutput = $this->getMockBuilder(\Symfony\Component\Console\Output\Output::class)->setMethods(['doWrite'])->getMock(); $realOutput->setVerbosity($verbosity); if ($realOutput->isDebug()) { $log = "16:21:54 $levelName [app] My info message\n"; @@ -110,7 +110,7 @@ class ConsoleHandlerTest extends TestCase public function testVerbosityChanged() { - $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $output = $this->getMockBuilder(OutputInterface::class)->getMock(); $output ->expects($this->exactly(2)) ->method('getVerbosity') @@ -131,14 +131,14 @@ class ConsoleHandlerTest extends TestCase public function testGetFormatter() { $handler = new ConsoleHandler(); - $this->assertInstanceOf('Symfony\Bridge\Monolog\Formatter\ConsoleFormatter', $handler->getFormatter(), + $this->assertInstanceOf(\Symfony\Bridge\Monolog\Formatter\ConsoleFormatter::class, $handler->getFormatter(), '-getFormatter returns ConsoleFormatter by default' ); } public function testWritingAndFormatting() { - $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); + $output = $this->getMockBuilder(OutputInterface::class)->getMock(); $output ->expects($this->any()) ->method('getVerbosity') @@ -193,12 +193,12 @@ class ConsoleHandlerTest extends TestCase $logger->info('After terminate message.'); }); - $event = new ConsoleCommandEvent(new Command('foo'), $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $output); + $event = new ConsoleCommandEvent(new Command('foo'), $this->getMockBuilder(\Symfony\Component\Console\Input\InputInterface::class)->getMock(), $output); $dispatcher->dispatch($event, ConsoleEvents::COMMAND); $this->assertStringContainsString('Before command message.', $out = $output->fetch()); $this->assertStringContainsString('After command message.', $out); - $event = new ConsoleTerminateEvent(new Command('foo'), $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $output, 0); + $event = new ConsoleTerminateEvent(new Command('foo'), $this->getMockBuilder(\Symfony\Component\Console\Input\InputInterface::class)->getMock(), $output, 0); $dispatcher->dispatch($event, ConsoleEvents::TERMINATE); $this->assertStringContainsString('Before terminate message.', $out = $output->fetch()); $this->assertStringContainsString('After terminate message.', $out); diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php index 75bbe16c14..3d84cb3552 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php @@ -22,13 +22,13 @@ class HttpCodeActivationStrategyTest extends TestCase { public function testExclusionsWithoutCode() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING); } public function testExclusionsWithoutUrls() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], Logger::WARNING); } diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php index 24aed73095..73cb964d9a 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php @@ -109,7 +109,7 @@ class WebProcessorTest extends TestCase private function isExtraFieldsSupported() { - $monologWebProcessorClass = new \ReflectionClass('Monolog\Processor\WebProcessor'); + $monologWebProcessorClass = new \ReflectionClass(\Monolog\Processor\WebProcessor::class); foreach ($monologWebProcessorClass->getConstructor()->getParameters() as $parameter) { if ('extraFields' === $parameter->getName()) { diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index cfbdd30fc1..f2f8045360 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -332,7 +332,7 @@ class DeprecationErrorHandler private static function getPhpUnitErrorHandler() { if (!isset(self::$isAtLeastPhpUnit83)) { - self::$isAtLeastPhpUnit83 = class_exists('PHPUnit\Util\ErrorHandler') && method_exists('PHPUnit\Util\ErrorHandler', '__invoke'); + self::$isAtLeastPhpUnit83 = class_exists(ErrorHandler::class) && method_exists(ErrorHandler::class, '__invoke'); } if (!self::$isAtLeastPhpUnit83) { return 'PHPUnit\Util\ErrorHandler::handleError'; diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 2b9be2cd59..546e3c01f7 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -133,8 +133,8 @@ class SymfonyTestsListenerTrait echo "Testing $suiteName\n"; $this->state = 0; - if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) { - if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) { + if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { + if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { AnnotationRegistry::registerUniqueLoader('class_exists'); } else { AnnotationRegistry::registerLoader('class_exists'); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/BarCovTest.php b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/BarCovTest.php index dc7f2cefd0..d0280dc13a 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/BarCovTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/BarCovTest.php @@ -17,7 +17,7 @@ class BarCovTest extends TestCase { public function testBarCov() { - if (!class_exists('PhpUnitCoverageTest\FooCov')) { + if (!class_exists(\PhpUnitCoverageTest\FooCov::class)) { $this->markTestSkipped('This test is not part of the main Symfony test suite. It\'s here to test the CoverageListener.'); } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php index 1471e9c7be..e9634480b7 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php @@ -24,7 +24,7 @@ class ProcessIsolationTest extends TestCase public function testCallingOtherErrorHandler() { - $this->expectException('PHPUnit\Framework\Exception'); + $this->expectException(\PHPUnit\Framework\Exception::class); $this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.'); trigger_error('Test that PHPUnit\'s error handler fires.', \E_USER_WARNING); diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php index c2a3efeb59..581e26dc3f 100644 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php @@ -262,17 +262,17 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; -if (!class_exists('SymfonyExcludeListPhpunit', false)) { +if (!class_exists(\SymfonyExcludeListPhpunit::class, false)) { class SymfonyExcludeListPhpunit {} } -if (method_exists('PHPUnit\Util\ExcludeList', 'addDirectory')) { +if (method_exists(\PHPUnit\Util\ExcludeList::class, 'addDirectory')) { (new PHPUnit\Util\Excludelist())->getExcludedDirectories(); - PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName())); - class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName())); -} elseif (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) { + PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName())); + class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName())); +} elseif (method_exists(\PHPUnit\Util\Blacklist::class, 'addDirectory')) { (new PHPUnit\Util\BlackList())->getBlacklistedDirectories(); - PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName())); - class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName())); + PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName())); + class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName())); } else { PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1; PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1; @@ -397,7 +397,7 @@ if ($components) { } } } elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) { - if (!class_exists('SymfonyExcludeListSimplePhpunit', false)) { + if (!class_exists(\SymfonyExcludeListSimplePhpunit::class, false)) { class SymfonyExcludeListSimplePhpunit { } diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index 2b6f2bac6c..d9947a7f4e 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -12,7 +12,7 @@ use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; -if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { +if (class_exists(\PHPUnit_Runner_Version::class) && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { $classes = [ 'PHPUnit_Framework_Assert', // override PhpUnit's ForwardCompat child class 'PHPUnit_Framework_AssertionFailedError', // override PhpUnit's ForwardCompat child class @@ -110,15 +110,15 @@ if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) { } // Detect if we're loaded by an actual run of phpunit -if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false) && !class_exists('PHPUnit\TextUI\Command', false)) { +if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists(\PHPUnit_TextUI_Command::class, false) && !class_exists(\PHPUnit\TextUI\Command::class, false)) { return; } // Enforce a consistent locale setlocale(\LC_ALL, 'C'); -if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) { - if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) { +if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { + if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { AnnotationRegistry::registerUniqueLoader('class_exists'); } else { AnnotationRegistry::registerLoader('class_exists'); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php index 647d1667c3..6a2935f5f1 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php @@ -38,15 +38,15 @@ class PhpDumperTest extends TestCase */ public function testDumpContainerWithProxyServiceWillShareProxies() { - if (!class_exists('LazyServiceProjectServiceContainer', false)) { + if (!class_exists(\LazyServiceProjectServiceContainer::class, false)) { eval('?>'.$this->dumpLazyServiceProjectServiceContainer()); } $container = new \LazyServiceProjectServiceContainer(); $proxy = $container->get('foo'); - $this->assertInstanceOf('stdClass', $proxy); - $this->assertInstanceOf('ProxyManager\Proxy\LazyLoadingInterface', $proxy); + $this->assertInstanceOf(\stdClass::class, $proxy); + $this->assertInstanceOf(\ProxyManager\Proxy\LazyLoadingInterface::class, $proxy); $this->assertSame($proxy, $container->get('foo')); $this->assertFalse($proxy->isProxyInitialized()); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php index e53fb43c1f..4673972961 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php @@ -38,7 +38,7 @@ class RuntimeInstantiatorTest extends TestCase public function testInstantiateProxy() { $instance = new \stdClass(); - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock(); $definition = new Definition('stdClass'); $instantiator = function () use ($instance) { return $instance; @@ -47,8 +47,8 @@ class RuntimeInstantiatorTest extends TestCase /* @var $proxy \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface */ $proxy = $this->instantiator->instantiateProxy($container, $definition, 'foo', $instantiator); - $this->assertInstanceOf('ProxyManager\Proxy\LazyLoadingInterface', $proxy); - $this->assertInstanceOf('ProxyManager\Proxy\ValueHolderInterface', $proxy); + $this->assertInstanceOf(\ProxyManager\Proxy\LazyLoadingInterface::class, $proxy); + $this->assertInstanceOf(\ProxyManager\Proxy\ValueHolderInterface::class, $proxy); $this->assertFalse($proxy->isProxyInitialized()); $proxy->initializeProxy(); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index 33ea1cdcec..91b1af2892 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -111,7 +111,7 @@ class ProxyDumperTest extends TestCase public function testGetProxyFactoryCodeWithoutCustomMethod() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Missing factory code to construct the service "foo".'); $definition = new Definition(__CLASS__); $definition->setLazy(true); diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index 54247a59e3..bc87d75bd7 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -20,7 +20,7 @@ use Twig\Node\Node; use Twig\Node\TextNode; // BC/FC with namespaced Twig -class_exists('Twig\Node\Expression\ArrayExpression'); +class_exists(ArrayExpression::class); /** * @author Fabien Potencier diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php index 59539f278c..044827110d 100644 --- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php +++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php @@ -50,7 +50,7 @@ class AppVariableTest extends TestCase */ public function testGetSession() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(Request::class)->getMock(); $request->method('hasSession')->willReturn(true); $request->method('getSession')->willReturn($session = new Session()); @@ -75,10 +75,10 @@ class AppVariableTest extends TestCase public function testGetToken() { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $this->appVariable->setTokenStorage($tokenStorage); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $tokenStorage->method('getToken')->willReturn($token); $this->assertEquals($token, $this->appVariable->getToken()); @@ -86,7 +86,7 @@ class AppVariableTest extends TestCase public function testGetUser() { - $this->setTokenStorage($user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()); + $this->setTokenStorage($user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock()); $this->assertEquals($user, $this->appVariable->getUser()); } @@ -100,7 +100,7 @@ class AppVariableTest extends TestCase public function testGetTokenWithNoToken() { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $this->appVariable->setTokenStorage($tokenStorage); $this->assertNull($this->appVariable->getToken()); @@ -108,7 +108,7 @@ class AppVariableTest extends TestCase public function testGetUserWithNoToken() { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $this->appVariable->setTokenStorage($tokenStorage); $this->assertNull($this->appVariable->getUser()); @@ -116,37 +116,37 @@ class AppVariableTest extends TestCase public function testEnvironmentNotSet() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->appVariable->getEnvironment(); } public function testDebugNotSet() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->appVariable->getDebug(); } public function testGetTokenWithTokenStorageNotSet() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->appVariable->getToken(); } public function testGetUserWithTokenStorageNotSet() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->appVariable->getUser(); } public function testGetRequestWithRequestStackNotSet() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->appVariable->getRequest(); } public function testGetSessionWithRequestStackNotSet() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->appVariable->getSession(); } @@ -224,7 +224,7 @@ class AppVariableTest extends TestCase protected function setRequestStack($request) { - $requestStackMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $requestStackMock = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $requestStackMock->method('getCurrentRequest')->willReturn($request); $this->appVariable->setRequestStack($requestStackMock); @@ -232,10 +232,10 @@ class AppVariableTest extends TestCase protected function setTokenStorage($user) { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $this->appVariable->setTokenStorage($tokenStorage); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $tokenStorage->method('getToken')->willReturn($token); $token->method('getUser')->willReturn($user); @@ -251,11 +251,11 @@ class AppVariableTest extends TestCase $flashBag = new FlashBag(); $flashBag->initialize($flashMessages); - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); + $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); $session->method('isStarted')->willReturn($sessionHasStarted); $session->method('getFlashBag')->willReturn($flashBag); - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(Request::class)->getMock(); $request->method('hasSession')->willReturn(true); $request->method('getSession')->willReturn($session); $this->setRequestStack($request); diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index 3d85565fdc..8be4a64bd6 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -91,7 +91,7 @@ class DebugCommandTest extends TestCase public function testMalformedTemplateName() { - $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Console\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Malformed namespaced template name "@foo" (expecting "@namespace/template_name").'); $this->createCommandTester()->execute(['name' => '@foo']); } diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index 09e8352fae..9bb9a9867c 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -48,7 +48,7 @@ class LintCommandTest extends TestCase public function testLintFileNotReadable() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $tester = $this->createCommandTester(); $filename = $this->createFile(''); unlink($filename); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index 25e42ce7bd..bd6e58b5ed 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -67,7 +67,7 @@ class DumpExtensionTest extends TestCase public function testDump($context, $args, $expectedOutput, $debug = true) { $extension = new DumpExtension(new VarCloner()); - $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [ + $twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), [ 'debug' => $debug, 'cache' => false, 'optimizations' => 0, @@ -124,7 +124,7 @@ class DumpExtensionTest extends TestCase '' ); $extension = new DumpExtension(new VarCloner(), $dumper); - $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [ + $twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), [ 'debug' => true, 'cache' => false, 'optimizations' => 0, diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index 61be57e1a6..425b489fec 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -50,7 +50,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori 'bootstrap_3_horizontal_layout.html.twig', 'custom_widgets.html.twig', ], $environment); - $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); + $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index 9dcefcbee3..b20768b911 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -46,7 +46,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest 'bootstrap_3_layout.html.twig', 'custom_widgets.html.twig', ], $environment); - $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); + $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } @@ -88,7 +88,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest 'bootstrap_3_layout.html.twig', 'custom_widgets.html.twig', ], $environment); - $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); + $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); $view = $this->factory diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php index a7222867d1..70713ef59a 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php @@ -52,7 +52,7 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori 'bootstrap_4_horizontal_layout.html.twig', 'custom_widgets.html.twig', ], $environment); - $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); + $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php index ee13f62cea..c489bfb425 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php @@ -50,7 +50,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest 'bootstrap_4_layout.html.twig', 'custom_widgets.html.twig', ], $environment); - $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); + $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } @@ -92,7 +92,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest 'bootstrap_4_layout.html.twig', 'custom_widgets.html.twig', ], $environment); - $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); + $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); $view = $this->factory diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index 5ad451c0b8..61e91ebd0a 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -53,7 +53,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest 'form_div_layout.html.twig', 'custom_widgets.html.twig', ], $environment); - $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); + $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } @@ -181,7 +181,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest 'form_div_layout.html.twig', 'custom_widgets.html.twig', ], $environment); - $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); + $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); $view = $this->factory diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index 40d51c2bbb..629677832f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -50,7 +50,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest 'form_table_layout.html.twig', 'custom_widgets.html.twig', ], $environment); - $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); + $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php index 396f433bfd..df9add8afb 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php @@ -62,7 +62,7 @@ class HttpFoundationExtensionTest extends TestCase */ public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected) { - if (!class_exists('Symfony\Component\Routing\RequestContext')) { + if (!class_exists(RequestContext::class)) { $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); } @@ -77,7 +77,7 @@ class HttpFoundationExtensionTest extends TestCase */ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) { - if (!class_exists('Symfony\Component\Routing\RequestContext')) { + if (!class_exists(RequestContext::class)) { $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); } @@ -120,7 +120,7 @@ class HttpFoundationExtensionTest extends TestCase */ public function testGenerateRelativePath($expected, $path, $pathinfo) { - if (!method_exists('Symfony\Component\HttpFoundation\Request', 'getRelativeUriForPath')) { + if (!method_exists(Request::class, 'getRelativeUriForPath')) { $this->markTestSkipped('Your version of Symfony HttpFoundation is too old.'); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php index c635935f3e..83ca06fbab 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php @@ -24,7 +24,7 @@ class HttpKernelExtensionTest extends TestCase { public function testFragmentWithError() { - $this->expectException('Twig\Error\RuntimeError'); + $this->expectException(\Twig\Error\RuntimeError::class); $renderer = $this->getFragmentHandler($this->throwException(new \Exception('foo'))); $this->renderTemplate($renderer); @@ -41,13 +41,13 @@ class HttpKernelExtensionTest extends TestCase public function testUnknownFragmentRenderer() { - $context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') + $context = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class) ->disableOriginalConstructor() ->getMock() ; $renderer = new FragmentHandler($context); - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "inline" renderer does not exist.'); $renderer->render('/foo'); @@ -55,11 +55,11 @@ class HttpKernelExtensionTest extends TestCase protected function getFragmentHandler($return) { - $strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock(); + $strategy = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface::class)->getMock(); $strategy->expects($this->once())->method('getName')->willReturn('inline'); $strategy->expects($this->once())->method('render')->will($return); - $context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') + $context = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class) ->disableOriginalConstructor() ->getMock() ; @@ -75,7 +75,7 @@ class HttpKernelExtensionTest extends TestCase $twig = new Environment($loader, ['debug' => true, 'cache' => false]); $twig->addExtension(new HttpKernelExtension()); - $loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Twig\RuntimeLoader\RuntimeLoaderInterface::class)->getMock(); $loader->expects($this->any())->method('load')->willReturnMap([ ['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)], ]); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php index 05f7ad741c..7362702bd2 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php @@ -24,8 +24,8 @@ class RoutingExtensionTest extends TestCase */ public function testEscaping($template, $mustBeEscaped) { - $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); - $twig->addExtension(new RoutingExtension($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock())); + $twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); + $twig->addExtension(new RoutingExtension($this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock())); $nodes = $twig->parse($twig->tokenize(new Source($template, ''))); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php b/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php index 0bec8ec6f1..f3ef885834 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php @@ -18,7 +18,7 @@ trait RuntimeLoaderProvider { protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer) { - $loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Twig\RuntimeLoader\RuntimeLoaderInterface::class)->getMock(); $loader->expects($this->any())->method('load')->will($this->returnValueMap([ ['Symfony\Component\Form\FormRenderer', $renderer], ])); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php index 8e100deae1..8f7ef97e9c 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php @@ -21,7 +21,7 @@ class StopwatchExtensionTest extends TestCase { public function testFailIfStoppingWrongEvent() { - $this->expectException('Twig\Error\SyntaxError'); + $this->expectException(\Twig\Error\SyntaxError::class); $this->testTiming('{% stopwatch "foo" %}{% endstopwatch "bar" %}', []); } @@ -55,7 +55,7 @@ class StopwatchExtensionTest extends TestCase protected function getStopwatch($events = []) { $events = \is_array($events) ? $events : [$events]; - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); + $stopwatch = $this->getMockBuilder(\Symfony\Component\Stopwatch\Stopwatch::class)->getMock(); $expectedCalls = 0; $expectedStartCalls = []; diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index d082e9b5de..a02fd2b295 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -58,14 +58,14 @@ class TranslationExtensionTest extends TestCase public function testTransUnknownKeyword() { - $this->expectException('Twig\Error\SyntaxError'); + $this->expectException(\Twig\Error\SyntaxError::class); $this->expectExceptionMessage('Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3.'); $this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render(); } public function testTransComplexBody() { - $this->expectException('Twig\Error\SyntaxError'); + $this->expectException(\Twig\Error\SyntaxError::class); $this->expectExceptionMessage('A message inside a trans tag must be a simple text in "index" at line 2.'); $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render(); } @@ -75,7 +75,7 @@ class TranslationExtensionTest extends TestCase */ public function testTransChoiceComplexBody() { - $this->expectException('Twig\Error\SyntaxError'); + $this->expectException(\Twig\Error\SyntaxError::class); $this->expectExceptionMessage('A message inside a transchoice tag must be a simple text in "index" at line 2.'); $this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render(); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php index 06c75fd0ec..89afd4ab2d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php @@ -24,7 +24,7 @@ class DumpNodeTest extends TestCase { $node = new DumpNode('bar', null, 7); - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); + $env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()); $compiler = new Compiler($env); $expected = <<<'EOTXT' @@ -48,7 +48,7 @@ EOTXT; { $node = new DumpNode('bar', null, 7); - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); + $env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()); $compiler = new Compiler($env); $expected = <<<'EOTXT' @@ -75,7 +75,7 @@ EOTXT; ]); $node = new DumpNode('bar', $vars, 7); - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); + $env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()); $compiler = new Compiler($env); $expected = <<<'EOTXT' @@ -99,7 +99,7 @@ EOTXT; ]); $node = new DumpNode('bar', $vars, 7); - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); + $env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()); $compiler = new Compiler($env); $expected = <<<'EOTXT' diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index 848685ee5f..99a1e7fde2 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -54,7 +54,7 @@ class FormThemeTest extends TestCase $node = new FormThemeNode($form, $resources, 0); - $environment = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); + $environment = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()); $formRenderer = new FormRenderer($this->getMockBuilder(FormRendererEngineInterface::class)->getMock()); $this->registerTwigRuntimeLoader($environment, $formRenderer); $compiler = new Compiler($environment); diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index fab7d0974c..b7cb678189 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -31,7 +31,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); $this->assertEquals( sprintf( @@ -54,7 +54,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); $this->assertEquals( sprintf( @@ -74,7 +74,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); $this->assertEquals( sprintf( @@ -94,7 +94,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -116,7 +116,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -137,7 +137,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); $this->assertEquals( sprintf( @@ -161,7 +161,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -190,7 +190,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); $this->assertEquals( sprintf( @@ -218,7 +218,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -255,7 +255,7 @@ class SearchAndRenderBlockNodeTest extends TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock())); + $compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock())); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index f974f08580..2acf695e56 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -29,7 +29,7 @@ class TransNodeTest extends TestCase $vars = new NameExpression('foo', 0); $node = new TransNode($body, null, null, $vars); - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]); + $env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['strict_variables' => true]); $compiler = new Compiler($env); $this->assertEquals( diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php index 5abfe1e92a..3f1de5bb1e 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php @@ -26,7 +26,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase /** @dataProvider getDefaultDomainAssignmentTestData */ public function testDefaultDomainAssignment(Node $node) { - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); + $env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag @@ -52,7 +52,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase /** @dataProvider getDefaultDomainAssignmentTestData */ public function testNewModuleWithoutDefaultDomainTag(Node $node) { - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); + $env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php index 11d16e4cd6..57da0628f6 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php @@ -25,7 +25,7 @@ class TranslationNodeVisitorTest extends TestCase /** @dataProvider getMessagesExtractionTestData */ public function testMessagesExtraction(Node $node, array $expectedMessages) { - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); + $env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); $visitor = new TranslationNodeVisitor(); $visitor->enable(); $visitor->enterNode($node, $env); diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php index ce1980eb16..69fb98a631 100644 --- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php @@ -28,7 +28,7 @@ class FormThemeTokenParserTest extends TestCase */ public function testCompile($source, $expected) { - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); + $env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); $env->addTokenParser(new FormThemeTokenParser()); $source = new Source($source, ''); $stream = $env->tokenize($source); diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index dcc704f3d0..21e78322d3 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -26,7 +26,7 @@ class TwigExtractorTest extends TestCase */ public function testExtract($template, $messages) { - $loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(); $twig = new Environment($loader, [ 'strict_variables' => true, 'debug' => true, @@ -102,7 +102,7 @@ class TwigExtractorTest extends TestCase */ public function testExtractSyntaxError($resources, array $messages) { - $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); + $twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()); $twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock())); $extractor = new TwigExtractor($twig); diff --git a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php index f7a7461931..3d15dae98f 100644 --- a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php @@ -26,7 +26,7 @@ class TwigEngineTest extends TestCase { $engine = $this->getTwig(); - $this->assertTrue($engine->exists($this->getMockForAbstractClass('Twig\Template', [], '', false))); + $this->assertTrue($engine->exists($this->getMockForAbstractClass(\Twig\Template::class, [], '', false))); } public function testExistsWithNonExistentTemplates() @@ -63,7 +63,7 @@ class TwigEngineTest extends TestCase public function testRenderWithError() { - $this->expectException('Twig\Error\SyntaxError'); + $this->expectException(\Twig\Error\SyntaxError::class); $engine = $this->getTwig(); $engine->render(new TemplateReference('error')); @@ -75,7 +75,7 @@ class TwigEngineTest extends TestCase 'index' => 'foo', 'error' => '{{ foo }', ])); - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock(); return new TwigEngine($twig, $parser); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php index 0295b4d2e3..b6e5c74a79 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php @@ -82,7 +82,7 @@ EOT new TableSeparator(), ['Version', \PHP_VERSION], ['Architecture', (\PHP_INT_SIZE * 8).' bits'], - ['Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'], + ['Intl locale', class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'], ['Timezone', date_default_timezone_get().' ('.(new \DateTime())->format(\DateTime::W3C).')'], ['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], ['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index f19c7a80ef..06069cae5b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -197,7 +197,7 @@ class FrameworkExtension extends Extension // default in the Form and Validator component). If disabled, an identity // translator will be used and everything will still work as expected. if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) { - if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['translator'])) { + if (!class_exists(Translator::class) && $this->isConfigEnabled($container, $config['translator'])) { throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".'); } @@ -268,14 +268,14 @@ class FrameworkExtension extends Extension $this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader); if ($this->isConfigEnabled($container, $config['form'])) { - if (!class_exists('Symfony\Component\Form\Form')) { + if (!class_exists(\Symfony\Component\Form\Form::class)) { throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".'); } $this->formConfigEnabled = true; $this->registerFormConfiguration($config, $container, $loader); - if (class_exists('Symfony\Component\Validator\Validation')) { + if (class_exists(\Symfony\Component\Validator\Validation::class)) { $config['validation']['enabled'] = true; } else { $container->setParameter('validator.translation_domain', 'validators'); @@ -288,7 +288,7 @@ class FrameworkExtension extends Extension } if ($this->isConfigEnabled($container, $config['assets'])) { - if (!class_exists('Symfony\Component\Asset\Package')) { + if (!class_exists(\Symfony\Component\Asset\Package::class)) { throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".'); } @@ -298,7 +298,7 @@ class FrameworkExtension extends Extension if ($this->isConfigEnabled($container, $config['templating'])) { @trigger_error('Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', \E_USER_DEPRECATED); - if (!class_exists('Symfony\Component\Templating\PhpEngine')) { + if (!class_exists(\Symfony\Component\Templating\PhpEngine::class)) { throw new LogicException('Templating support cannot be enabled as the Templating component is not installed. Try running "composer require symfony/templating".'); } @@ -351,7 +351,7 @@ class FrameworkExtension extends Extension $this->registerSecretsConfiguration($config['secrets'], $container, $loader); if ($this->isConfigEnabled($container, $config['serializer'])) { - if (!class_exists('Symfony\Component\Serializer\Serializer')) { + if (!class_exists(\Symfony\Component\Serializer\Serializer::class)) { throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".'); } @@ -1170,18 +1170,18 @@ class FrameworkExtension extends Extension $dirs = []; $transPaths = []; $nonExistingDirs = []; - if (class_exists('Symfony\Component\Validator\Validation')) { - $r = new \ReflectionClass('Symfony\Component\Validator\Validation'); + if (class_exists(\Symfony\Component\Validator\Validation::class)) { + $r = new \ReflectionClass(\Symfony\Component\Validator\Validation::class); $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations'; } - if (class_exists('Symfony\Component\Form\Form')) { - $r = new \ReflectionClass('Symfony\Component\Form\Form'); + if (class_exists(\Symfony\Component\Form\Form::class)) { + $r = new \ReflectionClass(\Symfony\Component\Form\Form::class); $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations'; } - if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { - $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); + if (class_exists(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)) { + $r = new \ReflectionClass(\Symfony\Component\Security\Core\Exception\AuthenticationException::class); $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations'; } @@ -1281,7 +1281,7 @@ class FrameworkExtension extends Extension return; } - if (!class_exists('Symfony\Component\Validator\Validation')) { + if (!class_exists(\Symfony\Component\Validator\Validation::class)) { throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".'); } @@ -1351,8 +1351,8 @@ class FrameworkExtension extends Extension $files['yaml' === $extension ? 'yml' : $extension][] = $path; }; - if (interface_exists('Symfony\Component\Form\FormInterface')) { - $reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface'); + if (interface_exists(\Symfony\Component\Form\FormInterface::class)) { + $reflClass = new \ReflectionClass(\Symfony\Component\Form\FormInterface::class); $fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml'); } @@ -1413,7 +1413,7 @@ class FrameworkExtension extends Extension return; } - if (!class_exists('Doctrine\Common\Annotations\Annotation')) { + if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) { throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.'); } @@ -1425,7 +1425,7 @@ class FrameworkExtension extends Extension } if ('none' !== $config['cache']) { - if (!class_exists('Doctrine\Common\Cache\CacheProvider')) { + if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) { throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.'); } @@ -1469,7 +1469,7 @@ class FrameworkExtension extends Extension private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { - if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) { + if (!class_exists(PropertyAccessor::class)) { return; } @@ -1523,7 +1523,7 @@ class FrameworkExtension extends Extension return; } - if (!class_exists('Symfony\Component\Security\Csrf\CsrfToken')) { + if (!class_exists(\Symfony\Component\Security\Csrf\CsrfToken::class)) { throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".'); } @@ -1554,7 +1554,7 @@ class FrameworkExtension extends Extension $chainLoader = $container->getDefinition('serializer.mapping.chain_loader'); - if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) { + if (!class_exists(PropertyAccessor::class)) { $container->removeAlias('serializer.property_accessor'); $container->removeDefinition('serializer.normalizer.object'); } @@ -1643,7 +1643,7 @@ class FrameworkExtension extends Extension $loader->load('property_info.xml'); - if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) { + if (interface_exists(\phpDocumentor\Reflection\DocBlockFactoryInterface::class)) { $definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor'); $definition->setPrivate(true); $definition->addTag('property_info.description_extractor', ['priority' => -1000]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php index ca90187a8d..12e1d6fd9a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php @@ -125,7 +125,7 @@ class AnnotationsCacheWarmerTest extends TestCase */ private function getReadOnlyReader() { - $readerMock = $this->getMockBuilder('Doctrine\Common\Annotations\Reader')->getMock(); + $readerMock = $this->getMockBuilder(Reader::class)->getMock(); $readerMock->expects($this->exactly(0))->method('getClassAnnotations'); $readerMock->expects($this->exactly(0))->method('getClassAnnotation'); $readerMock->expects($this->exactly(0))->method('getMethodAnnotations'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php index 52b8dfad9d..267fe7d7b9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php @@ -24,7 +24,7 @@ class TemplateFinderTest extends TestCase public function testFindAllTemplates() { $kernel = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') + ->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class) ->disableOriginalConstructor() ->getMock() ; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php index aa70e4ed80..796d004fdf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php @@ -89,7 +89,7 @@ class CachePoolDeleteCommandTest extends TestCase private function getKernel() { $container = $this - ->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface') + ->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class) ->getMock(); $kernel = $this diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php index 251e8f3340..f8106d2ef1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php @@ -55,7 +55,7 @@ class CachePruneCommandTest extends TestCase private function getKernel() { $container = $this - ->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface') + ->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class) ->getMock(); $kernel = $this diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php index 2505d07881..ef59d07d7b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php @@ -55,7 +55,7 @@ class RouterMatchCommandTest extends TestCase $routeCollection = new RouteCollection(); $routeCollection->add('foo', new Route('foo')); $requestContext = new RequestContext(); - $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); + $router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock(); $router ->expects($this->any()) ->method('getRouteCollection') @@ -70,7 +70,7 @@ class RouterMatchCommandTest extends TestCase private function getKernel() { - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock(); $container ->expects($this->atLeastOnce()) ->method('has') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index 733dca5a42..8f779bb42b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -101,7 +101,7 @@ class TranslationDebugCommandTest extends TestCase { $this->fs->mkdir($this->translationDir.'/customDir/translations'); $this->fs->mkdir($this->translationDir.'/customDir/templates'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel->expects($this->once()) ->method('getBundle') ->with($this->equalTo($this->translationDir.'/customDir')) @@ -116,8 +116,8 @@ class TranslationDebugCommandTest extends TestCase public function testDebugInvalidDirectory() { - $this->expectException('InvalidArgumentException'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $this->expectException(\InvalidArgumentException::class); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel->expects($this->once()) ->method('getBundle') ->with($this->equalTo('dir')) @@ -142,7 +142,7 @@ class TranslationDebugCommandTest extends TestCase private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester { - $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') + $translator = $this->getMockBuilder(\Symfony\Component\Translation\Translator::class) ->disableOriginalConstructor() ->getMock(); @@ -151,7 +151,7 @@ class TranslationDebugCommandTest extends TestCase ->method('getFallbackLocales') ->willReturn(['en']); - $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); + $extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock(); $extractor ->expects($this->any()) ->method('extract') @@ -161,7 +161,7 @@ class TranslationDebugCommandTest extends TestCase } ); - $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock(); $loader ->expects($this->any()) ->method('read') @@ -182,7 +182,7 @@ class TranslationDebugCommandTest extends TestCase ['test', true, $this->getBundle('test')], ]; } - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel ->expects($this->any()) ->method('getBundle') @@ -212,7 +212,7 @@ class TranslationDebugCommandTest extends TestCase private function getBundle($path) { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock(); $bundle ->expects($this->any()) ->method('getPath') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index bf8d302282..2e9ca1297e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -154,7 +154,7 @@ class TranslationUpdateCommandTest extends TestCase */ private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = []) { - $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') + $translator = $this->getMockBuilder(\Symfony\Component\Translation\Translator::class) ->disableOriginalConstructor() ->getMock(); @@ -163,7 +163,7 @@ class TranslationUpdateCommandTest extends TestCase ->method('getFallbackLocales') ->willReturn(['en']); - $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); + $extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock(); $extractor ->expects($this->any()) ->method('extract') @@ -175,7 +175,7 @@ class TranslationUpdateCommandTest extends TestCase } ); - $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock(); $loader ->expects($this->any()) ->method('read') @@ -185,7 +185,7 @@ class TranslationUpdateCommandTest extends TestCase } ); - $writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock(); + $writer = $this->getMockBuilder(\Symfony\Component\Translation\Writer\TranslationWriter::class)->getMock(); $writer ->expects($this->any()) ->method('getFormats') @@ -204,7 +204,7 @@ class TranslationUpdateCommandTest extends TestCase ['test', true, $this->getBundle('test')], ]; } - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel ->expects($this->any()) ->method('getBundle') @@ -233,7 +233,7 @@ class TranslationUpdateCommandTest extends TestCase private function getBundle($path) { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock(); $bundle ->expects($this->any()) ->method('getPath') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php index 29947983f4..7031270246 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php @@ -60,7 +60,7 @@ bar'; public function testLintFileNotReadable() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $tester = $this->createCommandTester(); $filename = $this->createFile(''); unlink($filename); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php index ca99d56e15..e4aae37843 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php @@ -30,7 +30,7 @@ class ApplicationTest extends TestCase { public function testBundleInterfaceImplementation() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock(); $kernel = $this->getKernel([$bundle], true); @@ -110,7 +110,7 @@ class ApplicationTest extends TestCase */ public function testBundleCommandsHaveRightContainer() { - $command = $this->getMockForAbstractClass('Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand', ['foo'], '', true, true, true, ['setContainer']); + $command = $this->getMockForAbstractClass(\Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand::class, ['foo'], '', true, true, true, ['setContainer']); $command->setCode(function () {}); $command->expects($this->exactly(2))->method('setContainer'); @@ -259,10 +259,10 @@ class ApplicationTest extends TestCase private function getKernel(array $bundles, $useDispatcher = false) { - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock(); if ($useDispatcher) { - $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); $dispatcher ->expects($this->atLeastOnce()) ->method('dispatch') @@ -287,7 +287,7 @@ class ApplicationTest extends TestCase ->willReturnOnConsecutiveCalls([], []) ; - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); $kernel->expects($this->once())->method('boot'); $kernel ->expects($this->any()) @@ -305,7 +305,7 @@ class ApplicationTest extends TestCase private function createBundleMock(array $commands) { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); $bundle ->expects($this->once()) ->method('registerCommands') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 8d677220f1..15f7222ae0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -68,7 +68,7 @@ class AbstractControllerTest extends ControllerTraitTest public function testMissingParameterBag() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->expectExceptionMessage('TestAbstractController::getParameter()" method is missing a parameter bag'); $container = new Container(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php index 35580abaad..dcf8a2f1de 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php @@ -151,7 +151,7 @@ class ControllerNameParserTest extends TestCase 'FooBundle' => $this->getBundle('TestBundle\FooBundle', 'FooBundle'), ]; - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel ->expects($this->any()) ->method('getBundle') @@ -180,7 +180,7 @@ class ControllerNameParserTest extends TestCase private function getBundle($namespace, $name) { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock(); $bundle->expects($this->any())->method('getName')->willReturn($name); $bundle->expects($this->any())->method('getNamespace')->willReturn($namespace); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php index 3eea42c24e..17eaa278b3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php @@ -32,8 +32,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller[0]); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller[0]->getContainer()); + $this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller[0]); + $this->assertInstanceOf(ContainerInterface::class, $controller[0]->getContainer()); $this->assertSame('testAction', $controller[1]); } @@ -45,8 +45,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller->getContainer()); + $this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller); + $this->assertInstanceOf(ContainerInterface::class, $controller->getContainer()); } /** @@ -69,8 +69,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller[0]); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller[0]->getContainer()); + $this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller[0]); + $this->assertInstanceOf(ContainerInterface::class, $controller[0]->getContainer()); $this->assertSame('testAction', $controller[1]); } @@ -200,12 +200,12 @@ class ControllerResolverTest extends ContainerControllerResolverTest protected function createMockParser() { - return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser')->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(ControllerNameParser::class)->disableOriginalConstructor()->getMock(); } protected function createMockContainer() { - return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + return $this->getMockBuilder(ContainerInterface::class)->getMock(); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php index cf7cc5afea..6645ca7aaa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php @@ -43,7 +43,7 @@ abstract class ControllerTraitTest extends TestCase $requestStack = new RequestStack(); $requestStack->push($request); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat().'--'.$request->getLocale()); }); @@ -90,7 +90,7 @@ abstract class ControllerTraitTest extends TestCase public function testGetUserWithEmptyContainer() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('The SecurityBundle is not registered in your application.'); $controller = $this->createController(); $controller->setContainer(new Container()); @@ -100,7 +100,7 @@ abstract class ControllerTraitTest extends TestCase private function getContainerWithTokenStorage($token = null): Container { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::class)->getMock(); $tokenStorage ->expects($this->once()) ->method('getToken') @@ -169,7 +169,7 @@ abstract class ControllerTraitTest extends TestCase public function testFile() { $container = new Container(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); $container->set('http_kernel', $kernel); $controller = $this->createController(); @@ -270,7 +270,7 @@ abstract class ControllerTraitTest extends TestCase public function testFileWhichDoesNotExist() { - $this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); + $this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class); $controller = $this->createController(); $controller->file('some-file.txt', 'test.php'); @@ -278,7 +278,7 @@ abstract class ControllerTraitTest extends TestCase public function testIsGranted() { - $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); + $authorizationChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class)->getMock(); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true); $container = new Container(); @@ -292,8 +292,8 @@ abstract class ControllerTraitTest extends TestCase public function testdenyAccessUnlessGranted() { - $this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException'); - $authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); + $this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class); + $authorizationChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class)->getMock(); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false); $container = new Container(); @@ -307,7 +307,7 @@ abstract class ControllerTraitTest extends TestCase public function testRenderViewTwig() { - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock(); $twig->expects($this->once())->method('render')->willReturn('bar'); $container = new Container(); @@ -321,7 +321,7 @@ abstract class ControllerTraitTest extends TestCase public function testRenderTwig() { - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock(); $twig->expects($this->once())->method('render')->willReturn('bar'); $container = new Container(); @@ -335,7 +335,7 @@ abstract class ControllerTraitTest extends TestCase public function testStreamTwig() { - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock(); $container = new Container(); $container->set('twig', $twig); @@ -343,12 +343,12 @@ abstract class ControllerTraitTest extends TestCase $controller = $this->createController(); $controller->setContainer($container); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo')); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\StreamedResponse::class, $controller->stream('foo')); } public function testRedirectToRoute() { - $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); + $router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock(); $router->expects($this->once())->method('generate')->willReturn('/foo'); $container = new Container(); @@ -358,7 +358,7 @@ abstract class ControllerTraitTest extends TestCase $controller->setContainer($container); $response = $controller->redirectToRoute('foo'); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response); $this->assertSame('/foo', $response->getTargetUrl()); $this->assertSame(302, $response->getStatusCode()); } @@ -369,7 +369,7 @@ abstract class ControllerTraitTest extends TestCase public function testAddFlash() { $flashBag = new FlashBag(); - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock(); + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class)->getMock(); $session->expects($this->once())->method('getFlashBag')->willReturn($flashBag); $container = new Container(); @@ -386,12 +386,12 @@ abstract class ControllerTraitTest extends TestCase { $controller = $this->createController(); - $this->assertInstanceOf('Symfony\Component\Security\Core\Exception\AccessDeniedException', $controller->createAccessDeniedException()); + $this->assertInstanceOf(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class, $controller->createAccessDeniedException()); } public function testIsCsrfTokenValid() { - $tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); + $tokenManager = $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock(); $tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true); $container = new Container(); @@ -405,7 +405,7 @@ abstract class ControllerTraitTest extends TestCase public function testGenerateUrl() { - $router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); + $router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock(); $router->expects($this->once())->method('generate')->willReturn('/foo'); $container = new Container(); @@ -422,7 +422,7 @@ abstract class ControllerTraitTest extends TestCase $controller = $this->createController(); $response = $controller->redirect('https://dunglas.fr', 301); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response); $this->assertSame('https://dunglas.fr', $response->getTargetUrl()); $this->assertSame(301, $response->getStatusCode()); } @@ -432,7 +432,7 @@ abstract class ControllerTraitTest extends TestCase */ public function testRenderViewTemplating() { - $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); + $templating = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock(); $templating->expects($this->once())->method('render')->willReturn('bar'); $container = new Container(); @@ -449,7 +449,7 @@ abstract class ControllerTraitTest extends TestCase */ public function testRenderTemplating() { - $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); + $templating = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock(); $templating->expects($this->once())->method('render')->willReturn('bar'); $container = new Container(); @@ -466,7 +466,7 @@ abstract class ControllerTraitTest extends TestCase */ public function testStreamTemplating() { - $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); + $templating = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock(); $container = new Container(); $container->set('templating', $templating); @@ -474,21 +474,21 @@ abstract class ControllerTraitTest extends TestCase $controller = $this->createController(); $controller->setContainer($container); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo')); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\StreamedResponse::class, $controller->stream('foo')); } public function testCreateNotFoundException() { $controller = $this->createController(); - $this->assertInstanceOf('Symfony\Component\HttpKernel\Exception\NotFoundHttpException', $controller->createNotFoundException()); + $this->assertInstanceOf(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class, $controller->createNotFoundException()); } public function testCreateForm() { $form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock()); - $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $formFactory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(); $formFactory->expects($this->once())->method('create')->willReturn($form); $container = new Container(); @@ -502,9 +502,9 @@ abstract class ControllerTraitTest extends TestCase public function testCreateFormBuilder() { - $formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilderInterface')->getMock(); + $formBuilder = $this->getMockBuilder(\Symfony\Component\Form\FormBuilderInterface::class)->getMock(); - $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $formFactory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(); $formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder); $container = new Container(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php index 0eeb029384..b746492bf5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php @@ -22,7 +22,7 @@ class TemplateControllerTest extends TestCase { public function testTwig() { - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock(); $twig->expects($this->exactly(2))->method('render')->willReturn('bar'); $controller = new TemplateController($twig); @@ -47,7 +47,7 @@ class TemplateControllerTest extends TestCase public function testNoTwigNorTemplating() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.'); $controller = new TemplateController(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php index 6bc90a478f..55a92488d5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php @@ -113,7 +113,7 @@ class CachePoolPassTest extends TestCase public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are'); $container = new ContainerBuilder(); $container->setParameter('kernel.container_class', 'app'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php index b47dc907c3..44c2909cf6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php @@ -61,7 +61,7 @@ class CachePoolPrunerPassTest extends TestCase public function testCompilerPassThrowsOnInvalidDefinitionClass() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found.'); $container = new ContainerBuilder(); $container->register('console.command.cache_pool_prune')->addArgument([]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index 99299282aa..17ffbd2347 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -27,7 +27,7 @@ class ProfilerPassTest extends TestCase */ public function testTemplateNoIdThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $builder = new ContainerBuilder(); $builder->register('profiler', 'ProfilerClass'); $builder->register('my_collector_service') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/WorkflowGuardListenerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/WorkflowGuardListenerPassTest.php index cab03fd9c8..32ca959032 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/WorkflowGuardListenerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/WorkflowGuardListenerPassTest.php @@ -54,7 +54,7 @@ class WorkflowGuardListenerPassTest extends TestCase public function testExceptionIfTheTokenStorageServiceIsNotPresent() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class); $this->expectExceptionMessage('The "security.token_storage" service is needed to be able to use the workflow guard listener.'); $this->container->setParameter('workflow.has_guard_listeners', true); $this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class); @@ -66,7 +66,7 @@ class WorkflowGuardListenerPassTest extends TestCase public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class); $this->expectExceptionMessage('The "security.authorization_checker" service is needed to be able to use the workflow guard listener.'); $this->container->setParameter('workflow.has_guard_listeners', true); $this->container->register('security.token_storage', TokenStorageInterface::class); @@ -78,7 +78,7 @@ class WorkflowGuardListenerPassTest extends TestCase public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class); $this->expectExceptionMessage('The "security.authentication.trust_resolver" service is needed to be able to use the workflow guard listener.'); $this->container->setParameter('workflow.has_guard_listeners', true); $this->container->register('security.token_storage', TokenStorageInterface::class); @@ -90,7 +90,7 @@ class WorkflowGuardListenerPassTest extends TestCase public function testExceptionIfTheRoleHierarchyServiceIsNotPresent() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class); $this->expectExceptionMessage('The "security.role_hierarchy" service is needed to be able to use the workflow guard listener.'); $this->container->setParameter('workflow.has_guard_listeners', true); $this->container->register('security.token_storage', TokenStorageInterface::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index e9efb76967..e4d36c522f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -66,7 +66,7 @@ class ConfigurationTest extends TestCase */ public function testInvalidSessionName($sessionName) { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(InvalidConfigurationException::class); $processor = new Processor(); $processor->processConfiguration( new Configuration(true), diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 7b56e404df..7f6d841315 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -127,7 +127,7 @@ abstract class FrameworkExtensionTest extends TestCase public function testCsrfProtectionNeedsSessionToBeEnabled() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('CSRF protection needs sessions to be enabled.'); $this->createContainerFromFile('csrf_needs_session'); } @@ -167,7 +167,7 @@ abstract class FrameworkExtensionTest extends TestCase */ public function testAmbiguousWhenBothTemplatingAndFragments() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->createContainerFromFile('template_and_fragments'); } @@ -331,28 +331,28 @@ abstract class FrameworkExtensionTest extends TestCase public function testWorkflowAreValidated() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "go" from place/state "first" were found on StateMachine "my_workflow".'); $this->createContainerFromFile('workflow_not_valid'); } public function testWorkflowCannotHaveBothTypeAndService() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('"type" and "service" cannot be used together.'); $this->createContainerFromFile('workflow_legacy_with_type_and_service'); } public function testWorkflowCannotHaveBothSupportsAndSupportStrategy() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('"supports" and "support_strategy" cannot be used together.'); $this->createContainerFromFile('workflow_with_support_and_support_strategy'); } public function testWorkflowShouldHaveOneOfSupportsAndSupportStrategy() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('"supports" or "support_strategy" should be configured.'); $this->createContainerFromFile('workflow_without_support_and_support_strategy'); } @@ -362,7 +362,7 @@ abstract class FrameworkExtensionTest extends TestCase */ public function testWorkflowCannotHaveBothArgumentsAndService() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('"arguments" and "service" cannot be used together.'); $this->createContainerFromFile('workflow_legacy_with_arguments_and_service'); } @@ -524,7 +524,7 @@ abstract class FrameworkExtensionTest extends TestCase public function testRouterRequiresResourceOption() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $container = $this->createContainer(); $loader = new FrameworkExtension(); $loader->load([['router' => true]], $container); @@ -815,14 +815,14 @@ abstract class FrameworkExtensionTest extends TestCase public function testMessengerMiddlewareFactoryErroneousFormat() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid middleware at path "framework.messenger": a map with a single factory id as key and its arguments as value was expected, {"foo":["qux"],"bar":["baz"]} given.'); $this->createContainerFromFile('messenger_middleware_factory_erroneous_format'); } public function testMessengerInvalidTransportRouting() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Invalid Messenger routing configuration: the "Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage" class is being routed to a sender called "invalid". This is not a valid transport or service id.'); $this->createContainerFromFile('messenger_routing_invalid_transport'); } @@ -838,19 +838,19 @@ abstract class FrameworkExtensionTest extends TestCase $this->assertSame($container->getParameter('kernel.cache_dir').'/translations', $options['cache_dir']); $files = array_map('realpath', $options['resource_files']['en']); - $ref = new \ReflectionClass('Symfony\Component\Validator\Validation'); + $ref = new \ReflectionClass(\Symfony\Component\Validator\Validation::class); $this->assertContains( strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Validator translation resources' ); - $ref = new \ReflectionClass('Symfony\Component\Form\Form'); + $ref = new \ReflectionClass(\Symfony\Component\Form\Form::class); $this->assertContains( strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Form translation resources' ); - $ref = new \ReflectionClass('Symfony\Component\Security\Core\Security'); + $ref = new \ReflectionClass(\Symfony\Component\Security\Core\Security::class); $this->assertContains( strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', \DIRECTORY_SEPARATOR), $files, @@ -921,7 +921,7 @@ abstract class FrameworkExtensionTest extends TestCase */ public function testTemplatingRequiresAtLeastOneEngine() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $container = $this->createContainer(); $loader = new FrameworkExtension(); $loader->load([['templating' => null]], $container); @@ -932,7 +932,7 @@ abstract class FrameworkExtensionTest extends TestCase $container = $this->createContainerFromFile('full'); $projectDir = $container->getParameter('kernel.project_dir'); - $ref = new \ReflectionClass('Symfony\Component\Form\Form'); + $ref = new \ReflectionClass(\Symfony\Component\Form\Form::class); $xmlMappings = [ \dirname($ref->getFileName()).'/Resources/config/validation.xml', strtr($projectDir.'/config/validator/foo.xml', '/', \DIRECTORY_SEPARATOR), @@ -969,7 +969,7 @@ abstract class FrameworkExtensionTest extends TestCase { $container = $this->createContainerFromFile('validation_annotations', ['kernel.charset' => 'UTF-8'], false); - $this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator')); + $this->assertInstanceOf(\Symfony\Component\Validator\Validator\ValidatorInterface::class, $container->get('validator')); } public function testAnnotations() @@ -1097,7 +1097,7 @@ abstract class FrameworkExtensionTest extends TestCase */ public function testCannotConfigureStrictEmailAndEmailValidationModeAtTheSameTime() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('"strict_email" and "email_validation_mode" cannot be used together.'); $this->createContainerFromFile('validation_strict_email_and_validation_mode'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index da540da12b..0212e662c3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -25,7 +25,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest public function testAssetsCannotHavePathAndUrl() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', [ 'assets' => [ @@ -38,7 +38,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest public function testAssetPackageCannotHavePathAndUrl() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', [ 'assets' => [ @@ -55,7 +55,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest public function testWorkflowValidationStateMachine() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "a_to_b" from place/state "a" were found on StateMachine "article".'); $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', [ @@ -157,7 +157,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest */ public function testWorkflowValidationSingleState() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('The marking store of workflow "article" can not store many places. But the transition "a_to_b" has too many output (2). Only one is accepted.'); $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', [ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php index 01a99c2f37..c3f56f1e4d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php @@ -67,7 +67,7 @@ class CachePoolClearCommandTest extends AbstractWebTestCase public function testClearUnexistingPool() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->expectExceptionMessage('You have requested a non-existent service "unknown_pool"'); $this->createCommandTester() ->execute(['pools' => ['unknown_pool']], ['decorated' => false]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php index 22114349d5..b7cf74798a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php @@ -63,7 +63,7 @@ class RouterDebugCommandTest extends AbstractWebTestCase public function testSearchWithThrow() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The route "gerard" does not exist.'); $tester = $this->createCommandTester(); $tester->execute(['name' => 'gerard'], ['interactive' => true]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php index dd909ea6fc..4d7a11ea62 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php @@ -29,7 +29,7 @@ class MicroKernelTraitTest extends TestCase $this->assertEquals('halloween', $response->getContent()); $this->assertEquals('Have a great day!', $kernel->getContainer()->getParameter('halloween')); - $this->assertInstanceOf('stdClass', $kernel->getContainer()->get('halloween')); + $this->assertInstanceOf(\stdClass::class, $kernel->getContainer()->get('halloween')); } public function testAsEventSubscriber() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 1e6578929c..6cf4cf3fad 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -25,7 +25,7 @@ class RouterTest extends TestCase { public function testConstructThrowsOnNonSymfonyNorPsr11Container() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('You should either pass a "Symfony\Component\DependencyInjection\ContainerInterface" instance or provide the $parameters argument of the "Symfony\Bundle\FrameworkBundle\Routing\Router::__construct" method'); new Router($this->createMock(ContainerInterface::class), 'foo'); } @@ -293,7 +293,7 @@ class RouterTest extends TestCase public function testEnvPlaceholders() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.'); $routes = new RouteCollection(); @@ -305,7 +305,7 @@ class RouterTest extends TestCase public function testEnvPlaceholdersWithSfContainer() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.'); $routes = new RouteCollection(); @@ -375,7 +375,7 @@ class RouterTest extends TestCase public function testExceptionOnNonExistentParameterWithSfContainer() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException::class); $this->expectExceptionMessage('You have requested a non-existent parameter "nope".'); $routes = new RouteCollection(); @@ -389,7 +389,7 @@ class RouterTest extends TestCase public function testExceptionOnNonStringParameter() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".'); $routes = new RouteCollection(); @@ -404,7 +404,7 @@ class RouterTest extends TestCase public function testExceptionOnNonStringParameterWithSfContainer() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".'); $routes = new RouteCollection(); @@ -504,7 +504,7 @@ class RouterTest extends TestCase private function getServiceContainer(RouteCollection $routes): Container { - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); $loader ->expects($this->any()) @@ -512,7 +512,7 @@ class RouterTest extends TestCase ->willReturn($routes) ; - $sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock(); + $sc = $this->getMockBuilder(Container::class)->setMethods(['get'])->getMock(); $sc ->expects($this->once()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php index 1d3eaf3691..344920d851 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php @@ -49,7 +49,7 @@ class DelegatingEngineTest extends TestCase public function testGetInvalidEngine() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('No engine is able to work with the template "template.php"'); $firstEngine = $this->getEngineMock('template.php', false); $secondEngine = $this->getEngineMock('template.php', false); @@ -83,12 +83,12 @@ class DelegatingEngineTest extends TestCase $container = $this->getContainerMock(['engine' => $engine]); $delegatingEngine = new DelegatingEngine($container, ['engine']); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $delegatingEngine->renderResponse('template.php', ['foo' => 'bar'])); + $this->assertInstanceOf(Response::class, $delegatingEngine->renderResponse('template.php', ['foo' => 'bar'])); } private function getEngineMock($template, $supports) { - $engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock(); + $engine = $this->getMockBuilder(\Symfony\Component\Templating\EngineInterface::class)->getMock(); $engine->expects($this->once()) ->method('supports') @@ -100,7 +100,7 @@ class DelegatingEngineTest extends TestCase private function getFrameworkEngineMock($template, $supports) { - $engine = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); + $engine = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock(); $engine->expects($this->once()) ->method('supports') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php index a892ebeddc..5795b2528f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php @@ -36,14 +36,14 @@ class GlobalVariablesTest extends TestCase public function testGetTokenNoToken() { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $this->container->set('security.token_storage', $tokenStorage); $this->assertNull($this->globals->getToken()); } public function testGetToken() { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $this->container->set('security.token_storage', $tokenStorage); @@ -62,7 +62,7 @@ class GlobalVariablesTest extends TestCase public function testGetUserNoToken() { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $this->container->set('security.token_storage', $tokenStorage); $this->assertNull($this->globals->getUser()); } @@ -72,8 +72,8 @@ class GlobalVariablesTest extends TestCase */ public function testGetUser($user, $expectedUser) { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $this->container->set('security.token_storage', $tokenStorage); @@ -92,9 +92,9 @@ class GlobalVariablesTest extends TestCase public function getUserProvider() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $std = new \stdClass(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); return [ [$user, $user], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php index c277cf8e06..2e2e449327 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php @@ -36,7 +36,7 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest { // should be moved to the Form component once absolute file paths are supported // by the default name parser in the Templating component - $reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle'); + $reflClass = new \ReflectionClass(\Symfony\Bundle\FrameworkBundle\FrameworkBundle::class); $root = realpath(\dirname($reflClass->getFileName()).'/Resources/views'); $rootTheme = realpath(__DIR__.'/Resources'); $templateNameParser = new StubTemplateNameParser($root, $rootTheme); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php index e2c21f8bdd..6bc09530e6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php @@ -80,7 +80,7 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest { // should be moved to the Form component once absolute file paths are supported // by the default name parser in the Templating component - $reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle'); + $reflClass = new \ReflectionClass(\Symfony\Bundle\FrameworkBundle\FrameworkBundle::class); $root = realpath(\dirname($reflClass->getFileName()).'/Resources/views'); $rootTheme = realpath(__DIR__.'/Resources'); $templateNameParser = new StubTemplateNameParser($root, $rootTheme); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php index f5030b4e79..3794e047b9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php @@ -21,7 +21,7 @@ class StopwatchHelperTest extends TestCase { public function testDevEnvironment() { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); + $stopwatch = $this->getMockBuilder(\Symfony\Component\Stopwatch\Stopwatch::class)->getMock(); $stopwatch->expects($this->once()) ->method('start') ->with('foo'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php index 63581e131e..fe66fda7aa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php @@ -82,7 +82,7 @@ class TemplateLocatorTest extends TestCase public function testThrowsAnExceptionWhenTemplateIsNotATemplateReferenceInterface() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $locator = new TemplateLocator($this->getFileLocator()); $locator->locate('template'); } @@ -90,7 +90,7 @@ class TemplateLocatorTest extends TestCase protected function getFileLocator() { return $this - ->getMockBuilder('Symfony\Component\Config\FileLocator') + ->getMockBuilder(\Symfony\Component\Config\FileLocator::class) ->setMethods(['locate']) ->setConstructorArgs(['/path/to/fallback']) ->getMock() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php index 77cbeb5998..2f1a19cc68 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php @@ -29,7 +29,7 @@ class PhpEngineTest extends TestCase public function testEvaluateAddsAppGlobal() { $container = $this->getContainer(); - $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); + $loader = $this->getMockForAbstractClass(\Symfony\Component\Templating\Loader\Loader::class); $engine = new PhpEngine(new TemplateNameParser(), $container, $loader, $app = new GlobalVariables($container)); $globals = $engine->getGlobals(); $this->assertSame($app, $globals['app']); @@ -38,7 +38,7 @@ class PhpEngineTest extends TestCase public function testEvaluateWithoutAvailableRequest() { $container = new Container(); - $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); + $loader = $this->getMockForAbstractClass(\Symfony\Component\Templating\Loader\Loader::class); $engine = new PhpEngine(new TemplateNameParser(), $container, $loader, new GlobalVariables($container)); $this->assertFalse($container->has('request_stack')); @@ -48,9 +48,9 @@ class PhpEngineTest extends TestCase public function testGetInvalidHelper() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $container = $this->getContainer(); - $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); + $loader = $this->getMockForAbstractClass(\Symfony\Component\Templating\Loader\Loader::class); $engine = new PhpEngine(new TemplateNameParser(), $container, $loader); $engine->get('non-existing-helper'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index d3e8272d22..76fc7b91bc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php @@ -25,7 +25,7 @@ class TemplateNameParserTest extends TestCase protected function setUp(): void { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel ->expects($this->any()) ->method('getBundle') @@ -79,7 +79,7 @@ class TemplateNameParserTest extends TestCase public function testParseValidNameWithNotFoundBundle() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->parser->parse('BarBundle:Post:index.html.php'); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php index 2e9ca7e650..ed7d87b305 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php @@ -49,13 +49,13 @@ class TimedPhpEngineTest extends TestCase private function getContainer(): Container { - return $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')->getMock(); + return $this->getMockBuilder(Container::class)->getMock(); } private function getTemplateNameParser(): TemplateNameParserInterface { - $templateReference = $this->getMockBuilder('Symfony\Component\Templating\TemplateReferenceInterface')->getMock(); - $templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $templateReference = $this->getMockBuilder(\Symfony\Component\Templating\TemplateReferenceInterface::class)->getMock(); + $templateNameParser = $this->getMockBuilder(TemplateNameParserInterface::class)->getMock(); $templateNameParser->expects($this->any()) ->method('parse') ->willReturn($templateReference); @@ -65,14 +65,14 @@ class TimedPhpEngineTest extends TestCase private function getGlobalVariables(): GlobalVariables { - return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables') + return $this->getMockBuilder(GlobalVariables::class) ->disableOriginalConstructor() ->getMock(); } private function getStorage(): StringStorage { - return $this->getMockBuilder('Symfony\Component\Templating\Storage\StringStorage') + return $this->getMockBuilder(StringStorage::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); } @@ -82,7 +82,7 @@ class TimedPhpEngineTest extends TestCase */ private function getLoader($storage): Loader { - $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); + $loader = $this->getMockForAbstractClass(Loader::class); $loader->expects($this->once()) ->method('load') ->willReturn($storage); @@ -92,13 +92,13 @@ class TimedPhpEngineTest extends TestCase private function getStopwatchEvent(): StopwatchEvent { - return $this->getMockBuilder('Symfony\Component\Stopwatch\StopwatchEvent') + return $this->getMockBuilder(StopwatchEvent::class) ->disableOriginalConstructor() ->getMock(); } private function getStopwatch(): Stopwatch { - return $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); + return $this->getMockBuilder(Stopwatch::class)->getMock(); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index db0e6dc5d3..0ff5b7915b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -94,7 +94,7 @@ class TranslatorTest extends TestCase $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); // do it another time as the cache is primed now - $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock(); $loader->expects($this->never())->method('load'); $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]); @@ -124,7 +124,7 @@ class TranslatorTest extends TestCase $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); // do it another time as the cache is primed now - $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock(); $loader->expects($this->never())->method('load'); $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]); @@ -137,9 +137,9 @@ class TranslatorTest extends TestCase public function testTransWithCachingWithInvalidLocale() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "invalid locale" locale.'); - $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock(); $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', TranslatorWithInvalidLocale::class); $translator->trans('foo'); @@ -170,9 +170,9 @@ class TranslatorTest extends TestCase public function testInvalidOptions() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The Translator does not support the following options: \'foo\''); - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock(); (new Translator($container, new MessageFormatter(), 'en', [], ['foo' => 'bar'])); } @@ -182,7 +182,7 @@ class TranslatorTest extends TestCase { $someCatalogue = $this->getCatalogue('some_locale', []); - $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock(); $loader->expects($this->exactly(2)) ->method('load') @@ -300,7 +300,7 @@ class TranslatorTest extends TestCase protected function getLoader() { - $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock(); $loader ->expects($this->exactly(7)) ->method('load') @@ -336,7 +336,7 @@ class TranslatorTest extends TestCase protected function getContainer($loader) { - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock(); $container ->expects($this->any()) ->method('get') @@ -377,7 +377,7 @@ class TranslatorTest extends TestCase $translator->setFallbackLocales(['fr']); $translator->warmup($this->tmpDir); - $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock(); $loader ->expects($this->never()) ->method('load'); diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index ab56ce26b9..365638dc4a 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -115,7 +115,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface $loader->load('security_debug.xml'); } - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) { $container->removeDefinition('security.expression_language'); $container->removeDefinition('security.access.expression_voter'); } @@ -707,7 +707,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface return $this->expressions[$id]; } - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) { throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php index 65ab44566e..62e1c9cfcf 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php @@ -24,7 +24,7 @@ class AddSecurityVotersPassTest extends TestCase { public function testNoVoters() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); + $this->expectException(LogicException::class); $this->expectExceptionMessage('No security voters found. You need to tag at least one with "security.voter".'); $container = new ContainerBuilder(); $container diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index 6eca98ae70..bc70434f83 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -610,7 +610,7 @@ abstract class CompleteConfigurationTest extends TestCase public function testAccessDecisionManagerServiceAndStrategyCannotBeUsedAtTheSameTime() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('Invalid configuration for path "security.access_decision_manager": "strategy" and "service" cannot be used together.'); $this->getContainer('access_decision_manager_service_and_strategy'); } @@ -628,14 +628,14 @@ abstract class CompleteConfigurationTest extends TestCase public function testFirewallUndefinedUserProvider() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.'); $this->getContainer('firewall_undefined_provider'); } public function testFirewallListenerUndefinedProvider() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.'); $this->getContainer('listener_undefined_provider'); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php index ebbe0c65e7..86971c38c9 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php @@ -34,7 +34,7 @@ class MainConfigurationTest extends TestCase public function testNoConfigForProvider() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $config = [ 'providers' => [ 'stub' => [], @@ -48,7 +48,7 @@ class MainConfigurationTest extends TestCase public function testManyConfigForProvider() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $config = [ 'providers' => [ 'stub' => [ diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php index 3360863159..c16539d0c5 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php @@ -127,7 +127,7 @@ class AbstractFactoryTest extends TestCase protected function callFactory($id, $config, $userProviderId, $defaultEntryPointId) { - $factory = $this->getMockForAbstractClass('Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory', []); + $factory = $this->getMockForAbstractClass(\Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory::class, []); $factory ->expects($this->once()) diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php index c1f3669c11..a28bed4f5c 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php @@ -41,7 +41,7 @@ class GuardAuthenticationFactoryTest extends TestCase */ public function testAddInvalidConfiguration(array $inputConfig) { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $factory = new GuardAuthenticationFactory(); $nodeDefinition = new ArrayNodeDefinition('guard'); $factory->addConfiguration($nodeDefinition); @@ -132,7 +132,7 @@ class GuardAuthenticationFactoryTest extends TestCase public function testCannotOverrideDefaultEntryPoint() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); // any existing default entry point is used $config = [ 'authenticators' => ['authenticator123'], @@ -143,7 +143,7 @@ class GuardAuthenticationFactoryTest extends TestCase public function testMultipleAuthenticatorsRequiresEntryPoint() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); // any existing default entry point is used $config = [ 'authenticators' => ['authenticator123', 'authenticatorABC'], diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 35a1930158..e3d4642190 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -26,7 +26,7 @@ class SecurityExtensionTest extends TestCase { public function testInvalidCheckPath() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The check_path "/some_area/login_check" for login method "form_login" is not matched by the firewall pattern "/secured_area/.*".'); $container = $this->getRawContainer(); @@ -50,7 +50,7 @@ class SecurityExtensionTest extends TestCase public function testFirewallWithoutAuthenticationListener() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('No authentication listener registered for firewall "some_firewall"'); $container = $this->getRawContainer(); @@ -71,7 +71,7 @@ class SecurityExtensionTest extends TestCase public function testFirewallWithInvalidUserProvider() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('Unable to create definition for "security.user.provider.concrete.my_foo" user provider'); $container = $this->getRawContainer(); @@ -190,7 +190,7 @@ class SecurityExtensionTest extends TestCase public function testMissingProviderForListener() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('Not configuring explicitly the provider for the "http_basic" listener on "ambiguous" firewall is ambiguous as there is more than one registered provider.'); $container = $this->getRawContainer(); $container->loadFromExtension('security', [ diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php index b6245286a8..bd94f4d2d6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php @@ -298,7 +298,7 @@ EOTXT public function testThrowsExceptionOnNoConfiguredEncoders() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('There are no configured encoders for the "security" extension.'); $application = new ConsoleApplication(); $application->add(new UserPasswordEncoderCommand($this->getMockBuilder(EncoderFactoryInterface::class)->getMock(), [])); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index 76665764a1..de65dd5711 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -25,23 +25,23 @@ class ExtensionPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - if (!class_exists('Symfony\Component\Asset\Packages')) { + if (!class_exists(\Symfony\Component\Asset\Packages::class)) { $container->removeDefinition('twig.extension.assets'); } - if (!class_exists('Symfony\Component\ExpressionLanguage\Expression')) { + if (!class_exists(\Symfony\Component\ExpressionLanguage\Expression::class)) { $container->removeDefinition('twig.extension.expression'); } - if (!interface_exists('Symfony\Component\Routing\Generator\UrlGeneratorInterface')) { + if (!interface_exists(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)) { $container->removeDefinition('twig.extension.routing'); } - if (!class_exists('Symfony\Component\Yaml\Yaml')) { + if (!class_exists(\Symfony\Component\Yaml\Yaml::class)) { $container->removeDefinition('twig.extension.yaml'); } - $viewDir = \dirname((new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension'))->getFileName(), 2).'/Resources/views'; + $viewDir = \dirname((new \ReflectionClass(\Symfony\Bridge\Twig\Extension\FormExtension::class))->getFileName(), 2).'/Resources/views'; $templateIterator = $container->getDefinition('twig.template_iterator'); $templatePaths = $templateIterator->getArgument(2); $cacheWarmer = null; @@ -139,7 +139,7 @@ class ExtensionPass implements CompilerPassInterface $container->getDefinition('twig.extension.yaml')->addTag('twig.extension'); } - if (class_exists('Symfony\Component\Stopwatch\Stopwatch')) { + if (class_exists(\Symfony\Component\Stopwatch\Stopwatch::class)) { $container->getDefinition('twig.extension.debug.stopwatch')->addTag('twig.extension'); } diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php index a1354622b6..07ec691769 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php @@ -15,7 +15,7 @@ use Symfony\Bridge\Twig\UndefinedCallableHandler; use Twig\Environment; // BC/FC with namespaced Twig -class_exists('Twig\Environment'); +class_exists(Environment::class); /** * Twig environment configurator. diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 7eba6c4a8e..1a9222bdf3 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -38,11 +38,11 @@ class TwigExtension extends Extension $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('twig.xml'); - if (class_exists('Symfony\Component\Form\Form')) { + if (class_exists(\Symfony\Component\Form\Form::class)) { $loader->load('form.xml'); } - if (interface_exists('Symfony\Component\Templating\EngineInterface')) { + if (interface_exists(\Symfony\Component\Templating\EngineInterface::class)) { $loader->load('templating.xml'); } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php index fe7c525179..d544dde63c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php @@ -89,7 +89,7 @@ class TwigLoaderPassTest extends TestCase public function testMapperPassWithZeroTaggedLoaders() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class); $this->pass->process($this->builder); } } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index b760cca926..1610320216 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -22,8 +22,8 @@ class FilesystemLoaderTest extends TestCase { public function testGetSourceContext() { - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock(); + $locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $locator ->expects($this->once()) ->method('locate') @@ -42,8 +42,8 @@ class FilesystemLoaderTest extends TestCase public function testExists() { // should return true for templates that Twig does not find, but Symfony does - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock(); + $locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $locator ->expects($this->once()) ->method('locate') @@ -56,8 +56,8 @@ class FilesystemLoaderTest extends TestCase public function testTwigErrorIfLocatorThrowsInvalid() { - $this->expectException('Twig\Error\LoaderError'); - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $this->expectException(\Twig\Error\LoaderError::class); + $parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock(); $parser ->expects($this->once()) ->method('parse') @@ -65,7 +65,7 @@ class FilesystemLoaderTest extends TestCase ->willReturn($this->getMockBuilder(TemplateReferenceInterface::class)->getMock()) ; - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $locator ->expects($this->once()) ->method('locate') @@ -78,8 +78,8 @@ class FilesystemLoaderTest extends TestCase public function testTwigErrorIfLocatorReturnsFalse() { - $this->expectException('Twig\Error\LoaderError'); - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $this->expectException(\Twig\Error\LoaderError::class); + $parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock(); $parser ->expects($this->once()) ->method('parse') @@ -87,7 +87,7 @@ class FilesystemLoaderTest extends TestCase ->willReturn($this->getMockBuilder(TemplateReferenceInterface::class)->getMock()) ; - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $locator ->expects($this->once()) ->method('locate') @@ -100,28 +100,28 @@ class FilesystemLoaderTest extends TestCase public function testTwigErrorIfTemplateDoesNotExist() { - $this->expectException('Twig\Error\LoaderError'); + $this->expectException(\Twig\Error\LoaderError::class); $this->expectExceptionMessageMatches('/Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..DependencyInjection.Fixtures.templates\)/'); - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock(); + $locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/templates'); - $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); + $method = new \ReflectionMethod(FilesystemLoader::class, 'findTemplate'); $method->setAccessible(true); $method->invoke($loader, 'name.format.engine'); } public function testTwigSoftErrorIfTemplateDoesNotExist() { - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock(); + $locator = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/templates'); - $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); + $method = new \ReflectionMethod(FilesystemLoader::class, 'findTemplate'); $method->setAccessible(true); $this->assertNull($method->invoke($loader, 'name.format.engine', false)); } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/NativeFilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/NativeFilesystemLoaderTest.php index fe1c0680fa..21b2765802 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/NativeFilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/NativeFilesystemLoaderTest.php @@ -17,7 +17,7 @@ class NativeFilesystemLoaderTest extends TestCase public function testWithLegacyStyle1() { - $this->expectException('Twig\Error\LoaderError'); + $this->expectException(\Twig\Error\LoaderError::class); $this->expectExceptionMessage('Template reference "TestBundle::Foo/index.html.twig" not found, did you mean "@Test/Foo/index.html.twig"?'); $loader = new NativeFilesystemLoader(null, __DIR__.'/../'); $loader->addPath('Fixtures/templates', 'Test'); @@ -27,7 +27,7 @@ class NativeFilesystemLoaderTest extends TestCase public function testWithLegacyStyle2() { - $this->expectException('Twig\Error\LoaderError'); + $this->expectException(\Twig\Error\LoaderError::class); $this->expectExceptionMessage('Template reference "TestBundle:Foo:index.html.twig" not found, did you mean "@Test/Foo/index.html.twig"?'); $loader = new NativeFilesystemLoader(null, __DIR__.'/../'); $loader->addPath('Fixtures/templates', 'Test'); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php index b9092af3eb..a222e03ecf 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php @@ -17,11 +17,11 @@ class TemplateIteratorTest extends TestCase { public function testGetIterator() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock(); $bundle->expects($this->any())->method('getName')->willReturn('BarBundle'); $bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class)->disableOriginalConstructor()->getMock(); $kernel->expects($this->any())->method('getBundles')->willReturn([ $bundle, ]); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index b3c9825f1f..95fff43997 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -35,8 +35,8 @@ class ProfilerControllerTest extends WebTestCase $this->expectException(NotFoundHttpException::class); $this->expectExceptionMessage('The profiler must be enabled.'); - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock(); + $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); $controller = new ProfilerController($urlGenerator, null, $twig, []); $controller->homeAction(); @@ -111,8 +111,8 @@ class ProfilerControllerTest extends WebTestCase $this->expectException(NotFoundHttpException::class); $this->expectExceptionMessage('The profiler must be enabled.'); - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock(); + $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); $controller = new ProfilerController($urlGenerator, null, $twig, []); $controller->toolbarAction(Request::create('/_wdt/foo-token'), null); @@ -123,10 +123,10 @@ class ProfilerControllerTest extends WebTestCase */ public function testToolbarActionWithEmptyToken($token) { - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock(); + $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); $profiler = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->getMockBuilder(Profiler::class) ->disableOriginalConstructor() ->getMock(); @@ -150,10 +150,10 @@ class ProfilerControllerTest extends WebTestCase */ public function testOpeningDisallowedPaths($path, $isAllowed) { - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock(); + $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); $profiler = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->getMockBuilder(Profiler::class) ->disableOriginalConstructor() ->getMock(); @@ -186,9 +186,9 @@ class ProfilerControllerTest extends WebTestCase */ public function testReturns404onTokenNotFound($withCsp) { - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); $profiler = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->getMockBuilder(Profiler::class) ->disableOriginalConstructor() ->getMock(); @@ -214,8 +214,8 @@ class ProfilerControllerTest extends WebTestCase $this->expectException(NotFoundHttpException::class); $this->expectExceptionMessage('The profiler must be enabled.'); - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock(); + $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); $controller = new ProfilerController($urlGenerator, null, $twig, []); $controller->searchBarAction(Request::create('/_profiler/search_bar')); @@ -240,9 +240,9 @@ class ProfilerControllerTest extends WebTestCase */ public function testSearchResultsAction($withCsp) { - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); $profiler = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->getMockBuilder(Profiler::class) ->disableOriginalConstructor() ->getMock(); @@ -306,8 +306,8 @@ class ProfilerControllerTest extends WebTestCase $this->expectException(NotFoundHttpException::class); $this->expectExceptionMessage('The profiler must be enabled.'); - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock(); + $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); $controller = new ProfilerController($urlGenerator, null, $twig, []); $controller->searchBarAction(Request::create('/_profiler/search')); @@ -345,8 +345,8 @@ class ProfilerControllerTest extends WebTestCase $this->expectException(NotFoundHttpException::class); $this->expectExceptionMessage('The profiler must be enabled.'); - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); - $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock(); + $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); $controller = new ProfilerController($urlGenerator, null, $twig, []); $controller->phpinfoAction(Request::create('/_profiler/phpinfo')); @@ -464,10 +464,10 @@ class ProfilerControllerTest extends WebTestCase private function createController($profiler, $twig, $withCSP, array $templates = []): ProfilerController { - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); + $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock(); if ($withCSP) { - $nonceGenerator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock(); + $nonceGenerator = $this->getMockBuilder(\Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator::class)->getMock(); $nonceGenerator->method('generate')->willReturn('dummy_nonce'); return new ProfilerController($urlGenerator, $profiler, $twig, $templates, new ContentSecurityPolicyHandler($nonceGenerator)); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php index 986db4ebf3..b83ee8a4fd 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php @@ -210,7 +210,7 @@ class ContentSecurityPolicyHandlerTest extends TestCase private function mockNonceGenerator($value) { - $generator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock(); + $generator = $this->getMockBuilder(\Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator::class)->getMock(); $generator->expects($this->any()) ->method('generate') diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index 6c6fc7f0b4..c78f491b9b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -51,7 +51,7 @@ class WebProfilerExtensionTest extends TestCase { parent::setUp(); - $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock(); + $this->kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $this->container = new ContainerBuilder(); $this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index 416f63916f..ed3341be0b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -299,7 +299,7 @@ class WebDebugToolbarListenerTest extends TestCase protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true) { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock(); + $request = $this->getMockBuilder(Request::class)->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('isXmlHttpRequest') ->willReturn($isXmlHttpRequest); @@ -310,7 +310,7 @@ class WebDebugToolbarListenerTest extends TestCase $request->headers = new HeaderBag(); if ($hasSession) { - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class)->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('getSession') ->willReturn($session); @@ -321,7 +321,7 @@ class WebDebugToolbarListenerTest extends TestCase protected function getTwigMock($render = 'WDT') { - $templating = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $templating = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock(); $templating->expects($this->any()) ->method('render') ->willReturn($render); @@ -331,11 +331,11 @@ class WebDebugToolbarListenerTest extends TestCase protected function getUrlGeneratorMock() { - return $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); + return $this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); } protected function getKernelMock() { - return $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class)->disableOriginalConstructor()->getMock(); } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index 210807756d..66895312d7 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -57,7 +57,7 @@ class TemplateManagerTest extends TestCase public function testGetNameOfInvalidTemplate() { - $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $this->templateManager->getName(new Profile('token'), 'notexistingpanel'); } @@ -98,12 +98,12 @@ class TemplateManagerTest extends TestCase protected function mockProfile() { - return $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(Profile::class)->disableOriginalConstructor()->getMock(); } protected function mockTwigEnvironment() { - $this->twigEnvironment = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); + $this->twigEnvironment = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); if (Environment::MAJOR_VERSION > 1) { $loader = $this->createMock(LoaderInterface::class); @@ -122,7 +122,7 @@ class TemplateManagerTest extends TestCase protected function mockProfiler() { - $this->profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + $this->profiler = $this->getMockBuilder(\Symfony\Component\HttpKernel\Profiler\Profiler::class) ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php index d9a54c066e..accc39ccdd 100644 --- a/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php +++ b/src/Symfony/Component/Asset/Tests/Context/RequestStackContextTest.php @@ -18,7 +18,7 @@ class RequestStackContextTest extends TestCase { public function testGetBasePathEmpty() { - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $requestStackContext = new RequestStackContext($requestStack); $this->assertEmpty($requestStackContext->getBasePath()); @@ -28,10 +28,10 @@ class RequestStackContextTest extends TestCase { $testBasePath = 'test-path'; - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); $request->method('getBasePath') ->willReturn($testBasePath); - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $requestStack->method('getMasterRequest') ->willReturn($request); @@ -42,7 +42,7 @@ class RequestStackContextTest extends TestCase public function testIsSecureFalse() { - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $requestStackContext = new RequestStackContext($requestStack); $this->assertFalse($requestStackContext->isSecure()); @@ -50,10 +50,10 @@ class RequestStackContextTest extends TestCase public function testIsSecureTrue() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); $request->method('isSecure') ->willReturn(true); - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $requestStack->method('getMasterRequest') ->willReturn($request); @@ -64,7 +64,7 @@ class RequestStackContextTest extends TestCase public function testDefaultContext() { - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $requestStackContext = new RequestStackContext($requestStack, 'default-path', true); $this->assertSame('default-path', $requestStackContext->getBasePath()); diff --git a/src/Symfony/Component/Asset/Tests/PackagesTest.php b/src/Symfony/Component/Asset/Tests/PackagesTest.php index 4b30e30a5e..fd16697f5a 100644 --- a/src/Symfony/Component/Asset/Tests/PackagesTest.php +++ b/src/Symfony/Component/Asset/Tests/PackagesTest.php @@ -21,8 +21,8 @@ class PackagesTest extends TestCase public function testGetterSetters() { $packages = new Packages(); - $packages->setDefaultPackage($default = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock()); - $packages->addPackage('a', $a = $this->getMockBuilder('Symfony\Component\Asset\PackageInterface')->getMock()); + $packages->setDefaultPackage($default = $this->getMockBuilder(\Symfony\Component\Asset\PackageInterface::class)->getMock()); + $packages->addPackage('a', $a = $this->getMockBuilder(\Symfony\Component\Asset\PackageInterface::class)->getMock()); $this->assertSame($default, $packages->getPackage()); $this->assertSame($a, $packages->getPackage('a')); @@ -57,14 +57,14 @@ class PackagesTest extends TestCase public function testNoDefaultPackage() { - $this->expectException('Symfony\Component\Asset\Exception\LogicException'); + $this->expectException(\Symfony\Component\Asset\Exception\LogicException::class); $packages = new Packages(); $packages->getPackage(); } public function testUndefinedPackage() { - $this->expectException('Symfony\Component\Asset\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Asset\Exception\InvalidArgumentException::class); $packages = new Packages(); $packages->getPackage('a'); } diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php index 4d57559847..c006369bcb 100644 --- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php @@ -77,7 +77,7 @@ class PathPackageTest extends TestCase public function testVersionStrategyGivesAbsoluteURL() { - $versionStrategy = $this->getMockBuilder('Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface')->getMock(); + $versionStrategy = $this->getMockBuilder(\Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface::class)->getMock(); $versionStrategy->expects($this->any()) ->method('applyVersion') ->willReturn('https://cdn.com/bar/main.css'); @@ -88,7 +88,7 @@ class PathPackageTest extends TestCase private function getContext($basePath) { - $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); + $context = $this->getMockBuilder(\Symfony\Component\Asset\Context\ContextInterface::class)->getMock(); $context->expects($this->any())->method('getBasePath')->willReturn($basePath); return $context; diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php index f403a55a4a..690eb38406 100644 --- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php @@ -86,7 +86,7 @@ class UrlPackageTest extends TestCase public function testVersionStrategyGivesAbsoluteURL() { - $versionStrategy = $this->getMockBuilder('Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface')->getMock(); + $versionStrategy = $this->getMockBuilder(\Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface::class)->getMock(); $versionStrategy->expects($this->any()) ->method('applyVersion') ->willReturn('https://cdn.com/bar/main.css'); @@ -97,7 +97,7 @@ class UrlPackageTest extends TestCase public function testNoBaseUrls() { - $this->expectException('Symfony\Component\Asset\Exception\LogicException'); + $this->expectException(\Symfony\Component\Asset\Exception\LogicException::class); new UrlPackage([], new EmptyVersionStrategy()); } @@ -106,7 +106,7 @@ class UrlPackageTest extends TestCase */ public function testWrongBaseUrl($baseUrls) { - $this->expectException('Symfony\Component\Asset\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Asset\Exception\InvalidArgumentException::class); new UrlPackage($baseUrls, new EmptyVersionStrategy()); } @@ -120,7 +120,7 @@ class UrlPackageTest extends TestCase private function getContext($secure) { - $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); + $context = $this->getMockBuilder(\Symfony\Component\Asset\Context\ContextInterface::class)->getMock(); $context->expects($this->any())->method('isSecure')->willReturn($secure); return $context; diff --git a/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php b/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php index 7f2d44c4a2..a9ca035fb9 100644 --- a/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php +++ b/src/Symfony/Component/Asset/Tests/VersionStrategy/JsonManifestVersionStrategyTest.php @@ -39,14 +39,14 @@ class JsonManifestVersionStrategyTest extends TestCase public function testMissingManifestFileThrowsException() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $strategy = $this->createStrategy('non-existent-file.json'); $strategy->getVersion('main.js'); } public function testManifestFileWithBadJSONThrowsException() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Error parsing JSON'); $strategy = $this->createStrategy('manifest-invalid.json'); $strategy->getVersion('main.js'); diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 7e95ebc448..b20ccdc88c 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -117,7 +117,7 @@ abstract class Client */ public function insulate($insulated = true) { - if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) { + if ($insulated && !class_exists(\Symfony\Component\Process\Process::class)) { throw new \LogicException('Unable to isolate requests as the Symfony Process Component is not installed.'); } @@ -527,7 +527,7 @@ abstract class Client */ protected function createCrawlerFromContent($uri, $content, $type) { - if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { + if (!class_exists(Crawler::class)) { return null; } diff --git a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index ca3d18a953..716ad88009 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -89,7 +89,7 @@ class AbstractBrowserTest extends TestCase $client->request('GET', 'http://example.com/'); $this->assertSame('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request'); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request'); + $this->assertInstanceOf(Response::class, $client->getResponse(), '->getCrawler() returns the Response of the last request'); } /** @@ -300,7 +300,7 @@ class AbstractBrowserTest extends TestCase $client->clickLink('foo'); $this->fail('->clickLink() throws a \InvalidArgumentException if the link could not be found'); } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '->clickLink() throws a \InvalidArgumentException if the link could not be found'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->clickLink() throws a \InvalidArgumentException if the link could not be found'); } } @@ -359,7 +359,7 @@ class AbstractBrowserTest extends TestCase ], 'POST'); $this->fail('->submitForm() throws a \InvalidArgumentException if the form could not be found'); } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '->submitForm() throws a \InvalidArgumentException if the form could not be found'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->submitForm() throws a \InvalidArgumentException if the form could not be found'); } } @@ -410,7 +410,7 @@ class AbstractBrowserTest extends TestCase $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request was not redirected'); } catch (\Exception $e) { - $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected'); + $this->assertInstanceOf(\LogicException::class, $e, '->followRedirect() throws a \LogicException if the request was not redirected'); } $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); @@ -440,7 +440,7 @@ class AbstractBrowserTest extends TestCase $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); } catch (\Exception $e) { - $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); + $this->assertInstanceOf(\LogicException::class, $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); } } @@ -470,7 +470,7 @@ class AbstractBrowserTest extends TestCase $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); } catch (\Exception $e) { - $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); + $this->assertInstanceOf(\LogicException::class, $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); } $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); @@ -753,7 +753,7 @@ class AbstractBrowserTest extends TestCase $client->request('GET', 'http://www.example.com/foo/foobar'); $this->fail('->request() throws a \RuntimeException if the script has an error'); } catch (\Exception $e) { - $this->assertInstanceOf('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error'); + $this->assertInstanceOf(\RuntimeException::class, $e, '->request() throws a \RuntimeException if the script has an error'); } } @@ -841,7 +841,7 @@ class AbstractBrowserTest extends TestCase 'NEW_SERVER_KEY' => 'new-server-key-value', ]); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest()); + $this->assertInstanceOf(\Symfony\Component\BrowserKit\Request::class, $client->getInternalRequest()); } /** diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php index d88f0234c6..414f5dc62c 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -77,8 +77,8 @@ class CookieJarTest extends TestCase $cookieJar->set(new Cookie('bar', 'bar')); $cookieJar->updateFromSetCookie($setCookies); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('foo')); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('bar')); + $this->assertInstanceOf(Cookie::class, $cookieJar->get('foo')); + $this->assertInstanceOf(Cookie::class, $cookieJar->get('bar')); $this->assertEquals('foo', $cookieJar->get('foo')->getValue(), '->updateFromSetCookie() updates cookies from a Set-Cookie header'); $this->assertEquals('bar', $cookieJar->get('bar')->getValue(), '->updateFromSetCookie() keeps existing cookies'); } @@ -103,9 +103,9 @@ class CookieJarTest extends TestCase $barCookie = $cookieJar->get('bar', '/', '.blog.symfony.com'); $phpCookie = $cookieJar->get('PHPSESSID'); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $fooCookie); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $barCookie); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $phpCookie); + $this->assertInstanceOf(Cookie::class, $fooCookie); + $this->assertInstanceOf(Cookie::class, $barCookie); + $this->assertInstanceOf(Cookie::class, $phpCookie); $this->assertEquals('foo', $fooCookie->getValue()); $this->assertEquals('bar', $barCookie->getValue()); $this->assertEquals('id', $phpCookie->getValue()); diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php index 6318cae2d5..72f69e0616 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -103,7 +103,7 @@ class CookieTest extends TestCase public function testFromStringThrowsAnExceptionIfCookieIsNotValid() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); Cookie::fromString('foo'); } @@ -116,7 +116,7 @@ class CookieTest extends TestCase public function testFromStringThrowsAnExceptionIfUrlIsNotValid() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); Cookie::fromString('foo=bar', 'foobar'); } @@ -199,7 +199,7 @@ class CookieTest extends TestCase public function testConstructException() { - $this->expectException('UnexpectedValueException'); + $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage('The cookie expiration time "string" is not valid.'); new Cookie('foo', 'bar', 'string'); } diff --git a/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php b/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php index aa09b05b34..8f3cfae16b 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HistoryTest.php @@ -55,7 +55,7 @@ class HistoryTest extends TestCase $history->current(); $this->fail('->current() throws a \LogicException if the history is empty'); } catch (\Exception $e) { - $this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is empty'); + $this->assertInstanceOf(\LogicException::class, $e, '->current() throws a \LogicException if the history is empty'); } $history->add(new Request('http://www.example.com/', 'get')); @@ -72,7 +72,7 @@ class HistoryTest extends TestCase $history->back(); $this->fail('->back() throws a \LogicException if the history is already on the first page'); } catch (\Exception $e) { - $this->assertInstanceOf('LogicException', $e, '->current() throws a \LogicException if the history is already on the first page'); + $this->assertInstanceOf(\LogicException::class, $e, '->current() throws a \LogicException if the history is already on the first page'); } $history->add(new Request('http://www.example1.com/', 'get')); @@ -91,7 +91,7 @@ class HistoryTest extends TestCase $history->forward(); $this->fail('->forward() throws a \LogicException if the history is already on the last page'); } catch (\Exception $e) { - $this->assertInstanceOf('LogicException', $e, '->forward() throws a \LogicException if the history is already on the last page'); + $this->assertInstanceOf(\LogicException::class, $e, '->forward() throws a \LogicException if the history is already on the last page'); } $history->back(); diff --git a/src/Symfony/Component/BrowserKit/Tests/TestClient.php b/src/Symfony/Component/BrowserKit/Tests/TestClient.php index 0efa48b98b..64e4937ea5 100644 --- a/src/Symfony/Component/BrowserKit/Tests/TestClient.php +++ b/src/Symfony/Component/BrowserKit/Tests/TestClient.php @@ -43,7 +43,7 @@ class TestClient extends AbstractBrowser protected function getScript($request) { - $r = new \ReflectionClass('Symfony\Component\BrowserKit\Response'); + $r = new \ReflectionClass(Response::class); $path = $r->getFileName(); return <<getFileName(); return <<expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('At least one adapter must be specified.'); new ChainAdapter([]); } public function testInvalidAdapterException() { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The class "stdClass" does not implement'); new ChainAdapter([new \stdClass()]); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php index 6f49652a45..8970327049 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php @@ -68,7 +68,7 @@ class MaxIdLengthAdapterTest extends TestCase public function testTooLongNamespace() { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Namespace must be 26 chars max, 40 given ("----------------------------------------")'); $this->getMockBuilder(MaxIdLengthAdapter::class) ->setConstructorArgs([str_repeat('-', 40)]) diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php index 8de7a9d1b8..25fef07985 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php @@ -72,10 +72,10 @@ class MemcachedAdapterTest extends AdapterTestCase public function testBadOptions($name, $value) { if (\PHP_VERSION_ID < 80000) { - $this->expectException('ErrorException'); + $this->expectException(\ErrorException::class); $this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::'); } else { - $this->expectException('Error'); + $this->expectException(\Error::class); $this->expectExceptionMessage('Undefined constant Memcached::'); } @@ -106,7 +106,7 @@ class MemcachedAdapterTest extends AdapterTestCase public function testOptionSerializer() { - $this->expectException('Symfony\Component\Cache\Exception\CacheException'); + $this->expectException(\Symfony\Component\Cache\Exception\CacheException::class); $this->expectExceptionMessage('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); if (!\Memcached::HAVE_JSON) { $this->markTestSkipped('Memcached::HAVE_JSON required'); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php index 0fbe94aac8..378efa7b75 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php @@ -40,7 +40,7 @@ class ProxyAdapterTest extends AdapterTestCase public function testProxyfiedItem() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('OK bar'); $item = new CacheItem(); $pool = new ProxyAdapter(new TestingArrayAdapter($item)); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php index 82b9f08b65..3c250a5e6f 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php @@ -21,7 +21,7 @@ class RedisAdapterSentinelTest extends AbstractRedisAdapterTest { public static function setUpBeforeClass(): void { - if (!class_exists('Predis\Client')) { + if (!class_exists(\Predis\Client::class)) { self::markTestSkipped('The Predis\Client class is required.'); } if (!$hosts = getenv('REDIS_SENTINEL_HOSTS')) { @@ -36,7 +36,7 @@ class RedisAdapterSentinelTest extends AbstractRedisAdapterTest public function testInvalidDSNHasBothClusterAndSentinel() { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Cannot use both "redis_cluster" and "redis_sentinel" at the same time:'); $dsn = 'redis:?host[redis1]&host[redis2]&host[redis3]&redis_cluster=1&redis_sentinel=mymaster'; RedisAdapter::createConnection($dsn); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php index 9843a36891..0e4f930377 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php @@ -70,7 +70,7 @@ class RedisAdapterTest extends AbstractRedisAdapterTest */ public function testFailedCreateConnection(string $dsn) { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Redis connection '); RedisAdapter::createConnection($dsn); } @@ -89,7 +89,7 @@ class RedisAdapterTest extends AbstractRedisAdapterTest */ public function testInvalidCreateConnection(string $dsn) { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid Redis DSN'); RedisAdapter::createConnection($dsn); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php index eb691ed27d..70afe6dac9 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php @@ -19,7 +19,7 @@ class RedisArrayAdapterTest extends AbstractRedisAdapterTest public static function setUpBeforeClass(): void { parent::setupBeforeClass(); - if (!class_exists('RedisArray')) { + if (!class_exists(\RedisArray::class)) { self::markTestSkipped('The RedisArray class is required.'); } self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php index 0705726026..92a9678461 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php @@ -23,7 +23,7 @@ class RedisClusterAdapterTest extends AbstractRedisAdapterTest { public static function setUpBeforeClass(): void { - if (!class_exists('RedisCluster')) { + if (!class_exists(\RedisCluster::class)) { self::markTestSkipped('The RedisCluster class is required.'); } if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { @@ -46,7 +46,7 @@ class RedisClusterAdapterTest extends AbstractRedisAdapterTest */ public function testFailedCreateConnection(string $dsn) { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Redis connection '); RedisAdapter::createConnection($dsn); } diff --git a/src/Symfony/Component/Cache/Tests/CacheItemTest.php b/src/Symfony/Component/Cache/Tests/CacheItemTest.php index 01914e4a36..d667aa1261 100644 --- a/src/Symfony/Component/Cache/Tests/CacheItemTest.php +++ b/src/Symfony/Component/Cache/Tests/CacheItemTest.php @@ -27,7 +27,7 @@ class CacheItemTest extends TestCase */ public function testInvalidKey($key) { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Cache key'); CacheItem::validateKey($key); } @@ -75,7 +75,7 @@ class CacheItemTest extends TestCase */ public function testInvalidTag($tag) { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Cache tag'); $item = new CacheItem(); $r = new \ReflectionProperty($item, 'isTaggable'); @@ -87,7 +87,7 @@ class CacheItemTest extends TestCase public function testNonTaggableItem() { - $this->expectException('Symfony\Component\Cache\Exception\LogicException'); + $this->expectException(\Symfony\Component\Cache\Exception\LogicException::class); $this->expectExceptionMessage('Cache item "foo" comes from a non tag-aware pool: you cannot tag it.'); $item = new CacheItem(); $r = new \ReflectionProperty($item, 'key'); diff --git a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php index 20701adcb4..9769b3992e 100644 --- a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php +++ b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php @@ -161,7 +161,7 @@ class CachePoolPassTest extends TestCase public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are'); $container = new ContainerBuilder(); $container->setParameter('kernel.container_class', 'app'); diff --git a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPrunerPassTest.php b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPrunerPassTest.php index 2a1ab49b64..7225d630e1 100644 --- a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPrunerPassTest.php +++ b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPrunerPassTest.php @@ -58,7 +58,7 @@ class CachePoolPrunerPassTest extends TestCase public function testCompilerPassThrowsOnInvalidDefinitionClass() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Class "Symfony\Component\Cache\Tests\DependencyInjection\NotFound" used for service "pool.not-found" cannot be found.'); $container = new ContainerBuilder(); $container->register('console.command.cache_pool_prune')->addArgument([]); diff --git a/src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php b/src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php index 050aab4207..51ecc941b8 100644 --- a/src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php +++ b/src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php @@ -56,7 +56,7 @@ class DefaultMarshallerTest extends TestCase public function testNativeUnserializeNotFoundClass() { - $this->expectException('DomainException'); + $this->expectException(\DomainException::class); $this->expectExceptionMessage('Class not found: NotExistingClass'); $marshaller = new DefaultMarshaller(); $marshaller->unmarshall('O:16:"NotExistingClass":0:{}'); @@ -71,7 +71,7 @@ class DefaultMarshallerTest extends TestCase $this->markTestSkipped('igbinary is not compatible with PHP 7.4.'); } - $this->expectException('DomainException'); + $this->expectException(\DomainException::class); $this->expectExceptionMessage('Class not found: NotExistingClass'); $marshaller = new DefaultMarshaller(); $marshaller->unmarshall(rawurldecode('%00%00%00%02%17%10NotExistingClass%14%00')); @@ -79,7 +79,7 @@ class DefaultMarshallerTest extends TestCase public function testNativeUnserializeInvalid() { - $this->expectException('DomainException'); + $this->expectException(\DomainException::class); $this->expectExceptionMessage('unserialize(): Error at offset 0 of 3 bytes'); $marshaller = new DefaultMarshaller(); set_error_handler(function () { return false; }); @@ -99,7 +99,7 @@ class DefaultMarshallerTest extends TestCase $this->markTestSkipped('igbinary is not compatible with PHP 7.4.'); } - $this->expectException('DomainException'); + $this->expectException(\DomainException::class); $this->expectExceptionMessage('igbinary_unserialize_zval: unknown type \'61\', position 5'); $marshaller = new DefaultMarshaller(); set_error_handler(function () { return false; }); diff --git a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php index 47e6b8686a..c65cf92c6a 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php @@ -30,14 +30,14 @@ class ChainCacheTest extends CacheTestCase public function testEmptyCachesException() { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('At least one cache must be specified.'); new ChainCache([]); } public function testInvalidCacheException() { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The class "stdClass" does not implement'); new ChainCache([new \stdClass()]); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php index 920c864e61..707c205089 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php @@ -82,10 +82,10 @@ class MemcachedCacheTest extends CacheTestCase public function testBadOptions(string $name, $value) { if (\PHP_VERSION_ID < 80000) { - $this->expectException('ErrorException'); + $this->expectException(\ErrorException::class); $this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::'); } else { - $this->expectException('Error'); + $this->expectException(\Error::class); $this->expectExceptionMessage('Undefined constant Memcached::'); } @@ -115,7 +115,7 @@ class MemcachedCacheTest extends CacheTestCase public function testOptionSerializer() { - $this->expectException('Symfony\Component\Cache\Exception\CacheException'); + $this->expectException(\Symfony\Component\Cache\Exception\CacheException::class); $this->expectExceptionMessage('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); if (!\Memcached::HAVE_JSON) { $this->markTestSkipped('Memcached::HAVE_JSON required'); diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php index 01256120dd..8173bcf101 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php @@ -20,7 +20,7 @@ class RedisArrayCacheTest extends AbstractRedisCacheTest public static function setUpBeforeClass(): void { parent::setupBeforeClass(); - if (!class_exists('RedisArray')) { + if (!class_exists(\RedisArray::class)) { self::markTestSkipped('The RedisArray class is required.'); } self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php index 62ebf69bf3..770d8ff9e9 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php @@ -52,7 +52,7 @@ class RedisCacheTest extends AbstractRedisCacheTest */ public function testFailedCreateConnection(string $dsn) { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Redis connection '); RedisCache::createConnection($dsn); } @@ -71,7 +71,7 @@ class RedisCacheTest extends AbstractRedisCacheTest */ public function testInvalidCreateConnection(string $dsn) { - $this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid Redis DSN'); RedisCache::createConnection($dsn); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php index deede9ae21..bf20819df5 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php @@ -19,7 +19,7 @@ class RedisClusterCacheTest extends AbstractRedisCacheTest { public static function setUpBeforeClass(): void { - if (!class_exists('RedisCluster')) { + if (!class_exists(\RedisCluster::class)) { self::markTestSkipped('The RedisCluster class is required.'); } if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { diff --git a/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php b/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php index 8b687b5a75..f0ad55720d 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php +++ b/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php @@ -22,7 +22,7 @@ trait TagAwareTestTrait { public function testInvalidTag() { - $this->expectException('Psr\Cache\InvalidArgumentException'); + $this->expectException(\Psr\Cache\InvalidArgumentException::class); $pool = $this->createCachePool(); $item = $pool->getItem('foo'); $item->tag(':'); diff --git a/src/Symfony/Component/Cache/Traits/ApcuTrait.php b/src/Symfony/Component/Cache/Traits/ApcuTrait.php index 7161adbddd..9a02148c14 100644 --- a/src/Symfony/Component/Cache/Traits/ApcuTrait.php +++ b/src/Symfony/Component/Cache/Traits/ApcuTrait.php @@ -81,7 +81,7 @@ trait ApcuTrait */ protected function doClear($namespace) { - return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) + return isset($namespace[0]) && class_exists(\APCuIterator::class, false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY)) : apcu_clear_cache(); } diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index e1a9b6208b..c77e343b5c 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -226,7 +226,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface foreach ($props as $p => $v) { if (null !== $v) { - $r = new \ReflectionProperty('Exception', $p); + $r = new \ReflectionProperty(\Exception::class, $p); $r->setAccessible(true); $r->setValue($e, $v); } diff --git a/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php b/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php index 6190b9b450..9552838757 100644 --- a/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php +++ b/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php @@ -18,7 +18,7 @@ class ConfigCacheFactoryTest extends TestCase { public function testCacheWithInvalidCallback() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid type for callback argument. Expected callable, but got "object".'); $cacheFactory = new ConfigCacheFactory(true); diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index 87945d980f..1f4d09835a 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -20,14 +20,14 @@ class ArrayNodeTest extends TestCase { public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $node = new ArrayNode('root'); $node->normalize(false); } public function testExceptionThrownOnUnrecognizedChild() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(InvalidConfigurationException::class); $this->expectExceptionMessage('Unrecognized option "foo" under "root"'); $node = new ArrayNode('root'); $node->normalize(['foo' => 'bar']); @@ -35,7 +35,7 @@ class ArrayNodeTest extends TestCase public function testNormalizeWithProposals() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(InvalidConfigurationException::class); $this->expectExceptionMessage('Did you mean "alpha1", "alpha2"?'); $node = new ArrayNode('root'); $node->addChild(new ArrayNode('alpha1')); @@ -46,7 +46,7 @@ class ArrayNodeTest extends TestCase public function testNormalizeWithoutProposals() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(InvalidConfigurationException::class); $this->expectExceptionMessage('Available options are "alpha1", "alpha2".'); $node = new ArrayNode('root'); $node->addChild(new ArrayNode('alpha1')); @@ -195,7 +195,7 @@ class ArrayNodeTest extends TestCase public function testAddChildEmptyName() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Child nodes must be named.'); $node = new ArrayNode('root'); @@ -205,7 +205,7 @@ class ArrayNodeTest extends TestCase public function testAddChildNameAlreadyExists() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('A child node named "foo" already exists.'); $node = new ArrayNode('root'); @@ -218,7 +218,7 @@ class ArrayNodeTest extends TestCase public function testGetDefaultValueWithoutDefaultValue() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('The node at path "foo" has no default value.'); $node = new ArrayNode('foo'); $node->getDefaultValue(); @@ -261,7 +261,7 @@ class ArrayNodeTest extends TestCase */ public function testMergeWithoutIgnoringExtraKeys($prenormalizeds, $merged) { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('merge() expects a normalized config array.'); $node = new ArrayNode('root'); $node->addChild(new ScalarNode('foo')); @@ -279,7 +279,7 @@ class ArrayNodeTest extends TestCase */ public function testMergeWithIgnoringAndRemovingExtraKeys($prenormalizeds, $merged) { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('merge() expects a normalized config array.'); $node = new ArrayNode('root'); $node->addChild(new ScalarNode('foo')); diff --git a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php index 8552eeba39..929b69755f 100644 --- a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php @@ -51,7 +51,7 @@ class BooleanNodeTest extends TestCase */ public function testNormalizeThrowsExceptionOnInvalidValues($value) { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $node = new BooleanNode('test'); $node->normalize($value); } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php index c0b1005543..765c94a6ba 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -42,7 +42,7 @@ class ArrayNodeDefinitionTest extends TestCase */ public function testPrototypeNodeSpecificOption($method, $args) { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $this->expectException(InvalidDefinitionException::class); $node = new ArrayNodeDefinition('root'); $node->{$method}(...$args); @@ -63,7 +63,7 @@ class ArrayNodeDefinitionTest extends TestCase public function testConcreteNodeSpecificOption() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $this->expectException(InvalidDefinitionException::class); $node = new ArrayNodeDefinition('root'); $node ->addDefaultsIfNotSet() @@ -74,7 +74,7 @@ class ArrayNodeDefinitionTest extends TestCase public function testPrototypeNodesCantHaveADefaultValueWhenUsingDefaultChildren() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $this->expectException(InvalidDefinitionException::class); $node = new ArrayNodeDefinition('root'); $node ->defaultValue([]) @@ -152,8 +152,8 @@ class ArrayNodeDefinitionTest extends TestCase ; $node = $nodeDefinition->getNode(); - $this->assertInstanceOf('Symfony\Component\Config\Definition\PrototypedArrayNode', $node); - $this->assertInstanceOf('Symfony\Component\Config\Definition\PrototypedArrayNode', $node->getPrototype()); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\PrototypedArrayNode::class, $node); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\PrototypedArrayNode::class, $node->getPrototype()); } public function testEnabledNodeDefaults() @@ -317,7 +317,7 @@ class ArrayNodeDefinitionTest extends TestCase public function testCannotBeEmpty() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The path "root" should have at least 1 element(s) defined.'); $node = new ArrayNodeDefinition('root'); $node @@ -343,7 +343,7 @@ class ArrayNodeDefinitionTest extends TestCase public function testCannotBeEmptyOnConcreteNode() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $this->expectException(InvalidDefinitionException::class); $this->expectExceptionMessage('->cannotBeEmpty() is not applicable to concrete nodes at path "root"'); $node = new ArrayNodeDefinition('root'); $node->cannotBeEmpty(); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/BooleanNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/BooleanNodeDefinitionTest.php index 6f568a2df6..bca66a0a59 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/BooleanNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/BooleanNodeDefinitionTest.php @@ -18,7 +18,7 @@ class BooleanNodeDefinitionTest extends TestCase { public function testCannotBeEmptyThrowsAnException() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.'); $def = new BooleanNodeDefinition('foo'); $def->cannotBeEmpty(); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php index 2e43a1354d..5173c151f9 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php @@ -36,7 +36,7 @@ class EnumNodeDefinitionTest extends TestCase public function testNoValuesPassed() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('You must call ->values() on enum nodes.'); $def = new EnumNodeDefinition('foo'); $def->getNode(); @@ -44,7 +44,7 @@ class EnumNodeDefinitionTest extends TestCase public function testWithNoValues() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('->values() must be called with at least one value.'); $def = new EnumNodeDefinition('foo'); $def->values([]); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index 5a1b3300fd..e2b14751b1 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -167,7 +167,7 @@ class ExprBuilderTest extends TestCase public function testThenInvalid() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $test = $this->getTestBuilder() ->ifString() ->thenInvalid('Invalid value') @@ -186,14 +186,14 @@ class ExprBuilderTest extends TestCase public function testEndIfPartNotSpecified() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('You must specify an if part.'); $this->getTestBuilder()->end(); } public function testEndThenPartNotSpecified() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('You must specify a then part.'); $builder = $this->getTestBuilder(); $builder->ifPart = 'test'; diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php index 46518c659a..e29a091053 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php @@ -19,14 +19,14 @@ class NodeBuilderTest extends TestCase { public function testThrowsAnExceptionWhenTryingToCreateANonRegisteredNodeType() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $builder = new BaseNodeBuilder(); $builder->node('', 'foobar'); } public function testThrowsAnExceptionWhenTheNodeClassIsNotFound() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $builder = new BaseNodeBuilder(); $builder ->setNodeClass('noclasstype', '\\foo\\bar\\noclass') @@ -79,10 +79,10 @@ class NodeBuilderTest extends TestCase $builder = new BaseNodeBuilder(); $node = $builder->integerNode('foo')->min(3)->max(5); - $this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition', $node); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition::class, $node); $node = $builder->floatNode('bar')->min(3.0)->max(5.0); - $this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\FloatNodeDefinition', $node); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\Builder\FloatNodeDefinition::class, $node); } } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/NumericNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/NumericNodeDefinitionTest.php index aa938bbaa7..b0a3983756 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/NumericNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/NumericNodeDefinitionTest.php @@ -19,7 +19,7 @@ class NumericNodeDefinitionTest extends TestCase { public function testIncoherentMinAssertion() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('You cannot define a min(4) as you already have a max(3)'); $def = new IntegerNodeDefinition('foo'); $def->max(3)->min(4); @@ -27,7 +27,7 @@ class NumericNodeDefinitionTest extends TestCase public function testIncoherentMaxAssertion() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('You cannot define a max(2) as you already have a min(3)'); $node = new IntegerNodeDefinition('foo'); $node->min(3)->max(2); @@ -35,7 +35,7 @@ class NumericNodeDefinitionTest extends TestCase public function testIntegerMinAssertion() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The value 4 is too small for path "foo". Should be greater than or equal to 5'); $def = new IntegerNodeDefinition('foo'); $def->min(5)->getNode()->finalize(4); @@ -43,7 +43,7 @@ class NumericNodeDefinitionTest extends TestCase public function testIntegerMaxAssertion() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The value 4 is too big for path "foo". Should be less than or equal to 3'); $def = new IntegerNodeDefinition('foo'); $def->max(3)->getNode()->finalize(4); @@ -58,7 +58,7 @@ class NumericNodeDefinitionTest extends TestCase public function testFloatMinAssertion() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The value 400 is too small for path "foo". Should be greater than or equal to 500'); $def = new FloatNodeDefinition('foo'); $def->min(5E2)->getNode()->finalize(4e2); @@ -66,7 +66,7 @@ class NumericNodeDefinitionTest extends TestCase public function testFloatMaxAssertion() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The value 4.3 is too big for path "foo". Should be less than or equal to 0.3'); $def = new FloatNodeDefinition('foo'); $def->max(0.3)->getNode()->finalize(4.3); @@ -81,7 +81,7 @@ class NumericNodeDefinitionTest extends TestCase public function testCannotBeEmptyThrowsAnException() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('->cannotBeEmpty() is not applicable to NumericNodeDefinition.'); $def = new IntegerNodeDefinition('foo'); $def->cannotBeEmpty(); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php index baeb8a4b16..96b1b4c2de 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php @@ -23,11 +23,11 @@ class TreeBuilderTest extends TestCase $nodeBuilder = $builder->getRootNode()->children(); - $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder', $nodeBuilder); + $this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder::class, $nodeBuilder); $nodeBuilder = $nodeBuilder->arrayNode('deeper')->children(); - $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder', $nodeBuilder); + $this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder::class, $nodeBuilder); } public function testOverrideABuiltInNodeType() @@ -36,7 +36,7 @@ class TreeBuilderTest extends TestCase $definition = $builder->getRootNode()->children()->variableNode('variable'); - $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\VariableNodeDefinition', $definition); + $this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\VariableNodeDefinition::class, $definition); } public function testAddANodeType() @@ -45,7 +45,7 @@ class TreeBuilderTest extends TestCase $definition = $builder->getRootNode()->children()->barNode('variable'); - $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\Builder\BarNodeDefinition', $definition); + $this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\BarNodeDefinition::class, $definition); } public function testCreateABuiltInNodeTypeWithACustomNodeBuilder() @@ -54,7 +54,7 @@ class TreeBuilderTest extends TestCase $definition = $builder->getRootNode()->children()->booleanNode('boolean'); - $this->assertInstanceOf('Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition', $definition); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition::class, $definition); } public function testPrototypedArrayNodeUseTheCustomNodeBuilder() @@ -64,7 +64,7 @@ class TreeBuilderTest extends TestCase $root = $builder->getRootNode(); $root->prototype('bar')->end(); - $this->assertInstanceOf('Symfony\Component\Config\Tests\Fixtures\BarNode', $root->getNode(true)->getPrototype()); + $this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\BarNode::class, $root->getNode(true)->getPrototype()); } public function testAnExtendedNodeBuilderGetsPropagatedToTheChildren() @@ -86,11 +86,11 @@ class TreeBuilderTest extends TestCase $node = $builder->buildTree(); $children = $node->getChildren(); - $this->assertInstanceOf('Symfony\Component\Config\Definition\BooleanNode', $children['foo']); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\BooleanNode::class, $children['foo']); $childChildren = $children['child']->getChildren(); - $this->assertInstanceOf('Symfony\Component\Config\Definition\BooleanNode', $childChildren['foo']); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\BooleanNode::class, $childChildren['foo']); } public function testDefinitionInfoGetsTransferredToNode() @@ -147,14 +147,14 @@ class TreeBuilderTest extends TestCase $children = $node->getChildren(); $this->assertArrayHasKey('foo', $children); - $this->assertInstanceOf('Symfony\Component\Config\Definition\BaseNode', $children['foo']); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $children['foo']); $this->assertSame('propagation.foo', $children['foo']->getPath()); $this->assertArrayHasKey('child', $children); $childChildren = $children['child']->getChildren(); $this->assertArrayHasKey('foo', $childChildren); - $this->assertInstanceOf('Symfony\Component\Config\Definition\BaseNode', $childChildren['foo']); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $childChildren['foo']); $this->assertSame('propagation.child.foo', $childChildren['foo']->getPath()); } @@ -178,14 +178,14 @@ class TreeBuilderTest extends TestCase $children = $node->getChildren(); $this->assertArrayHasKey('foo', $children); - $this->assertInstanceOf('Symfony\Component\Config\Definition\BaseNode', $children['foo']); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $children['foo']); $this->assertSame('propagation/foo', $children['foo']->getPath()); $this->assertArrayHasKey('child', $children); $childChildren = $children['child']->getChildren(); $this->assertArrayHasKey('foo', $childChildren); - $this->assertInstanceOf('Symfony\Component\Config\Definition\BaseNode', $childChildren['foo']); + $this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $childChildren['foo']); $this->assertSame('propagation/child/foo', $childChildren['foo']->getPath()); } diff --git a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php index 107fe8504d..1d5136ce5b 100644 --- a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php @@ -24,7 +24,7 @@ class EnumNodeTest extends TestCase public function testConstructionWithNoValues() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('$values must contain at least one element.'); new EnumNode('foo', null, []); } @@ -49,7 +49,7 @@ class EnumNodeTest extends TestCase public function testFinalizeWithInvalidValue() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar"'); $node = new EnumNode('foo', null, ['foo', 'bar']); $node->finalize('foobar'); diff --git a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php index fed9f013db..a22550bcc8 100644 --- a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php @@ -57,7 +57,7 @@ class FloatNodeTest extends TestCase */ public function testNormalizeThrowsExceptionOnInvalidValues($value) { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $node = new FloatNode('test'); $node->normalize($value); } diff --git a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php index 3fb1b771e5..2bc7db02ec 100644 --- a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php @@ -52,7 +52,7 @@ class IntegerNodeTest extends TestCase */ public function testNormalizeThrowsExceptionOnInvalidValues($value) { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $node = new IntegerNode('test'); $node->normalize($value); } diff --git a/src/Symfony/Component/Config/Tests/Definition/MergeTest.php b/src/Symfony/Component/Config/Tests/Definition/MergeTest.php index 654997a0f5..e9d87d9b2a 100644 --- a/src/Symfony/Component/Config/Tests/Definition/MergeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/MergeTest.php @@ -18,7 +18,7 @@ class MergeTest extends TestCase { public function testForbiddenOverwrite() { - $this->expectException('Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException::class); $tb = new TreeBuilder('root', 'array'); $tree = $tb ->getRootNode() @@ -92,7 +92,7 @@ class MergeTest extends TestCase public function testDoesNotAllowNewKeysInSubsequentConfigs() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $tb = new TreeBuilder('root', 'array'); $tree = $tb ->getRootNode() diff --git a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php index 931cf987ea..cd32779373 100644 --- a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php @@ -171,7 +171,7 @@ class NormalizationTest extends TestCase public function testNonAssociativeArrayThrowsExceptionIfAttributeNotSet() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The attribute "id" must be set for path "root.thing".'); $denormalized = [ 'thing' => [ diff --git a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php index ac2d9376f0..892c91d63f 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php @@ -77,7 +77,7 @@ class ScalarNodeTest extends TestCase */ public function testNormalizeThrowsExceptionOnInvalidValues($value) { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $node = new ScalarNode('test'); $node->normalize($value); } @@ -95,7 +95,7 @@ class ScalarNodeTest extends TestCase { $node = new ScalarNode('test'); - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $this->expectExceptionMessage('Invalid type for path "test". Expected scalar, but got array.'); $node->normalize([]); @@ -106,7 +106,7 @@ class ScalarNodeTest extends TestCase $node = new ScalarNode('test'); $node->setInfo('"the test value"'); - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $this->expectExceptionMessage("Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\""); $node->normalize([]); @@ -145,7 +145,7 @@ class ScalarNodeTest extends TestCase */ public function testNotAllowedEmptyValuesThrowException($value) { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $node = new ScalarNode('test'); $node->setAllowEmptyValue(false); $node->finalize($value); diff --git a/src/Symfony/Component/Config/Tests/FileLocatorTest.php b/src/Symfony/Component/Config/Tests/FileLocatorTest.php index e931916af9..4bdc945125 100644 --- a/src/Symfony/Component/Config/Tests/FileLocatorTest.php +++ b/src/Symfony/Component/Config/Tests/FileLocatorTest.php @@ -88,7 +88,7 @@ class FileLocatorTest extends TestCase public function testLocateThrowsAnExceptionIfTheFileDoesNotExists() { - $this->expectException('Symfony\Component\Config\Exception\FileLocatorFileNotFoundException'); + $this->expectException(\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException::class); $this->expectExceptionMessage('The file "foobar.xml" does not exist'); $loader = new FileLocator([__DIR__.'/Fixtures']); @@ -97,7 +97,7 @@ class FileLocatorTest extends TestCase public function testLocateThrowsAnExceptionIfTheFileDoesNotExistsInAbsolutePath() { - $this->expectException('Symfony\Component\Config\Exception\FileLocatorFileNotFoundException'); + $this->expectException(\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException::class); $loader = new FileLocator([__DIR__.'/Fixtures']); $loader->locate(__DIR__.'/Fixtures/foobar.xml', __DIR__); @@ -105,7 +105,7 @@ class FileLocatorTest extends TestCase public function testLocateEmpty() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('An empty file name is not valid to be located.'); $loader = new FileLocator([__DIR__.'/Fixtures']); diff --git a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php index 78c83044d8..2de74c4022 100644 --- a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php @@ -34,12 +34,12 @@ class DelegatingLoaderTest extends TestCase public function testSupports() { - $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader1 = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $loader1->expects($this->once())->method('supports')->willReturn(true); $loader = new DelegatingLoader(new LoaderResolver([$loader1])); $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); - $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader1 = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $loader1->expects($this->once())->method('supports')->willReturn(false); $loader = new DelegatingLoader(new LoaderResolver([$loader1])); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); @@ -47,7 +47,7 @@ class DelegatingLoaderTest extends TestCase public function testLoad() { - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $loader->expects($this->once())->method('supports')->willReturn(true); $loader->expects($this->once())->method('load'); $resolver = new LoaderResolver([$loader]); @@ -58,8 +58,8 @@ class DelegatingLoaderTest extends TestCase public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded() { - $this->expectException('Symfony\Component\Config\Exception\LoaderLoadException'); - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $this->expectException(\Symfony\Component\Config\Exception\LoaderLoadException::class); + $loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $loader->expects($this->once())->method('supports')->willReturn(false); $resolver = new LoaderResolver([$loader]); $loader = new DelegatingLoader($resolver); diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php index fc7a66c3b1..61fdabe039 100644 --- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php @@ -20,9 +20,9 @@ class FileLoaderTest extends TestCase { public function testImportWithFileLocatorDelegation() { - $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locatorMock = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); - $locatorMockForAdditionalLoader = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locatorMockForAdditionalLoader = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls( ['path/to/file1'], // Default ['path/to/file1', 'path/to/file2'], // First is imported @@ -55,7 +55,7 @@ class FileLoaderTest extends TestCase $fileLoader->import('my_resource'); $this->fail('->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException', $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); + $this->assertInstanceOf(\Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException::class, $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); } // Check exception throws if all files are already loading @@ -64,13 +64,13 @@ class FileLoaderTest extends TestCase $fileLoader->import('my_resource'); $this->fail('->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException', $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); + $this->assertInstanceOf(\Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException::class, $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading'); } } public function testImportWithGlobLikeResource() { - $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locatorMock = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $locatorMock->expects($this->once())->method('locate')->willReturn(''); $loader = new TestFileLoader($locatorMock); @@ -79,7 +79,7 @@ class FileLoaderTest extends TestCase public function testImportWithGlobLikeResourceWhichContainsSlashes() { - $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locatorMock = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $locatorMock->expects($this->once())->method('locate')->willReturn(''); $loader = new TestFileLoader($locatorMock); @@ -88,7 +88,7 @@ class FileLoaderTest extends TestCase public function testImportWithGlobLikeResourceWhichContainsMultipleLines() { - $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locatorMock = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $loader = new TestFileLoader($locatorMock); $this->assertSame("foo\nfoobar[foo]", $loader->import("foo\nfoobar[foo]")); @@ -96,7 +96,7 @@ class FileLoaderTest extends TestCase public function testImportWithGlobLikeResourceWhichContainsSlashesAndMultipleLines() { - $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locatorMock = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $loader = new TestFileLoader($locatorMock); $this->assertSame("foo\nfoo/bar[foo]", $loader->import("foo\nfoo/bar[foo]")); @@ -104,7 +104,7 @@ class FileLoaderTest extends TestCase public function testImportWithNoGlobMatch() { - $locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locatorMock = $this->getMockBuilder(\Symfony\Component\Config\FileLocatorInterface::class)->getMock(); $locatorMock->expects($this->once())->method('locate')->willReturn(''); $loader = new TestFileLoader($locatorMock); diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php index aabc2a600d..90d1ef0911 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php @@ -19,7 +19,7 @@ class LoaderResolverTest extends TestCase public function testConstructor() { $resolver = new LoaderResolver([ - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(), + $loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(), ]); $this->assertEquals([$loader], $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument'); @@ -27,11 +27,11 @@ class LoaderResolverTest extends TestCase public function testResolve() { - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $resolver = new LoaderResolver([$loader]); $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource'); - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $loader->expects($this->once())->method('supports')->willReturn(true); $resolver = new LoaderResolver([$loader]); $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource'); @@ -40,7 +40,7 @@ class LoaderResolverTest extends TestCase public function testLoaders() { $resolver = new LoaderResolver(); - $resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock()); + $resolver->addLoader($loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock()); $this->assertEquals([$loader], $resolver->getLoaders(), 'addLoader() adds a loader'); } diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php index b52e6322c0..7eb50d62a0 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php @@ -18,7 +18,7 @@ class LoaderTest extends TestCase { public function testGetSetResolver() { - $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $resolver = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderResolverInterface::class)->getMock(); $loader = new ProjectLoader1(); $loader->setResolver($resolver); @@ -28,9 +28,9 @@ class LoaderTest extends TestCase public function testResolve() { - $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $resolvedLoader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); - $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $resolver = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderResolverInterface::class)->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo.xml') @@ -45,8 +45,8 @@ class LoaderTest extends TestCase public function testResolveWhenResolverCannotFindLoader() { - $this->expectException('Symfony\Component\Config\Exception\LoaderLoadException'); - $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $this->expectException(\Symfony\Component\Config\Exception\LoaderLoadException::class); + $resolver = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderResolverInterface::class)->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('FOOBAR') @@ -60,13 +60,13 @@ class LoaderTest extends TestCase public function testImport() { - $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $resolvedLoader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $resolvedLoader->expects($this->once()) ->method('load') ->with('foo') ->willReturn('yes'); - $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $resolver = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderResolverInterface::class)->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo') @@ -80,13 +80,13 @@ class LoaderTest extends TestCase public function testImportWithType() { - $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $resolvedLoader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $resolvedLoader->expects($this->once()) ->method('load') ->with('foo', 'bar') ->willReturn('yes'); - $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $resolver = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderResolverInterface::class)->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo', 'bar') diff --git a/src/Symfony/Component/Config/Tests/Resource/ClassExistenceResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ClassExistenceResourceTest.php index 99098066de..733c47e40b 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ClassExistenceResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/ClassExistenceResourceTest.php @@ -85,7 +85,7 @@ EOF public function testBadParentWithNoTimestamp() { - $this->expectException('ReflectionException'); + $this->expectException(\ReflectionException::class); $this->expectExceptionMessage('Class "Symfony\Component\Config\Tests\Fixtures\MissingParent" not found while loading "Symfony\Component\Config\Tests\Fixtures\BadParent".'); $res = new ClassExistenceResource(BadParent::class, false); @@ -94,7 +94,7 @@ EOF public function testBadFileName() { - $this->expectException('ReflectionException'); + $this->expectException(\ReflectionException::class); $this->expectExceptionMessage('Mismatch between file name and class name.'); $res = new ClassExistenceResource(BadFileName::class, false); @@ -103,7 +103,7 @@ EOF public function testBadFileNameBis() { - $this->expectException('ReflectionException'); + $this->expectException(\ReflectionException::class); $this->expectExceptionMessage('Mismatch between file name and class name.'); $res = new ClassExistenceResource(BadFileName::class, false); @@ -119,7 +119,7 @@ EOF public function testParseError() { - $this->expectException('ParseError'); + $this->expectException(\ParseError::class); $res = new ClassExistenceResource(ParseError::class, false); $res->isFresh(0); diff --git a/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php index a956acd87f..3de58f4be0 100644 --- a/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php @@ -65,7 +65,7 @@ class DirectoryResourceTest extends TestCase public function testResourceDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The directory ".*" does not exist./'); new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999)); } diff --git a/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php index 9b619a0fe6..de2423830a 100644 --- a/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php @@ -53,7 +53,7 @@ class FileResourceTest extends TestCase public function testResourceDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The file ".*" does not exist./'); new FileResource('/____foo/foobar'.mt_rand(1, 999999)); } diff --git a/src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php index a30fbe8c43..7958332cb0 100644 --- a/src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php @@ -34,7 +34,7 @@ class GlobResourceTest extends TestCase $file = $dir.'/Resource'.\DIRECTORY_SEPARATOR.'ConditionalClass.php'; $this->assertEquals([$file => new \SplFileInfo($file)], $paths); - $this->assertInstanceOf('SplFileInfo', current($paths)); + $this->assertInstanceOf(\SplFileInfo::class, current($paths)); $this->assertSame($dir, $resource->getPrefix()); $resource = new GlobResource($dir, '/**/Resource', true); @@ -43,7 +43,7 @@ class GlobResourceTest extends TestCase $file = $dir.\DIRECTORY_SEPARATOR.'Resource'.\DIRECTORY_SEPARATOR.'ConditionalClass.php'; $this->assertEquals([$file => $file], $paths); - $this->assertInstanceOf('SplFileInfo', current($paths)); + $this->assertInstanceOf(\SplFileInfo::class, current($paths)); $this->assertSame($dir, $resource->getPrefix()); } diff --git a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php index 413a495825..af0c2cd2c9 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php @@ -21,7 +21,7 @@ class ReflectionClassResourceTest extends TestCase { public function testToString() { - $res = new ReflectionClassResource(new \ReflectionClass('ErrorException')); + $res = new ReflectionClassResource(new \ReflectionClass(\ErrorException::class)); $this->assertSame('reflection.ErrorException', (string) $res); } @@ -54,7 +54,7 @@ class ReflectionClassResourceTest extends TestCase file_put_contents($tmp, 'assertTrue($res->isFresh($now)); unlink($tmp); diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index f0b77ae6f6..386d97c99a 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -84,13 +84,13 @@ class XmlUtilsTest extends TestCase $this->assertMatchesRegularExpression('/The XML file ".+" is not valid\./', $e->getMessage()); } - $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate'])); + $this->assertInstanceOf(\DOMDocument::class, XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate'])); $this->assertSame([], libxml_get_errors()); } public function testParseWithInvalidValidatorCallable() { - $this->expectException('Symfony\Component\Config\Util\Exception\InvalidXmlException'); + $this->expectException(\Symfony\Component\Config\Util\Exception\InvalidXmlException::class); $this->expectExceptionMessage('The XML is not valid'); $fixtures = __DIR__.'/../Fixtures/Util/'; @@ -105,7 +105,7 @@ class XmlUtilsTest extends TestCase $internalErrors = libxml_use_internal_errors(true); $this->assertSame([], libxml_get_errors()); - $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/invalid_schema.xml')); + $this->assertInstanceOf(\DOMDocument::class, XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/invalid_schema.xml')); $this->assertSame([], libxml_get_errors()); libxml_clear_errors(); @@ -190,7 +190,7 @@ class XmlUtilsTest extends TestCase { $file = __DIR__.'/../Fixtures/foo.xml'; - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage(sprintf('File "%s" does not contain valid XML, it is empty.', $file)); XmlUtils::loadFile($file); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 8361635aeb..004b40955d 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -134,7 +134,7 @@ class ApplicationTest extends TestCase { $application = new Application(); $commands = $application->all(); - $this->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $commands['help'], '->all() returns the registered commands'); + $this->assertInstanceOf(\Symfony\Component\Console\Command\HelpCommand::class, $commands['help'], '->all() returns the registered commands'); $application->add(new \FooCommand()); $commands = $application->all('foo'); @@ -145,7 +145,7 @@ class ApplicationTest extends TestCase { $application = new Application(); $commands = $application->all(); - $this->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $commands['help'], '->all() returns the registered commands'); + $this->assertInstanceOf(\Symfony\Component\Console\Command\HelpCommand::class, $commands['help'], '->all() returns the registered commands'); $application->add(new \FooCommand()); $commands = $application->all('foo'); @@ -204,7 +204,7 @@ class ApplicationTest extends TestCase public function testAddCommandWithEmptyConstructor() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Command class "Foo5Command" is not correctly initialized. You probably forgot to call the parent constructor.'); $application = new Application(); $application->add(new \Foo5Command()); @@ -229,7 +229,7 @@ class ApplicationTest extends TestCase $p->setAccessible(true); $p->setValue($application, true); $command = $application->get('foo:bar'); - $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $command, '->get() returns the help command if --help is provided as the input'); + $this->assertInstanceOf(\Symfony\Component\Console\Command\HelpCommand::class, $command, '->get() returns the help command if --help is provided as the input'); } public function testHasGetWithCommandLoader() @@ -270,7 +270,7 @@ class ApplicationTest extends TestCase public function testGetInvalidCommand() { - $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectException(CommandNotFoundException::class); $this->expectExceptionMessage('The command "foofoo" does not exist.'); $application = new Application(); $application->get('foofoo'); @@ -327,7 +327,7 @@ class ApplicationTest extends TestCase public function testFindInvalidNamespace() { - $this->expectException('Symfony\Component\Console\Exception\NamespaceNotFoundException'); + $this->expectException(NamespaceNotFoundException::class); $this->expectExceptionMessage('There are no commands defined in the "bar" namespace.'); $application = new Application(); $application->findNamespace('bar'); @@ -335,7 +335,7 @@ class ApplicationTest extends TestCase public function testFindUniqueNameButNamespaceName() { - $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectException(CommandNotFoundException::class); $this->expectExceptionMessage('Command "foo1" is not defined'); $application = new Application(); $application->add(new \FooCommand()); @@ -350,11 +350,11 @@ class ApplicationTest extends TestCase $application = new Application(); $application->add(new \FooCommand()); - $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); - $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists'); - $this->assertInstanceOf('FooCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); - $this->assertInstanceOf('FooCommand', $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); - $this->assertInstanceOf('FooCommand', $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); + $this->assertInstanceOf(\FooCommand::class, $application->find('foo:bar'), '->find() returns a command if its name exists'); + $this->assertInstanceOf(\Symfony\Component\Console\Command\HelpCommand::class, $application->find('h'), '->find() returns a command if its name exists'); + $this->assertInstanceOf(\FooCommand::class, $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); + $this->assertInstanceOf(\FooCommand::class, $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); + $this->assertInstanceOf(\FooCommand::class, $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); } public function testFindCaseSensitiveFirst() @@ -363,10 +363,10 @@ class ApplicationTest extends TestCase $application->add(new \FooSameCaseUppercaseCommand()); $application->add(new \FooSameCaseLowercaseCommand()); - $this->assertInstanceOf('FooSameCaseUppercaseCommand', $application->find('f:B'), '->find() returns a command if the abbreviation is the correct case'); - $this->assertInstanceOf('FooSameCaseUppercaseCommand', $application->find('f:BAR'), '->find() returns a command if the abbreviation is the correct case'); - $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:b'), '->find() returns a command if the abbreviation is the correct case'); - $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation is the correct case'); + $this->assertInstanceOf(\FooSameCaseUppercaseCommand::class, $application->find('f:B'), '->find() returns a command if the abbreviation is the correct case'); + $this->assertInstanceOf(\FooSameCaseUppercaseCommand::class, $application->find('f:BAR'), '->find() returns a command if the abbreviation is the correct case'); + $this->assertInstanceOf(\FooSameCaseLowercaseCommand::class, $application->find('f:b'), '->find() returns a command if the abbreviation is the correct case'); + $this->assertInstanceOf(\FooSameCaseLowercaseCommand::class, $application->find('f:bar'), '->find() returns a command if the abbreviation is the correct case'); } public function testFindCaseInsensitiveAsFallback() @@ -374,20 +374,20 @@ class ApplicationTest extends TestCase $application = new Application(); $application->add(new \FooSameCaseLowercaseCommand()); - $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:b'), '->find() returns a command if the abbreviation is the correct case'); - $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('f:B'), '->find() will fallback to case insensitivity'); - $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('FoO:BaR'), '->find() will fallback to case insensitivity'); + $this->assertInstanceOf(\FooSameCaseLowercaseCommand::class, $application->find('f:b'), '->find() returns a command if the abbreviation is the correct case'); + $this->assertInstanceOf(\FooSameCaseLowercaseCommand::class, $application->find('f:B'), '->find() will fallback to case insensitivity'); + $this->assertInstanceOf(\FooSameCaseLowercaseCommand::class, $application->find('FoO:BaR'), '->find() will fallback to case insensitivity'); } public function testFindCaseInsensitiveSuggestions() { - $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectException(CommandNotFoundException::class); $this->expectExceptionMessage('Command "FoO:BaR" is ambiguous'); $application = new Application(); $application->add(new \FooSameCaseLowercaseCommand()); $application->add(new \FooSameCaseUppercaseCommand()); - $this->assertInstanceOf('FooSameCaseLowercaseCommand', $application->find('FoO:BaR'), '->find() will find two suggestions with case insensitivity'); + $this->assertInstanceOf(\FooSameCaseLowercaseCommand::class, $application->find('FoO:BaR'), '->find() will find two suggestions with case insensitivity'); } public function testFindWithCommandLoader() @@ -397,11 +397,11 @@ class ApplicationTest extends TestCase 'foo:bar' => $f = function () { return new \FooCommand(); }, ])); - $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); - $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists'); - $this->assertInstanceOf('FooCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); - $this->assertInstanceOf('FooCommand', $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); - $this->assertInstanceOf('FooCommand', $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); + $this->assertInstanceOf(\FooCommand::class, $application->find('foo:bar'), '->find() returns a command if its name exists'); + $this->assertInstanceOf(\Symfony\Component\Console\Command\HelpCommand::class, $application->find('h'), '->find() returns a command if its name exists'); + $this->assertInstanceOf(\FooCommand::class, $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); + $this->assertInstanceOf(\FooCommand::class, $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); + $this->assertInstanceOf(\FooCommand::class, $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); } /** @@ -410,7 +410,7 @@ class ApplicationTest extends TestCase public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage) { putenv('COLUMNS=120'); - $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectException(CommandNotFoundException::class); $this->expectExceptionMessage($expectedExceptionMessage); $application = new Application(); @@ -449,7 +449,7 @@ class ApplicationTest extends TestCase $application->add(new \FooCommand()); $application->add(new \FooHiddenCommand()); - $this->assertInstanceOf('FooCommand', $application->find('foo:')); + $this->assertInstanceOf(\FooCommand::class, $application->find('foo:')); } public function testFindCommandEqualNamespace() @@ -458,8 +458,8 @@ class ApplicationTest extends TestCase $application->add(new \Foo3Command()); $application->add(new \Foo4Command()); - $this->assertInstanceOf('Foo3Command', $application->find('foo3:bar'), '->find() returns the good command even if a namespace has same name'); - $this->assertInstanceOf('Foo4Command', $application->find('foo3:bar:toh'), '->find() returns a command even if its namespace equals another command name'); + $this->assertInstanceOf(\Foo3Command::class, $application->find('foo3:bar'), '->find() returns the good command even if a namespace has same name'); + $this->assertInstanceOf(\Foo4Command::class, $application->find('foo3:bar:toh'), '->find() returns a command even if its namespace equals another command name'); } public function testFindCommandWithAmbiguousNamespacesButUniqueName() @@ -468,7 +468,7 @@ class ApplicationTest extends TestCase $application->add(new \FooCommand()); $application->add(new \FoobarCommand()); - $this->assertInstanceOf('FoobarCommand', $application->find('f:f')); + $this->assertInstanceOf(\FoobarCommand::class, $application->find('f:f')); } public function testFindCommandWithMissingNamespace() @@ -476,7 +476,7 @@ class ApplicationTest extends TestCase $application = new Application(); $application->add(new \Foo4Command()); - $this->assertInstanceOf('Foo4Command', $application->find('f::t')); + $this->assertInstanceOf(\Foo4Command::class, $application->find('f::t')); } /** @@ -484,7 +484,7 @@ class ApplicationTest extends TestCase */ public function testFindAlternativeExceptionMessageSingle($name) { - $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectException(CommandNotFoundException::class); $this->expectExceptionMessage('Did you mean this'); $application = new Application(); $application->add(new \Foo3Command()); @@ -558,7 +558,7 @@ class ApplicationTest extends TestCase $application->find('foo:baR'); $this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertInstanceOf(CommandNotFoundException::class, $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertMatchesRegularExpression('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertMatchesRegularExpression('/foo1:bar/', $e->getMessage()); $this->assertMatchesRegularExpression('/foo:bar/', $e->getMessage()); @@ -569,7 +569,7 @@ class ApplicationTest extends TestCase $application->find('foo2:bar'); $this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); + $this->assertInstanceOf(CommandNotFoundException::class, $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertMatchesRegularExpression('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertMatchesRegularExpression('/foo1/', $e->getMessage()); } @@ -582,7 +582,7 @@ class ApplicationTest extends TestCase $application->find('foo3:'); $this->fail('->find() should throw an Symfony\Component\Console\Exception\CommandNotFoundException if a command is ambiguous because of a subnamespace, with alternatives'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e); + $this->assertInstanceOf(CommandNotFoundException::class, $e); $this->assertMatchesRegularExpression('/foo3:bar/', $e->getMessage()); $this->assertMatchesRegularExpression('/foo3:bar:toh/', $e->getMessage()); } @@ -600,7 +600,7 @@ class ApplicationTest extends TestCase $application->find($commandName = 'Unknown command'); $this->fail('->find() throws a CommandNotFoundException if command does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist'); + $this->assertInstanceOf(CommandNotFoundException::class, $e, '->find() throws a CommandNotFoundException if command does not exist'); $this->assertSame([], $e->getAlternatives()); $this->assertEquals(sprintf('Command "%s" is not defined.', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without alternatives'); } @@ -611,7 +611,7 @@ class ApplicationTest extends TestCase $application->find($commandName = 'bar1'); $this->fail('->find() throws a CommandNotFoundException if command does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist'); + $this->assertInstanceOf(CommandNotFoundException::class, $e, '->find() throws a CommandNotFoundException if command does not exist'); $this->assertSame(['afoobar1', 'foo:bar1'], $e->getAlternatives()); $this->assertMatchesRegularExpression(sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives'); $this->assertMatchesRegularExpression('/afoobar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "afoobar1"'); @@ -649,7 +649,7 @@ class ApplicationTest extends TestCase $application->find('Unknown-namespace:Unknown-command'); $this->fail('->find() throws a CommandNotFoundException if namespace does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if namespace does not exist'); + $this->assertInstanceOf(CommandNotFoundException::class, $e, '->find() throws a CommandNotFoundException if namespace does not exist'); $this->assertSame([], $e->getAlternatives()); $this->assertEquals('There are no commands defined in the "Unknown-namespace" namespace.', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, without alternatives'); } @@ -658,8 +658,8 @@ class ApplicationTest extends TestCase $application->find('foo2:command'); $this->fail('->find() throws a CommandNotFoundException if namespace does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Console\Exception\NamespaceNotFoundException', $e, '->find() throws a NamespaceNotFoundException if namespace does not exist'); - $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, 'NamespaceNotFoundException extends from CommandNotFoundException'); + $this->assertInstanceOf(NamespaceNotFoundException::class, $e, '->find() throws a NamespaceNotFoundException if namespace does not exist'); + $this->assertInstanceOf(CommandNotFoundException::class, $e, 'NamespaceNotFoundException extends from CommandNotFoundException'); $this->assertCount(3, $e->getAlternatives()); $this->assertContains('foo', $e->getAlternatives()); $this->assertContains('foo1', $e->getAlternatives()); @@ -695,7 +695,7 @@ class ApplicationTest extends TestCase $application->find('foo'); $this->fail('->find() throws a CommandNotFoundException if command is not defined'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command is not defined'); + $this->assertInstanceOf(CommandNotFoundException::class, $e, '->find() throws a CommandNotFoundException if command is not defined'); $this->assertSame($expectedAlternatives, $e->getAlternatives()); $this->assertMatchesRegularExpression('/Command "foo" is not defined\..*Did you mean one of these\?.*/Ums', $e->getMessage()); @@ -704,7 +704,7 @@ class ApplicationTest extends TestCase public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces() { - $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getNamespaces'])->getMock(); + $application = $this->getMockBuilder(Application::class)->setMethods(['getNamespaces'])->getMock(); $application->expects($this->once()) ->method('getNamespaces') ->willReturn(['foo:sublong', 'bar:sub']); @@ -714,7 +714,7 @@ class ApplicationTest extends TestCase public function testFindWithDoubleColonInNameThrowsException() { - $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectException(CommandNotFoundException::class); $this->expectExceptionMessage('Command "foo::bar" is not defined.'); $application = new Application(); $application->add(new \FooCommand()); @@ -727,8 +727,8 @@ class ApplicationTest extends TestCase $application = new Application(); $application->add(new \FooHiddenCommand()); - $this->assertInstanceOf('FooHiddenCommand', $application->find('foo:hidden')); - $this->assertInstanceOf('FooHiddenCommand', $application->find('afoohidden')); + $this->assertInstanceOf(\FooHiddenCommand::class, $application->find('foo:hidden')); + $this->assertInstanceOf(\FooHiddenCommand::class, $application->find('afoohidden')); } /** @@ -878,7 +878,7 @@ class ApplicationTest extends TestCase public function testRenderExceptionLineBreaks() { - $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getTerminalWidth'])->getMock(); + $application = $this->getMockBuilder(Application::class)->setMethods(['getTerminalWidth'])->getMock(); $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') @@ -950,8 +950,8 @@ class ApplicationTest extends TestCase $application->run(); ob_end_clean(); - $this->assertInstanceOf('Symfony\Component\Console\Input\ArgvInput', $command->input, '->run() creates an ArgvInput by default if none is given'); - $this->assertInstanceOf('Symfony\Component\Console\Output\ConsoleOutput', $command->output, '->run() creates a ConsoleOutput by default if none is given'); + $this->assertInstanceOf(ArgvInput::class, $command->input, '->run() creates an ArgvInput by default if none is given'); + $this->assertInstanceOf(\Symfony\Component\Console\Output\ConsoleOutput::class, $command->output, '->run() creates a ConsoleOutput by default if none is given'); $application = new Application(); $application->setAutoExit(false); @@ -1076,7 +1076,7 @@ class ApplicationTest extends TestCase { $exception = new \Exception('', 4); - $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['doRun'])->getMock(); + $application = $this->getMockBuilder(Application::class)->setMethods(['doRun'])->getMock(); $application->setAutoExit(false); $application->expects($this->once()) ->method('doRun') @@ -1115,7 +1115,7 @@ class ApplicationTest extends TestCase { $exception = new \Exception('', 0); - $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['doRun'])->getMock(); + $application = $this->getMockBuilder(Application::class)->setMethods(['doRun'])->getMock(); $application->setAutoExit(false); $application->expects($this->once()) ->method('doRun') @@ -1152,7 +1152,7 @@ class ApplicationTest extends TestCase public function testAddingOptionWithDuplicateShortcut() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('An option with shortcut "e" already exists.'); $dispatcher = new EventDispatcher(); $application = new Application(); @@ -1180,7 +1180,7 @@ class ApplicationTest extends TestCase */ public function testAddingAlreadySetDefinitionElementData($def) { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $application = new Application(); $application->setAutoExit(false); $application->setCatchExceptions(false); @@ -1331,7 +1331,7 @@ class ApplicationTest extends TestCase public function testRunWithExceptionAndDispatcher() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('error'); $application = new Application(); $application->setDispatcher($this->getDispatcher()); @@ -1474,7 +1474,7 @@ class ApplicationTest extends TestCase public function testRunWithErrorAndDispatcher() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('error'); $application = new Application(); $application->setDispatcher($this->getDispatcher()); @@ -1686,7 +1686,7 @@ class ApplicationTest extends TestCase public function testGetDisabledLazyCommand() { - $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectException(CommandNotFoundException::class); $application = new Application(); $application->setCommandLoader(new FactoryCommandLoader(['disabled' => function () { return new DisabledCommand(); }])); $application->get('disabled'); @@ -1779,7 +1779,7 @@ class ApplicationTest extends TestCase public function testThrowingErrorListener() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('foo'); $dispatcher = $this->getDispatcher(); $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index d82b0d03ae..34156f7b52 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -42,7 +42,7 @@ class CommandTest extends TestCase public function testCommandNameCannotBeEmpty() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('The command defined in "Symfony\Component\Console\Command\Command" cannot have an empty name.'); (new Application())->add(new Command()); } @@ -115,7 +115,7 @@ class CommandTest extends TestCase */ public function testInvalidCommandNames($name) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name)); $command = new \TestCommand(); @@ -182,7 +182,7 @@ class CommandTest extends TestCase public function testSetAliasesNull() { $command = new \TestCommand(); - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $command->setAliases(null); } @@ -214,7 +214,7 @@ class CommandTest extends TestCase public function testGetHelperWithoutHelperSet() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot retrieve helper "formatter" because there is no HelperSet defined.'); $command = new \TestCommand(); $command->getHelper('formatter'); @@ -285,7 +285,7 @@ class CommandTest extends TestCase public function testExecuteMethodNeedsToBeOverridden() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('You must override the execute() method in the concrete command class.'); $command = new Command('foo'); $command->run(new StringInput(''), new NullOutput()); @@ -293,7 +293,7 @@ class CommandTest extends TestCase public function testRunWithInvalidOption() { - $this->expectException('Symfony\Component\Console\Exception\InvalidOptionException'); + $this->expectException(\Symfony\Component\Console\Exception\InvalidOptionException::class); $this->expectExceptionMessage('The "--bar" option does not exist.'); $command = new \TestCommand(); $tester = new CommandTester($command); diff --git a/src/Symfony/Component/Console/Tests/CommandLoader/ContainerCommandLoaderTest.php b/src/Symfony/Component/Console/Tests/CommandLoader/ContainerCommandLoaderTest.php index 50fe125a64..67b2d5ceec 100644 --- a/src/Symfony/Component/Console/Tests/CommandLoader/ContainerCommandLoaderTest.php +++ b/src/Symfony/Component/Console/Tests/CommandLoader/ContainerCommandLoaderTest.php @@ -43,7 +43,7 @@ class ContainerCommandLoaderTest extends TestCase public function testGetUnknownCommandThrows() { - $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectException(\Symfony\Component\Console\Exception\CommandNotFoundException::class); (new ContainerCommandLoader(new ServiceLocator([]), []))->get('unknown'); } diff --git a/src/Symfony/Component/Console/Tests/CommandLoader/FactoryCommandLoaderTest.php b/src/Symfony/Component/Console/Tests/CommandLoader/FactoryCommandLoaderTest.php index a37ad18de1..8546ae669c 100644 --- a/src/Symfony/Component/Console/Tests/CommandLoader/FactoryCommandLoaderTest.php +++ b/src/Symfony/Component/Console/Tests/CommandLoader/FactoryCommandLoaderTest.php @@ -42,7 +42,7 @@ class FactoryCommandLoaderTest extends TestCase public function testGetUnknownCommandThrows() { - $this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException'); + $this->expectException(\Symfony\Component\Console\Exception\CommandNotFoundException::class); (new FactoryCommandLoader([]))->get('unknown'); } diff --git a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php index e80880826e..5e59f8fab3 100644 --- a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php +++ b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php @@ -120,7 +120,7 @@ class AddConsoleCommandPassTest extends TestCase public function testProcessThrowAnExceptionIfTheServiceIsAbstract() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The service "my-command" tagged "console.command" must not be abstract.'); $container = new ContainerBuilder(); $container->setResourceTracking(false); @@ -136,7 +136,7 @@ class AddConsoleCommandPassTest extends TestCase public function testProcessThrowAnExceptionIfTheServiceIsNotASubclassOfCommand() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The service "my-command" tagged "console.command" must be a subclass of "Symfony\Component\Console\Command\Command".'); $container = new ContainerBuilder(); $container->setResourceTracking(false); @@ -221,7 +221,7 @@ class AddConsoleCommandPassTest extends TestCase public function testProcessOnChildDefinitionWithoutClass() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('The definition for "my-child-command" has no class.'); $container = new ContainerBuilder(); $container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING); diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleStackTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleStackTest.php index d3020432ef..7fbe4f4151 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleStackTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleStackTest.php @@ -61,7 +61,7 @@ class OutputFormatterStyleStackTest extends TestCase public function testInvalidPop() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $stack = new OutputFormatterStyleStack(); $stack->push(new OutputFormatterStyle('white', 'black')); $stack->pop(new OutputFormatterStyle('yellow', 'blue')); diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php index 7c1a422301..00dfa19c83 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php @@ -41,7 +41,7 @@ class OutputFormatterStyleTest extends TestCase $style->setForeground('default'); $this->assertEquals("\033[39mfoo\033[39m", $style->apply('foo')); - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $style->setForeground('undefined-color'); } @@ -58,7 +58,7 @@ class OutputFormatterStyleTest extends TestCase $style->setBackground('default'); $this->assertEquals("\033[49mfoo\033[49m", $style->apply('foo')); - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $style->setBackground('undefined-color'); } diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php index 9a8ca07bc6..707a190cf4 100644 --- a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php @@ -68,7 +68,7 @@ class HelperSetTest extends TestCase $this->fail('->get() throws InvalidArgumentException when helper not found'); } catch (\Exception $e) { $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->get() throws InvalidArgumentException when helper not found'); - $this->assertInstanceOf('Symfony\Component\Console\Exception\ExceptionInterface', $e, '->get() throws domain specific exception when helper not found'); + $this->assertInstanceOf(\Symfony\Component\Console\Exception\ExceptionInterface::class, $e, '->get() throws domain specific exception when helper not found'); $this->assertStringContainsString('The helper "foo" is not defined.', $e->getMessage(), '->get() throws InvalidArgumentException when helper not found'); } } diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php index 986646794b..bbbde217cb 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressIndicatorTest.php @@ -102,14 +102,14 @@ class ProgressIndicatorTest extends TestCase public function testCannotSetInvalidIndicatorCharacters() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Must have at least 2 indicator value characters.'); new ProgressIndicator($this->getOutputStream(), null, 100, ['1']); } public function testCannotStartAlreadyStartedIndicator() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Progress indicator already started.'); $bar = new ProgressIndicator($this->getOutputStream()); $bar->start('Starting...'); @@ -118,7 +118,7 @@ class ProgressIndicatorTest extends TestCase public function testCannotAdvanceUnstartedIndicator() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Progress indicator has not yet been started.'); $bar = new ProgressIndicator($this->getOutputStream()); $bar->advance(); @@ -126,7 +126,7 @@ class ProgressIndicatorTest extends TestCase public function testCannotFinishUnstartedIndicator() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Progress indicator has not yet been started.'); $bar = new ProgressIndicator($this->getOutputStream()); $bar->finish('Finished'); diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 871524e444..5db0ded772 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -633,7 +633,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest public function testAmbiguousChoiceFromChoicelist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The provided answer is ambiguous. Value should be one of "env_2" or "env_3".'); $possibleChoices = [ 'env_1' => 'My first environment', @@ -700,7 +700,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest public function testAskThrowsExceptionOnMissingInput() { - $this->expectException('Symfony\Component\Console\Exception\MissingInputException'); + $this->expectException(\Symfony\Component\Console\Exception\MissingInputException::class); $this->expectExceptionMessage('Aborted.'); $dialog = new QuestionHelper(); $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new Question('What\'s your name?')); @@ -708,7 +708,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest public function testAskThrowsExceptionOnMissingInputForChoiceQuestion() { - $this->expectException('Symfony\Component\Console\Exception\MissingInputException'); + $this->expectException(\Symfony\Component\Console\Exception\MissingInputException::class); $this->expectExceptionMessage('Aborted.'); $dialog = new QuestionHelper(); $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new ChoiceQuestion('Choice', ['a', 'b'])); @@ -716,7 +716,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest public function testAskThrowsExceptionOnMissingInputWithValidator() { - $this->expectException('Symfony\Component\Console\Exception\MissingInputException'); + $this->expectException(\Symfony\Component\Console\Exception\MissingInputException::class); $this->expectExceptionMessage('Aborted.'); $dialog = new QuestionHelper(); @@ -764,7 +764,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest public function testEmptyChoices() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Choice question must have at least 1 choice available.'); new ChoiceQuestion('Question', [], 'irrelevant'); } @@ -878,7 +878,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest protected function createInputInterfaceMock($interactive = true) { - $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $mock = $this->getMockBuilder(\Symfony\Component\Console\Input\InputInterface::class)->getMock(); $mock->expects($this->any()) ->method('isInteractive') ->willReturn($interactive); diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index 06f20e2b1b..d7fcf7ecfd 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -124,7 +124,7 @@ class SymfonyQuestionHelperTest extends AbstractQuestionHelperTest public function testAskThrowsExceptionOnMissingInput() { - $this->expectException('Symfony\Component\Console\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class); $this->expectExceptionMessage('Aborted.'); $dialog = new SymfonyQuestionHelper(); $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new Question('What\'s your name?')); @@ -192,7 +192,7 @@ EOT protected function createInputInterfaceMock($interactive = true) { - $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); + $mock = $this->getMockBuilder(\Symfony\Component\Console\Input\InputInterface::class)->getMock(); $mock->expects($this->any()) ->method('isInteractive') ->willReturn($interactive); diff --git a/src/Symfony/Component/Console/Tests/Helper/TableStyleTest.php b/src/Symfony/Component/Console/Tests/Helper/TableStyleTest.php index 5980192540..a2875852dc 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableStyleTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableStyleTest.php @@ -18,7 +18,7 @@ class TableStyleTest extends TestCase { public function testSetPadTypeWithInvalidType() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); $style = new TableStyle(); $style->setPadType('TEST'); diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index dffaaf902c..3ad71062cf 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -808,7 +808,7 @@ TABLE; public function testThrowsWhenTheCellInAnArray() { - $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Console\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('A cell must be a TableCell, a scalar or an object implementing "__toString()", "array" given.'); $table = new Table($output = $this->getOutputStream()); $table @@ -983,7 +983,7 @@ TABLE; public function testAppendRowWithoutSectionOutput() { - $this->expectException('Symfony\Component\Console\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class); $this->expectExceptionMessage('Output should be an instance of "Symfony\Component\Console\Output\ConsoleSectionOutput" when calling "Symfony\Component\Console\Helper\Table::appendRow".'); $table = new Table($this->getOutputStream()); @@ -1024,7 +1024,7 @@ TABLE; public function testIsNotDefinedStyleException() { - $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Console\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Style "absent" is not defined.'); $table = new Table($this->getOutputStream()); $table->setStyle('absent'); @@ -1032,7 +1032,7 @@ TABLE; public function testGetStyleDefinition() { - $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Console\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Style "absent" is not defined.'); Table::getStyleDefinition('absent'); } diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index 51cc6e5175..4e39f5e93b 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -182,7 +182,7 @@ class ArgvInputTest extends TestCase */ public function testInvalidInput($argv, $definition, $expectedExceptionMessage) { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage($expectedExceptionMessage); $input = new ArgvInput($argv); diff --git a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php index 5e10223dd3..f3eedb3a2d 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php @@ -127,7 +127,7 @@ class ArrayInputTest extends TestCase */ public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage($expectedExceptionMessage); new ArrayInput($parameters, $definition); diff --git a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php index a4c951eead..4e583888a6 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php @@ -39,7 +39,7 @@ class InputArgumentTest extends TestCase public function testInvalidModes() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Argument mode "-1" is not valid.'); new InputArgument('foo', '-1'); @@ -82,7 +82,7 @@ class InputArgumentTest extends TestCase public function testSetDefaultWithRequiredArgument() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot set a default value except for InputArgument::OPTIONAL mode.'); $argument = new InputArgument('foo', InputArgument::REQUIRED); $argument->setDefault('default'); @@ -90,7 +90,7 @@ class InputArgumentTest extends TestCase public function testSetDefaultWithArrayArgument() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('A default value for an array argument must be an array.'); $argument = new InputArgument('foo', InputArgument::IS_ARRAY); $argument->setDefault('default'); diff --git a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php index 4b8f78a1c5..e811a66588 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php @@ -89,7 +89,7 @@ class InputDefinitionTest extends TestCase public function testArgumentsMustHaveDifferentNames() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('An argument with name "foo" already exists.'); $this->initializeArguments(); @@ -100,7 +100,7 @@ class InputDefinitionTest extends TestCase public function testArrayArgumentHasToBeLast() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot add an argument after an array argument.'); $this->initializeArguments(); @@ -111,7 +111,7 @@ class InputDefinitionTest extends TestCase public function testRequiredArgumentCannotFollowAnOptionalOne() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot add a required argument after an optional one.'); $this->initializeArguments(); @@ -131,7 +131,7 @@ class InputDefinitionTest extends TestCase public function testGetInvalidArgument() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "bar" argument does not exist.'); $this->initializeArguments(); @@ -201,7 +201,7 @@ class InputDefinitionTest extends TestCase public function testSetOptionsClearsOptions() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "-f" option does not exist.'); $this->initializeOptions(); @@ -233,7 +233,7 @@ class InputDefinitionTest extends TestCase public function testAddDuplicateOption() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('An option named "foo" already exists.'); $this->initializeOptions(); @@ -244,7 +244,7 @@ class InputDefinitionTest extends TestCase public function testAddDuplicateShortcutOption() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('An option with shortcut "f" already exists.'); $this->initializeOptions(); @@ -263,7 +263,7 @@ class InputDefinitionTest extends TestCase public function testGetInvalidOption() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "--bar" option does not exist.'); $this->initializeOptions(); @@ -308,7 +308,7 @@ class InputDefinitionTest extends TestCase public function testGetOptionForInvalidShortcut() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "-l" option does not exist.'); $this->initializeOptions(); diff --git a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php index d9e2f1d31d..8a5c8fc44b 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php @@ -26,7 +26,7 @@ class InputOptionTest extends TestCase public function testArrayModeWithoutValue() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); new InputOption('foo', 'f', InputOption::VALUE_IS_ARRAY); } @@ -73,7 +73,7 @@ class InputOptionTest extends TestCase public function testInvalidModes() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Option mode "-1" is not valid.'); new InputOption('foo', 'f', '-1'); @@ -81,19 +81,19 @@ class InputOptionTest extends TestCase public function testEmptyNameIsInvalid() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new InputOption(''); } public function testDoubleDashNameIsInvalid() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new InputOption('--'); } public function testSingleDashOptionIsInvalid() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new InputOption('foo', '-'); } @@ -144,7 +144,7 @@ class InputOptionTest extends TestCase public function testDefaultValueWithValueNoneMode() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot set a default value when using InputOption::VALUE_NONE mode.'); $option = new InputOption('foo', 'f', InputOption::VALUE_NONE); $option->setDefault('default'); @@ -152,7 +152,7 @@ class InputOptionTest extends TestCase public function testDefaultValueWithIsArrayMode() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('A default value for an array option must be an array.'); $option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY); $option->setDefault('default'); diff --git a/src/Symfony/Component/Console/Tests/Input/InputTest.php b/src/Symfony/Component/Console/Tests/Input/InputTest.php index 060b750f47..48c287cd9d 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputTest.php @@ -49,7 +49,7 @@ class InputTest extends TestCase public function testSetInvalidOption() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "foo" option does not exist.'); $input = new ArrayInput(['--name' => 'foo'], new InputDefinition([new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')])); $input->setOption('foo', 'bar'); @@ -57,7 +57,7 @@ class InputTest extends TestCase public function testGetInvalidOption() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "foo" option does not exist.'); $input = new ArrayInput(['--name' => 'foo'], new InputDefinition([new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')])); $input->getOption('foo'); @@ -79,7 +79,7 @@ class InputTest extends TestCase public function testSetInvalidArgument() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "foo" argument does not exist.'); $input = new ArrayInput(['name' => 'foo'], new InputDefinition([new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')])); $input->setArgument('foo', 'bar'); @@ -87,7 +87,7 @@ class InputTest extends TestCase public function testGetInvalidArgument() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "foo" argument does not exist.'); $input = new ArrayInput(['name' => 'foo'], new InputDefinition([new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')])); $input->getArgument('foo'); @@ -95,7 +95,7 @@ class InputTest extends TestCase public function testValidateWithMissingArguments() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Not enough arguments (missing: "name").'); $input = new ArrayInput([]); $input->bind(new InputDefinition([new InputArgument('name', InputArgument::REQUIRED)])); @@ -104,7 +104,7 @@ class InputTest extends TestCase public function testValidateWithMissingRequiredArguments() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Not enough arguments (missing: "name").'); $input = new ArrayInput(['bar' => 'baz']); $input->bind(new InputDefinition([new InputArgument('name', InputArgument::REQUIRED), new InputArgument('bar', InputArgument::OPTIONAL)])); diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php index 7f21894526..bcc43e431a 100644 --- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -24,7 +24,7 @@ class StringInputTest extends TestCase public function testTokenize($input, $tokens, $message) { $input = new StringInput($input); - $r = new \ReflectionClass('Symfony\Component\Console\Input\ArgvInput'); + $r = new \ReflectionClass(\Symfony\Component\Console\Input\ArgvInput::class); $p = $r->getProperty('tokens'); $p->setAccessible(true); $this->assertEquals($tokens, $p->getValue($input), $message); diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php index 283eccaf2b..5066c426fe 100644 --- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php +++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php @@ -105,7 +105,7 @@ class ConsoleLoggerTest extends TestCase public function testImplements() { - $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger()); + $this->assertInstanceOf(LoggerInterface::class, $this->getLogger()); } /** @@ -140,7 +140,7 @@ class ConsoleLoggerTest extends TestCase public function testThrowsOnInvalidLevel() { - $this->expectException('Psr\Log\InvalidArgumentException'); + $this->expectException(\Psr\Log\InvalidArgumentException::class); $logger = $this->getLogger(); $logger->log('invalid level', 'Foo'); } diff --git a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php index a434fead42..89debf40c6 100644 --- a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php @@ -38,7 +38,7 @@ class StreamOutputTest extends TestCase public function testStreamIsRequired() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The StreamOutput class needs a stream as its first argument.'); new StreamOutput('foo'); } diff --git a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php index 11a4bfaf4f..244a3f1d01 100644 --- a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -140,7 +140,7 @@ class CommandTesterTest extends TestCase public function testCommandWithWrongInputsNumber() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Aborted.'); $questions = [ 'What\'s your name?', @@ -165,7 +165,7 @@ class CommandTesterTest extends TestCase public function testCommandWithQuestionsButNoInputs() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Aborted.'); $questions = [ 'What\'s your name?', diff --git a/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php b/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php index 82e527c62e..718a5cd347 100644 --- a/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php +++ b/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php @@ -37,7 +37,7 @@ class CssSelectorConverterTest extends TestCase public function testParseExceptions() { - $this->expectException('Symfony\Component\CssSelector\Exception\ParseException'); + $this->expectException(\Symfony\Component\CssSelector\Exception\ParseException::class); $this->expectExceptionMessage('Expected identifier, but found.'); $converter = new CssSelectorConverter(); $converter->toXPath('h1:'); diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php index f63a15e0ab..48a67f5ab6 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php @@ -89,7 +89,7 @@ class ParserTest extends TestCase /** @var FunctionNode $function */ $function = $selectors[0]->getTree(); - $this->expectException('Symfony\Component\CssSelector\Exception\SyntaxErrorException'); + $this->expectException(SyntaxErrorException::class); Parser::parseSeries($function->getArguments()); } diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php index fb47625a89..85cabe9d75 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php @@ -53,7 +53,7 @@ class TokenStreamTest extends TestCase public function testFailToGetNextIdentifier() { - $this->expectException('Symfony\Component\CssSelector\Exception\SyntaxErrorException'); + $this->expectException(\Symfony\Component\CssSelector\Exception\SyntaxErrorException::class); $stream = new TokenStream(); $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); @@ -73,7 +73,7 @@ class TokenStreamTest extends TestCase public function testFailToGetNextIdentifierOrStar() { - $this->expectException('Symfony\Component\CssSelector\Exception\SyntaxErrorException'); + $this->expectException(\Symfony\Component\CssSelector\Exception\SyntaxErrorException::class); $stream = new TokenStream(); $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); diff --git a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php index 568bb42716..57fb19fead 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 public function testCssToXPathPseudoElement() { - $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException'); + $this->expectException(\Symfony\Component\CssSelector\Exception\ExpressionErrorException::class); $translator = new Translator(); $translator->registerExtension(new HtmlExtension($translator)); $translator->cssToXPath('e::first-line'); @@ -45,7 +45,7 @@ class TranslatorTest extends TestCase public function testGetExtensionNotExistsExtension() { - $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException'); + $this->expectException(\Symfony\Component\CssSelector\Exception\ExpressionErrorException::class); $translator = new Translator(); $translator->registerExtension(new HtmlExtension($translator)); $translator->getExtension('fake'); @@ -53,7 +53,7 @@ class TranslatorTest extends TestCase public function testAddCombinationNotExistsExtension() { - $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException'); + $this->expectException(\Symfony\Component\CssSelector\Exception\ExpressionErrorException::class); $translator = new Translator(); $translator->registerExtension(new HtmlExtension($translator)); $parser = new Parser(); @@ -64,7 +64,7 @@ class TranslatorTest extends TestCase public function testAddFunctionNotExistsFunction() { - $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException'); + $this->expectException(\Symfony\Component\CssSelector\Exception\ExpressionErrorException::class); $translator = new Translator(); $translator->registerExtension(new HtmlExtension($translator)); $xpath = new XPathExpr(); @@ -74,7 +74,7 @@ class TranslatorTest extends TestCase public function testAddPseudoClassNotExistsClass() { - $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException'); + $this->expectException(\Symfony\Component\CssSelector\Exception\ExpressionErrorException::class); $translator = new Translator(); $translator->registerExtension(new HtmlExtension($translator)); $xpath = new XPathExpr(); @@ -83,7 +83,7 @@ class TranslatorTest extends TestCase public function testAddAttributeMatchingClassNotExistsClass() { - $this->expectException('Symfony\Component\CssSelector\Exception\ExpressionErrorException'); + $this->expectException(\Symfony\Component\CssSelector\Exception\ExpressionErrorException::class); $translator = new Translator(); $translator->registerExtension(new HtmlExtension($translator)); $xpath = new XPathExpr(); diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index cf27907ce0..6081c525a6 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -90,8 +90,8 @@ class DebugClassLoader public static function enable() { // Ensures we don't hit https://bugs.php.net/42098 - class_exists('Symfony\Component\Debug\ErrorHandler'); - class_exists('Psr\Log\LogLevel'); + class_exists(\Symfony\Component\Debug\ErrorHandler::class); + class_exists(\Psr\Log\LogLevel::class); if (!\is_array($functions = spl_autoload_functions())) { return; diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 6da37ff552..fd22f201ad 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -169,7 +169,7 @@ class ErrorHandler $this->bootstrappingLogger = $bootstrappingLogger; $this->setDefaultLogger($bootstrappingLogger); } - $this->traceReflector = new \ReflectionProperty('Exception', 'trace'); + $this->traceReflector = new \ReflectionProperty(\Exception::class, 'trace'); $this->traceReflector->setAccessible(true); } diff --git a/src/Symfony/Component/Debug/Exception/FatalErrorException.php b/src/Symfony/Component/Debug/Exception/FatalErrorException.php index ca34265251..a9fd7bb9de 100644 --- a/src/Symfony/Component/Debug/Exception/FatalErrorException.php +++ b/src/Symfony/Component/Debug/Exception/FatalErrorException.php @@ -74,7 +74,7 @@ class FatalErrorException extends \ErrorException protected function setTrace($trace) { - $traceReflector = new \ReflectionProperty('Exception', 'trace'); + $traceReflector = new \ReflectionProperty(\Exception::class, 'trace'); $traceReflector->setAccessible(true); $traceReflector->setValue($this, $trace); } diff --git a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php index c946607959..dc9617d0fa 100644 --- a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php +++ b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php @@ -54,7 +54,7 @@ class DebugClassLoaderTest extends TestCase $reflProp = $reflClass->getProperty('classLoader'); $reflProp->setAccessible(true); - $this->assertNotInstanceOf('Symfony\Component\Debug\DebugClassLoader', $reflProp->getValue($function[0])); + $this->assertNotInstanceOf(DebugClassLoader::class, $reflProp->getValue($function[0])); return; } @@ -65,7 +65,7 @@ class DebugClassLoaderTest extends TestCase public function testThrowingClass() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('boo'); try { class_exists(Fixtures\Throwing::class); @@ -80,14 +80,14 @@ class DebugClassLoaderTest extends TestCase public function testNameCaseMismatch() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Case mismatch between loaded and declared class names'); class_exists(TestingCaseMismatch::class, true); } public function testFileCaseMismatch() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Case mismatch between class and real file names'); if (!file_exists(__DIR__.'/Fixtures/CaseMismatch.php')) { $this->markTestSkipped('Can only be run on case insensitive filesystems'); @@ -98,7 +98,7 @@ class DebugClassLoaderTest extends TestCase public function testPsr4CaseMismatch() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Case mismatch between loaded and declared class names'); class_exists(__NAMESPACE__.'\Fixtures\Psr4CaseMismatch', true); } @@ -179,7 +179,7 @@ class DebugClassLoaderTest extends TestCase $e = error_reporting(0); trigger_error('', E_USER_NOTICE); - class_exists('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent', true); + class_exists(\Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent::class, true); error_reporting($e); restore_error_handler(); diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 9f60182f64..6c2b31a511 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -35,7 +35,7 @@ class ErrorHandlerTest extends TestCase $handler = ErrorHandler::register(); try { - $this->assertInstanceOf('Symfony\Component\Debug\ErrorHandler', $handler); + $this->assertInstanceOf(ErrorHandler::class, $handler); $this->assertSame($handler, ErrorHandler::register()); $newHandler = new ErrorHandler(); @@ -72,7 +72,7 @@ class ErrorHandlerTest extends TestCase public function testErrorGetLast() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger); $handler->screamAt(\E_ALL); @@ -150,7 +150,7 @@ class ErrorHandlerTest extends TestCase public function testDefaultLogger() { try { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger, \E_NOTICE); @@ -225,7 +225,7 @@ class ErrorHandlerTest extends TestCase restore_error_handler(); restore_exception_handler(); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $warnArgCheck = function ($logLevel, $message, $context) { $this->assertEquals('info', $logLevel); @@ -250,7 +250,7 @@ class ErrorHandlerTest extends TestCase restore_error_handler(); restore_exception_handler(); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $line = null; $logArgCheck = function ($level, $message, $context) use (&$line) { @@ -355,7 +355,7 @@ class ErrorHandlerTest extends TestCase $this->assertSame('User Deprecated: Foo deprecation', $exception->getMessage()); }; - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger ->expects($this->once()) ->method('log') @@ -370,7 +370,7 @@ class ErrorHandlerTest extends TestCase public function testHandleException() { try { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $exception = new \Exception('foo'); @@ -450,7 +450,7 @@ class ErrorHandlerTest extends TestCase $bootLogger->log(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); - $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $mockLogger->expects($this->once()) ->method('log') ->with(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); @@ -465,7 +465,7 @@ class ErrorHandlerTest extends TestCase $exception = new \Exception('Foo message'); - $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $mockLogger->expects($this->once()) ->method('log') ->with(LogLevel::CRITICAL, 'Uncaught Exception: Foo message', ['exception' => $exception]); @@ -480,7 +480,7 @@ class ErrorHandlerTest extends TestCase public function testHandleFatalError() { try { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $error = [ @@ -527,13 +527,13 @@ class ErrorHandlerTest extends TestCase $handler->handleException($exception); - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $args[0]); + $this->assertInstanceOf(\Symfony\Component\Debug\Exception\ClassNotFoundException::class, $args[0]); $this->assertStringStartsWith("Attempted to load class \"IReallyReallyDoNotExistAnywhereInTheRepositoryISwear\" from the global namespace.\nDid you forget a \"use\" statement", $args[0]->getMessage()); } public function testCustomExceptionHandler() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $handler = new ErrorHandler(); $handler->setExceptionHandler(function ($e) use ($handler) { $handler->handleException($e); diff --git a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php index 061b645eb8..592a1ebea5 100644 --- a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php @@ -67,7 +67,7 @@ class ClassNotFoundFatalErrorHandlerTest extends TestCase array_map('spl_autoload_register', $autoloaders); } - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); + $this->assertInstanceOf(\Symfony\Component\Debug\Exception\ClassNotFoundException::class, $exception); $this->assertMatchesRegularExpression($translatedMessage, $exception->getMessage()); $this->assertSame($error['type'], $exception->getSeverity()); $this->assertSame($error['file'], $exception->getFile()); @@ -218,6 +218,6 @@ class ClassNotFoundFatalErrorHandlerTest extends TestCase $handler = new ClassNotFoundFatalErrorHandler(); $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); + $this->assertInstanceOf(\Symfony\Component\Debug\Exception\ClassNotFoundException::class, $exception); } } diff --git a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php index b827c4c67a..e46b4293de 100644 --- a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php @@ -28,7 +28,7 @@ class UndefinedFunctionFatalErrorHandlerTest extends TestCase $handler = new UndefinedFunctionFatalErrorHandler(); $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - $this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception); + $this->assertInstanceOf(\Symfony\Component\Debug\Exception\UndefinedFunctionException::class, $exception); // class names are case insensitive and PHP do not return the same $this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage())); $this->assertSame($error['type'], $exception->getSeverity()); diff --git a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php index 7ea1b1f95e..d1b8018b46 100644 --- a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php @@ -28,7 +28,7 @@ class UndefinedMethodFatalErrorHandlerTest extends TestCase $handler = new UndefinedMethodFatalErrorHandler(); $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - $this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedMethodException', $exception); + $this->assertInstanceOf(\Symfony\Component\Debug\Exception\UndefinedMethodException::class, $exception); $this->assertSame($translatedMessage, $exception->getMessage()); $this->assertSame($error['type'], $exception->getSeverity()); $this->assertSame($error['file'], $exception->getFile()); diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index def656ee13..027334ceb6 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -144,7 +144,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface { parent::__construct($parameterBag); - $this->trackResources = interface_exists('Symfony\Component\Config\Resource\ResourceInterface'); + $this->trackResources = interface_exists(ResourceInterface::class); $this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true)->setPublic(true)); $this->setAlias(PsrContainerInterface::class, new Alias('service_container', false)); $this->setAlias(ContainerInterface::class, new Alias('service_container', false)); @@ -1643,7 +1643,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface private function getExpressionLanguage(): ExpressionLanguage { if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) { throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } $this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index e6e51054d9..ea11778a64 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -534,7 +534,7 @@ EOF; $proxyClasses = []; $alreadyGenerated = []; $definitions = $this->container->getDefinitions(); - $strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments'); + $strip = '' === $this->docStar && method_exists(Kernel::class, 'stripComments'); $proxyDumper = $this->getProxyDumper(); ksort($definitions); foreach ($definitions as $definition) { @@ -1989,7 +1989,7 @@ EOF; private function getExpressionLanguage(): ExpressionLanguage { if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) { throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } $providers = $this->container->getExpressionLanguageProviders(); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index 523ea2026a..b57c8b955d 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -45,7 +45,7 @@ class YamlDumper extends Dumper */ public function dump(array $options = []) { - if (!class_exists('Symfony\Component\Yaml\Dumper')) { + if (!class_exists(\Symfony\Component\Yaml\Dumper::class)) { throw new LogicException('Unable to dump the container as the Symfony Yaml Component is not installed.'); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 96c0514307..d963445b30 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -671,7 +671,7 @@ class YamlFileLoader extends FileLoader */ protected function loadFile($file) { - if (!class_exists('Symfony\Component\Yaml\Parser')) { + if (!class_exists(\Symfony\Component\Yaml\Parser::class)) { throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php b/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php index 7f35edc065..12e30b9b80 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php @@ -90,7 +90,7 @@ class AliasTest extends TestCase */ public function testCannotDeprecateWithAnInvalidTemplate($message) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $def = new Alias('foo'); $def->setDeprecated(true, $message); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php index 15c440d889..35f25c0714 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php @@ -91,7 +91,7 @@ class ChildDefinitionTest extends TestCase public function testReplaceArgumentShouldRequireIntegerIndex() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $def = new ChildDefinition('foo'); $def->replaceArgument('0', 'foo'); @@ -118,7 +118,7 @@ class ChildDefinitionTest extends TestCase public function testGetArgumentShouldCheckBounds() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $def = new ChildDefinition('foo'); $def->setArguments([0 => 'foo']); @@ -129,14 +129,14 @@ class ChildDefinitionTest extends TestCase public function testCannotCallSetAutoconfigured() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\BadMethodCallException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\BadMethodCallException::class); $def = new ChildDefinition('foo'); $def->setAutoconfigured(true); } public function testCannotCallSetInstanceofConditionals() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\BadMethodCallException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\BadMethodCallException::class); $def = new ChildDefinition('foo'); $def->setInstanceofConditionals(['Foo' => new ChildDefinition('')]); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutoAliasServicePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutoAliasServicePassTest.php index 4e17778f8f..7b13d72ddb 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutoAliasServicePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutoAliasServicePassTest.php @@ -19,7 +19,7 @@ class AutoAliasServicePassTest extends TestCase { public function testProcessWithMissingParameter() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException::class); $container = new ContainerBuilder(); $container->register('example') @@ -31,7 +31,7 @@ class AutoAliasServicePassTest extends TestCase public function testProcessWithMissingFormat() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $container = new ContainerBuilder(); $container->register('example') diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index c4a6689fd7..3478e79d4b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -241,7 +241,7 @@ class AutowirePassTest extends TestCase */ public function testTypeNotGuessableUnionType() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException'); + $this->expectException(AutowiringFailedException::class); $this->expectExceptionMessage('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\UnionClasses::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionA|Symfony\Component\DependencyInjection\Tests\Compiler\CollisionB" but this class was not found.'); $container = new ContainerBuilder(); @@ -493,7 +493,7 @@ class AutowirePassTest extends TestCase */ public function testUnionScalarArgsCannotBeAutowired() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException'); + $this->expectException(AutowiringFailedException::class); $this->expectExceptionMessage('Cannot autowire service "union_scalars": argument "$timeout" of method "Symfony\Component\DependencyInjection\Tests\Compiler\UnionScalars::__construct()" is type-hinted "int|float", you should configure its value explicitly.'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php index 9554c23bb3..c8b17acb50 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckArgumentsValidityPassTest.php @@ -45,7 +45,7 @@ class CheckArgumentsValidityPassTest extends TestCase */ public function testException(array $arguments, array $methodCalls) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $container = new ContainerBuilder(); $definition = $container->register('foo'); $definition->setArguments($arguments); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php index 915809f0c8..60f635c0eb 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php @@ -23,7 +23,7 @@ class CheckCircularReferencesPassTest extends TestCase { public function testProcess() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $container = new ContainerBuilder(); $container->register('a')->addArgument(new Reference('b')); $container->register('b')->addArgument(new Reference('a')); @@ -33,7 +33,7 @@ class CheckCircularReferencesPassTest extends TestCase public function testProcessWithAliases() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $container = new ContainerBuilder(); $container->register('a')->addArgument(new Reference('b')); $container->setAlias('b', 'c'); @@ -44,7 +44,7 @@ class CheckCircularReferencesPassTest extends TestCase public function testProcessWithFactory() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $container = new ContainerBuilder(); $container @@ -60,7 +60,7 @@ class CheckCircularReferencesPassTest extends TestCase public function testProcessDetectsIndirectCircularReference() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $container = new ContainerBuilder(); $container->register('a')->addArgument(new Reference('b')); $container->register('b')->addArgument(new Reference('c')); @@ -71,7 +71,7 @@ class CheckCircularReferencesPassTest extends TestCase public function testProcessDetectsIndirectCircularReferenceWithFactory() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $container = new ContainerBuilder(); $container->register('a')->addArgument(new Reference('b')); @@ -87,7 +87,7 @@ class CheckCircularReferencesPassTest extends TestCase public function testDeepCircularReference() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $container = new ContainerBuilder(); $container->register('a')->addArgument(new Reference('b')); $container->register('b')->addArgument(new Reference('c')); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php index 33df2426ad..8ac217a989 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckDefinitionValidityPassTest.php @@ -20,7 +20,7 @@ class CheckDefinitionValidityPassTest extends TestCase { public function testProcessDetectsSyntheticNonPublicDefinitions() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $container = new ContainerBuilder(); $container->register('a')->setSynthetic(true)->setPublic(false); @@ -29,7 +29,7 @@ class CheckDefinitionValidityPassTest extends TestCase public function testProcessDetectsNonSyntheticNonAbstractDefinitionWithoutClass() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $container = new ContainerBuilder(); $container->register('a')->setSynthetic(false)->setAbstract(false); @@ -77,7 +77,7 @@ class CheckDefinitionValidityPassTest extends TestCase public function testInvalidTags() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $container = new ContainerBuilder(); $container->register('a', 'class')->addTag('foo', ['bar' => ['baz' => 'baz']]); @@ -86,7 +86,7 @@ class CheckDefinitionValidityPassTest extends TestCase public function testDynamicPublicServiceName() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\EnvParameterException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvParameterException::class); $container = new ContainerBuilder(); $env = $container->getParameterBag()->get('env(BAR)'); $container->register("foo.$env", 'class')->setPublic(true); @@ -96,7 +96,7 @@ class CheckDefinitionValidityPassTest extends TestCase public function testDynamicPublicAliasName() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\EnvParameterException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvParameterException::class); $container = new ContainerBuilder(); $env = $container->getParameterBag()->get('env(BAR)'); $container->setAlias("foo.$env", 'class')->setPublic(true); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php index dd3b1c27fb..e00ae5bf16 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php @@ -40,7 +40,7 @@ class CheckExceptionOnInvalidReferenceBehaviorPassTest extends TestCase public function testProcessThrowsExceptionOnInvalidReference() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $container = new ContainerBuilder(); $container @@ -53,7 +53,7 @@ class CheckExceptionOnInvalidReferenceBehaviorPassTest extends TestCase public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinition() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $container = new ContainerBuilder(); $def = new Definition(); @@ -83,7 +83,7 @@ class CheckExceptionOnInvalidReferenceBehaviorPassTest extends TestCase public function testWithErroredServiceLocator() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->expectExceptionMessage('The service "foo" in the container provided to "bar" has a dependency on a non-existent service "baz".'); $container = new ContainerBuilder(); @@ -96,7 +96,7 @@ class CheckExceptionOnInvalidReferenceBehaviorPassTest extends TestCase public function testWithErroredHiddenService() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->expectExceptionMessage('The service "bar" has a dependency on a non-existent service "foo".'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckReferenceValidityPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckReferenceValidityPassTest.php index 85a8a40f13..2c0c5e0467 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckReferenceValidityPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckReferenceValidityPassTest.php @@ -20,7 +20,7 @@ class CheckReferenceValidityPassTest extends TestCase { public function testProcessDetectsReferenceToAbstractDefinition() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $container = new ContainerBuilder(); $container->register('a')->setAbstract(true); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php index 3402bbd0c5..2bf822f2e7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php @@ -153,7 +153,7 @@ class DecoratorServicePassTest extends TestCase ->setDecoratedService('unknown_service') ; - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->process($container); } @@ -177,7 +177,7 @@ class DecoratorServicePassTest extends TestCase ->setDecoratedService('unknown_decorated', null, 0, 12) ; - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->process($container); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php index 273261976d..f17717f1df 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DefinitionErrorExceptionPassTest.php @@ -20,7 +20,7 @@ class DefinitionErrorExceptionPassTest extends TestCase { public function testThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Things went wrong!'); $container = new ContainerBuilder(); $def = new Definition(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php index e492e99d45..9c22b3a473 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php @@ -38,7 +38,7 @@ class InlineServiceDefinitionsPassTest extends TestCase $this->process($container); $arguments = $container->getDefinition('service')->getArguments(); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $arguments[0]); + $this->assertInstanceOf(Definition::class, $arguments[0]); $this->assertSame($inlineable, $arguments[0]); $this->assertFalse($container->has('inlinable.service')); } @@ -114,7 +114,7 @@ class InlineServiceDefinitionsPassTest extends TestCase public function testProcessThrowsOnNonSharedLoops() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> foo -> bar".'); $container = new ContainerBuilder(); $container diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php index a2cb3bda5e..c9a4aa72fa 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php @@ -28,7 +28,7 @@ class MergeExtensionConfigurationPassTest extends TestCase { $tmpProviders = []; - $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); + $extension = $this->getMockBuilder(\Symfony\Component\DependencyInjection\Extension\ExtensionInterface::class)->getMock(); $extension->expects($this->any()) ->method('getXsdValidationBasePath') ->willReturn(false); @@ -44,7 +44,7 @@ class MergeExtensionConfigurationPassTest extends TestCase $tmpProviders = $container->getExpressionLanguageProviders(); }); - $provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock(); + $provider = $this->getMockBuilder(\Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface::class)->getMock(); $container = new ContainerBuilder(new ParameterBag()); $container->registerExtension($extension); $container->prependExtensionConfig('foo', ['bar' => true]); @@ -105,7 +105,7 @@ class MergeExtensionConfigurationPassTest extends TestCase public function testProcessedEnvsAreIncompatibleWithResolve() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Using a cast in "env(int:FOO)" is incompatible with resolution at compile time in "Symfony\Component\DependencyInjection\Tests\Compiler\BarExtension". The logic in the extension should be moved to a compiler pass, or an env parameter with no cast should be used instead.'); $container = new ContainerBuilder(); $container->registerExtension(new BarExtension()); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php index 4686f483a7..4d513d2ee0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php @@ -62,7 +62,7 @@ class RegisterEnvVarProcessorsPassTest extends TestCase public function testBadProcessor() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid type "foo" returned by "Symfony\Component\DependencyInjection\Tests\Compiler\BadProcessor::getProvidedTypes()", expected one of "array", "bool", "float", "int", "string".'); $container = new ContainerBuilder(); $container->register('foo', BadProcessor::class)->addTag('container.env_var_processor'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php index d8e7d62d47..8846f602c7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php @@ -39,7 +39,7 @@ class RegisterServiceSubscribersPassTest extends TestCase { public function testInvalidClass() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Service "foo" must implement interface "Symfony\Contracts\Service\ServiceSubscriberInterface".'); $container = new ContainerBuilder(); @@ -53,7 +53,7 @@ class RegisterServiceSubscribersPassTest extends TestCase public function testInvalidAttributes() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "container.service_subscriber" tag accepts only the "key" and "id" attributes, "bar" given for service "foo".'); $container = new ContainerBuilder(); @@ -127,7 +127,7 @@ class RegisterServiceSubscribersPassTest extends TestCase public function testExtraServiceSubscriber() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Service key "test" does not exist in the map returned by "Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber::getSubscribedServices()" for service "foo_service".'); $container = new ContainerBuilder(); $container->register('foo_service', TestServiceSubscriber::class) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php index 2f0a413ca9..dbe43da290 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php @@ -55,7 +55,7 @@ class ReplaceAliasByActualDefinitionPassTest extends TestCase public function testProcessWithInvalidAlias() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $container = new ContainerBuilder(); $container->setAlias('a_alias', 'a'); $this->process($container); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveBindingsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveBindingsPassTest.php index 443114b0a2..e6d8344bab 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveBindingsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveBindingsPassTest.php @@ -64,7 +64,7 @@ class ResolveBindingsPassTest extends TestCase public function testUnusedBinding() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A binding is configured for an argument named "$quz" for service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy", but no corresponding argument has been found. It may be unused and should be removed, or it may have a typo.'); $container = new ContainerBuilder(); @@ -77,7 +77,7 @@ class ResolveBindingsPassTest extends TestCase public function testMissingParent() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A binding is configured for an argument named "$quz" for service "Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists", but no corresponding argument has been found. It may be unused and should be removed, or it may have a typo.'); $container = new ContainerBuilder(); @@ -134,7 +134,7 @@ class ResolveBindingsPassTest extends TestCase public function testWithNonExistingSetterAndBinding() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy": method "setLogger()" does not exist.'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php index dd58f90990..1216e59a8b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php @@ -399,7 +399,7 @@ class ResolveChildDefinitionsPassTest extends TestCase public function testProcessDetectsChildDefinitionIndirectCircularReference() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $this->expectExceptionMessageMatches('/^Circular reference detected for service "c", path: "c -> b -> a -> c"./'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php index 520c2245d7..0f56bfeac8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php @@ -84,7 +84,7 @@ class ResolveClassPassTest extends TestCase public function testAmbiguousChildDefinition() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Service definition "App\Foo\Child" has a parent but no class, and its name looks like a FQCN. Either the class is missing or you want to inherit it from the parent service. To resolve this ambiguity, please rename this service to a non-FQCN (e.g. using dots), or create the missing class.'); $container = new ContainerBuilder(); $container->register('App\Foo', null); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php index b87fb3db98..2c3fd59173 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveFactoryClassPassTest.php @@ -73,7 +73,7 @@ class ResolveFactoryClassPassTest extends TestCase public function testNotAnyClassThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('The "factory" service is defined to be created by a factory, but is missing the factory class. Did you forget to define the factory or service class?'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php index 99aa65b138..2f749362d2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php @@ -179,7 +179,7 @@ class ResolveInstanceofConditionalsPassTest extends TestCase public function testBadInterfaceThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('"App\FakeInterface" is set as an "instanceof" conditional, but it does not exist.'); $container = new ContainerBuilder(); $def = $container->register('normal_service', self::class); @@ -236,7 +236,7 @@ class ResolveInstanceofConditionalsPassTest extends TestCase public function testProcessThrowsExceptionForArguments() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./'); $container = new ContainerBuilder(); $container->registerForAutoconfiguration(parent::class) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php index d723951f98..61e5c72eec 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php @@ -64,7 +64,7 @@ class ResolveNamedArgumentsPassTest extends TestCase public function testClassNull() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $container = new ContainerBuilder(); $definition = $container->register(NamedArgumentsDummy::class); @@ -76,7 +76,7 @@ class ResolveNamedArgumentsPassTest extends TestCase public function testClassNotExist() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $container = new ContainerBuilder(); $definition = $container->register(NotExist::class, NotExist::class); @@ -88,7 +88,7 @@ class ResolveNamedArgumentsPassTest extends TestCase public function testClassNoConstructor() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $container = new ContainerBuilder(); $definition = $container->register(NoConstructor::class, NoConstructor::class); @@ -100,7 +100,7 @@ class ResolveNamedArgumentsPassTest extends TestCase public function testArgumentNotFound() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy": method "__construct()" has no argument named "$notFound". Check your service definition.'); $container = new ContainerBuilder(); @@ -113,7 +113,7 @@ class ResolveNamedArgumentsPassTest extends TestCase public function testCorrectMethodReportedInException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1": method "Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummyWithoutReturnTypes::createTestDefinition1()" has no argument named "$notFound". Check your service definition.'); $container = new ContainerBuilder(); @@ -142,7 +142,7 @@ class ResolveNamedArgumentsPassTest extends TestCase public function testTypedArgumentWithMissingDollar() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy": did you forget to add the "$" prefix to argument "apiKey"?'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php index 283cd32410..63fa9c4e5e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php @@ -53,7 +53,7 @@ class ResolveReferencesToAliasesPassTest extends TestCase public function testAliasCircularReference() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $container = new ContainerBuilder(); $container->setAlias('bar', 'foo'); $container->setAlias('foo', 'bar'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php index 66af69b543..2e9cc686c5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php @@ -27,7 +27,7 @@ class ServiceLocatorTagPassTest extends TestCase { public function testNoServices() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid definition for service "foo": an array of references is expected as first argument when the "container.service_locator" tag is set.'); $container = new ContainerBuilder(); @@ -40,7 +40,7 @@ class ServiceLocatorTagPassTest extends TestCase public function testInvalidServices() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid definition for service "foo": an array of references is expected as first argument when the "container.service_locator" tag is set, "string" found for key "0".'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php index dc8465b0d0..0a28a4363d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -44,7 +44,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase public function testDefaultEnvIsValidatedInConfig() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('Invalid configuration for path "env_extension.string_node": "fail" is not a valid string'); $container = new ContainerBuilder(); $container->setParameter('env(STRING)', 'fail'); @@ -76,7 +76,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase public function testEnvsAreValidatedInConfigWithInvalidPlaceholder() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $this->expectExceptionMessage('Invalid type for path "env_extension.bool_node". Expected "bool", but got one of "bool", "int", "float", "string", "array".'); $container = new ContainerBuilder(); $container->registerExtension($ext = new EnvExtension()); @@ -91,7 +91,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase public function testInvalidEnvInConfig() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $this->expectExceptionMessage('Invalid type for path "env_extension.int_node". Expected "int", but got "array".'); $container = new ContainerBuilder(); $container->registerExtension(new EnvExtension()); @@ -104,7 +104,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase public function testNulledEnvInConfig() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class); $this->expectExceptionMessageMatches('/^Invalid type for path "env_extension\.int_node"\. Expected "?int"?, but got (NULL|"null")\.$/'); $container = new ContainerBuilder(); $container->setParameter('env(NULLED)', null); @@ -156,7 +156,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase public function testEnvIsIncompatibleWithEnumNode() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('A dynamic value is not compatible with a "Symfony\Component\Config\Definition\EnumNode" node type at path "env_extension.enum_node".'); $container = new ContainerBuilder(); $container->registerExtension(new EnvExtension()); @@ -169,7 +169,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase public function testEnvIsIncompatibleWithArrayNode() { - $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('A dynamic value is not compatible with a "Symfony\Component\Config\Definition\ArrayNode" node type at path "env_extension.simple_array_node".'); $container = new ContainerBuilder(); $container->registerExtension(new EnvExtension()); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 8ffe22e664..4de833ba8d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -109,7 +109,7 @@ class ContainerBuilderTest extends TestCase $builder = new ContainerBuilder(); $builder->register('foo', 'Bar\FooClass'); $this->assertTrue($builder->hasDefinition('foo'), '->register() registers a new service definition'); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $builder->getDefinition('foo'), '->register() returns the newly created Definition instance'); + $this->assertInstanceOf(Definition::class, $builder->getDefinition('foo'), '->register() returns the newly created Definition instance'); } public function testAutowire() @@ -133,7 +133,7 @@ class ContainerBuilderTest extends TestCase public function testGetThrowsExceptionIfServiceDoesNotExist() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(ServiceNotFoundException::class); $this->expectExceptionMessage('You have requested a non-existent service "foo".'); $builder = new ContainerBuilder(); $builder->get('foo'); @@ -148,7 +148,7 @@ class ContainerBuilderTest extends TestCase public function testGetThrowsCircularReferenceExceptionIfServiceHasReferenceToItself() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $builder = new ContainerBuilder(); $builder->register('baz', 'stdClass')->setArguments([new Reference('baz')]); $builder->get('baz'); @@ -200,7 +200,7 @@ class ContainerBuilderTest extends TestCase */ public function testBadAliasId($id) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $builder = new ContainerBuilder(); $builder->setAlias($id, 'foo'); } @@ -210,7 +210,7 @@ class ContainerBuilderTest extends TestCase */ public function testBadDefinitionId($id) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $builder = new ContainerBuilder(); $builder->setDefinition($id, new Definition('Foo')); } @@ -229,7 +229,7 @@ class ContainerBuilderTest extends TestCase public function testGetUnsetLoadingServiceWhenCreateServiceThrowsAnException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('You have requested a synthetic service ("foo"). The DIC does not know how to construct this service.'); $builder = new ContainerBuilder(); $builder->register('foo', 'stdClass')->setSynthetic(true); @@ -375,8 +375,8 @@ class ContainerBuilderTest extends TestCase $builder = new ContainerBuilder(); $builder->setResourceTracking(false); $defaultPasses = $builder->getCompiler()->getPassConfig()->getPasses(); - $builder->addCompilerPass($pass1 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')->getMock(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -5); - $builder->addCompilerPass($pass2 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface')->getMock(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10); + $builder->addCompilerPass($pass1 = $this->getMockBuilder(\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface::class)->getMock(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -5); + $builder->addCompilerPass($pass2 = $this->getMockBuilder(\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface::class)->getMock(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10); $passes = $builder->getCompiler()->getPassConfig()->getPasses(); $this->assertCount(\count($passes) - 2, $defaultPasses); @@ -390,8 +390,8 @@ class ContainerBuilderTest extends TestCase $builder->register('foo1', 'Bar\FooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php'); $builder->register('foo2', 'Bar\FooClass')->setFile(__DIR__.'/Fixtures/includes/%file%.php'); $builder->setParameter('file', 'foo'); - $this->assertInstanceOf('\Bar\FooClass', $builder->get('foo1'), '->createService() requires the file defined by the service definition'); - $this->assertInstanceOf('\Bar\FooClass', $builder->get('foo2'), '->createService() replaces parameters in the file provided by the service definition'); + $this->assertInstanceOf(\Bar\FooClass::class, $builder->get('foo1'), '->createService() requires the file defined by the service definition'); + $this->assertInstanceOf(\Bar\FooClass::class, $builder->get('foo2'), '->createService() replaces parameters in the file provided by the service definition'); } public function testCreateProxyWithRealServiceInstantiator() @@ -527,7 +527,7 @@ class ContainerBuilderTest extends TestCase public function testCreateSyntheticService() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $builder = new ContainerBuilder(); $builder->register('foo', 'Bar\FooClass')->setSynthetic(true); $builder->get('foo'); @@ -553,7 +553,7 @@ class ContainerBuilderTest extends TestCase public function testResolveServicesWithDecoratedDefinition() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Constructing service "foo" from a parent definition is not supported at build time.'); $builder = new ContainerBuilder(); $builder->setDefinition('grandpa', new Definition('stdClass')); @@ -568,7 +568,7 @@ class ContainerBuilderTest extends TestCase $builder = new ContainerBuilder(); $builder->setDefinition('foo', new CustomDefinition('stdClass')); - $this->assertInstanceOf('stdClass', $builder->get('foo')); + $this->assertInstanceOf(\stdClass::class, $builder->get('foo')); } public function testMerge() @@ -632,7 +632,7 @@ class ContainerBuilderTest extends TestCase public function testMergeThrowsExceptionForDuplicateAutomaticInstanceofDefinitions() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('"AInterface" has already been autoconfigured and merge() does not support merging autoconfiguration for the same class/interface.'); $container = new ContainerBuilder(); $config = new ContainerBuilder(); @@ -737,7 +737,7 @@ class ContainerBuilderTest extends TestCase public function testCompileWithArrayInStringResolveEnv() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('A string value must be composed of strings and/or numbers, but found parameter "env(json:ARRAY)" of type "array" inside string value "ABC %env(json:ARRAY)%".'); putenv('ARRAY={"foo":"bar"}'); @@ -750,7 +750,7 @@ class ContainerBuilderTest extends TestCase public function testCompileWithResolveMissingEnv() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\EnvNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvNotFoundException::class); $this->expectExceptionMessage('Environment variable not found: "FOO".'); $container = new ContainerBuilder(); $container->setParameter('foo', '%env(FOO)%'); @@ -846,7 +846,7 @@ class ContainerBuilderTest extends TestCase public function testCircularDynamicEnv() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException::class); $this->expectExceptionMessage('Circular reference detected for parameter "env(resolve:DUMMY_ENV_VAR)" ("env(resolve:DUMMY_ENV_VAR)" > "env(resolve:DUMMY_ENV_VAR)").'); putenv('DUMMY_ENV_VAR=some%foo%'); @@ -863,7 +863,7 @@ class ContainerBuilderTest extends TestCase public function testMergeLogicException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $container = new ContainerBuilder(); $container->setResourceTracking(false); $container->compile(); @@ -928,7 +928,7 @@ class ContainerBuilderTest extends TestCase /* @var $resource \Symfony\Component\Config\Resource\FileResource */ $resource = end($resources); - $this->assertInstanceOf('Symfony\Component\Config\Resource\FileResource', $resource); + $this->assertInstanceOf(FileResource::class, $resource); $this->assertSame(realpath(__DIR__.'/Fixtures/includes/classes.php'), realpath($resource->getResource())); } @@ -1040,13 +1040,13 @@ class ContainerBuilderTest extends TestCase $container->registerExtension($extension = new \ProjectExtension()); $this->assertSame($container->getExtension('project'), $extension, '->registerExtension() registers an extension'); - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $container->getExtension('no_registered'); } public function testRegisteredButNotLoadedExtension() { - $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); + $extension = $this->getMockBuilder(\Symfony\Component\DependencyInjection\Extension\ExtensionInterface::class)->getMock(); $extension->expects($this->once())->method('getAlias')->willReturn('project'); $extension->expects($this->never())->method('load'); @@ -1058,7 +1058,7 @@ class ContainerBuilderTest extends TestCase public function testRegisteredAndLoadedExtension() { - $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); + $extension = $this->getMockBuilder(\Symfony\Component\DependencyInjection\Extension\ExtensionInterface::class)->getMock(); $extension->expects($this->exactly(2))->method('getAlias')->willReturn('project'); $extension->expects($this->once())->method('load')->with([['foo' => 'bar']]); @@ -1084,12 +1084,12 @@ class ContainerBuilderTest extends TestCase ]); $container->compile(); - $this->assertInstanceOf('BarClass', $container->get('bar_user')->bar); + $this->assertInstanceOf(\BarClass::class, $container->get('bar_user')->bar); } public function testThrowsExceptionWhenSetServiceOnACompiledContainer() { - $this->expectException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); $container = new ContainerBuilder(); $container->setResourceTracking(false); $container->register('a', 'stdClass')->setPublic(true); @@ -1118,7 +1118,7 @@ class ContainerBuilderTest extends TestCase public function testThrowsExceptionWhenSetDefinitionOnACompiledContainer() { - $this->expectException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); $container = new ContainerBuilder(); $container->setResourceTracking(false); $container->compile(); @@ -1212,7 +1212,7 @@ class ContainerBuilderTest extends TestCase public function testThrowsCircularExceptionForCircularAliases() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $this->expectExceptionMessage('Circular reference detected for service "app.test_class", path: "app.test_class -> App\TestClass -> app.test_class".'); $builder = new ContainerBuilder(); @@ -1268,7 +1268,7 @@ class ContainerBuilderTest extends TestCase public function testNoClassFromGlobalNamespaceClassId() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('The definition for "DateTime" has no class attribute, and appears to reference a class or interface in the global namespace.'); $container = new ContainerBuilder(); @@ -1278,7 +1278,7 @@ class ContainerBuilderTest extends TestCase public function testNoClassFromGlobalNamespaceClassIdWithLeadingSlash() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('The definition for "\DateTime" has no class attribute, and appears to reference a class or interface in the global namespace.'); $container = new ContainerBuilder(); @@ -1288,7 +1288,7 @@ class ContainerBuilderTest extends TestCase public function testNoClassFromNamespaceClassIdWithLeadingSlash() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('The definition for "\Symfony\Component\DependencyInjection\Tests\FooClass" has no class attribute, and appears to reference a class or interface. Please specify the class attribute explicitly or remove the leading backslash by renaming the service to "Symfony\Component\DependencyInjection\Tests\FooClass" to get rid of this error.'); $container = new ContainerBuilder(); @@ -1298,7 +1298,7 @@ class ContainerBuilderTest extends TestCase public function testNoClassFromNonClassId() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('The definition for "123_abc" has no class.'); $container = new ContainerBuilder(); @@ -1308,7 +1308,7 @@ class ContainerBuilderTest extends TestCase public function testNoClassFromNsSeparatorId() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('The definition for "\foo" has no class.'); $container = new ContainerBuilder(); @@ -1454,7 +1454,7 @@ class ContainerBuilderTest extends TestCase $this->assertSame($manager3, $listener3->manager, 'Both should identically be the manager3 service'); $listener4 = $container->get('listener4'); - $this->assertInstanceOf('stdClass', $listener4); + $this->assertInstanceOf(\stdClass::class, $listener4); } public function provideAlmostCircular() @@ -1571,7 +1571,7 @@ class ContainerBuilderTest extends TestCase public function testErroredDefinition() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Service "errored_definition" is broken.'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index ff6f483364..b9616f93e8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -80,7 +80,7 @@ class ContainerTest extends TestCase $this->assertFalse($sc->getParameterBag()->isResolved(), '->compile() resolves the parameter bag'); $sc->compile(); $this->assertTrue($sc->getParameterBag()->isResolved(), '->compile() resolves the parameter bag'); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag', $sc->getParameterBag(), '->compile() changes the parameter bag to a FrozenParameterBag instance'); + $this->assertInstanceOf(FrozenParameterBag::class, $sc->getParameterBag(), '->compile() changes the parameter bag to a FrozenParameterBag instance'); $this->assertEquals(['foo' => 'bar'], $sc->getParameterBag()->all(), '->compile() copies the current parameters to the new parameter bag'); } @@ -168,7 +168,7 @@ class ContainerTest extends TestCase public function testSetWithNullOnInitializedPredefinedService() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "bar" service is already initialized, you cannot replace it.'); $sc = new Container(); $sc->set('foo', new \stdClass()); @@ -207,7 +207,7 @@ class ContainerTest extends TestCase $sc->get(''); $this->fail('->get() throws a \InvalidArgumentException exception if the service is empty'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws a ServiceNotFoundException exception if the service is empty'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class, $e, '->get() throws a ServiceNotFoundException exception if the service is empty'); } $this->assertNull($sc->get('', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service is empty'); } @@ -233,7 +233,7 @@ class ContainerTest extends TestCase $sc->get('foo1'); $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class, $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); $this->assertEquals('You have requested a non-existent service "foo1". Did you mean this: "foo"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException with some advices'); } @@ -241,7 +241,7 @@ class ContainerTest extends TestCase $sc->get('bag'); $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class, $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist'); $this->assertEquals('You have requested a non-existent service "bag". Did you mean one of these: "bar", "baz"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException with some advices'); } } @@ -260,7 +260,7 @@ class ContainerTest extends TestCase public function testGetSyntheticServiceThrows() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->expectExceptionMessage('The "request" service is synthetic, it needs to be set at boot time before it can be used.'); require_once __DIR__.'/Fixtures/php/services9_compiled.php'; @@ -270,7 +270,7 @@ class ContainerTest extends TestCase public function testGetRemovedServiceThrows() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->expectExceptionMessage('The "inlined" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.'); require_once __DIR__.'/Fixtures/php/services9_compiled.php'; @@ -342,7 +342,7 @@ class ContainerTest extends TestCase public function testGetThrowsException() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('Something went terribly wrong!'); $c = new ProjectServiceContainer(); @@ -395,7 +395,7 @@ class ContainerTest extends TestCase public function testThatCloningIsNotSupported() { - $class = new \ReflectionClass('Symfony\Component\DependencyInjection\Container'); + $class = new \ReflectionClass(Container::class); $clone = $class->getMethod('__clone'); $this->assertFalse($class->isCloneable()); $this->assertTrue($clone->isPrivate()); @@ -410,7 +410,7 @@ class ContainerTest extends TestCase public function testRequestAnInternalSharedPrivateService() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->expectExceptionMessage('You have requested a non-existent service "internal".'); $c = new ProjectServiceContainer(); $c->get('internal_dependency'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index f5b3a9166b..45ec034ae2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -116,7 +116,7 @@ class DefinitionTest extends TestCase $def = new Definition('stdClass'); - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The decorated service inner name for "foo" must be different than the service name itself.'); $def->setDecoratedService('foo', 'foo'); @@ -152,7 +152,7 @@ class DefinitionTest extends TestCase public function testExceptionOnEmptyMethodCall() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Method name cannot be empty.'); $def = new Definition('stdClass'); $def->addMethodCall(''); @@ -221,7 +221,7 @@ class DefinitionTest extends TestCase */ public function testSetDeprecatedWithInvalidDeprecationTemplate($message) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $def = new Definition('stdClass'); $def->setDeprecated(false, $message); } @@ -306,7 +306,7 @@ class DefinitionTest extends TestCase public function testGetArgumentShouldCheckBounds() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $def = new Definition('stdClass'); $def->addArgument('foo'); @@ -315,7 +315,7 @@ class DefinitionTest extends TestCase public function testReplaceArgumentShouldCheckBounds() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage('The index "1" is not in the range [0, 0].'); $def = new Definition('stdClass'); @@ -325,7 +325,7 @@ class DefinitionTest extends TestCase public function testReplaceArgumentWithoutExistingArgumentsShouldCheckBounds() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage('Cannot replace arguments if none have been configured yet.'); $def = new Definition('stdClass'); $def->replaceArgument(0, 'bar'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 365cbc3461..707b014fba 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -163,7 +163,7 @@ class PhpDumperTest extends TestCase */ public function testExportParameters($parameters) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $container = new ContainerBuilder(new ParameterBag($parameters)); $container->compile(); $dumper = new PhpDumper($container); @@ -190,7 +190,7 @@ class PhpDumperTest extends TestCase public function testAddServiceWithoutCompilation() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class); $this->expectExceptionMessage('Cannot dump an uncompiled container.'); $container = include self::$fixturesPath.'/containers/container9.php'; new PhpDumper($container); @@ -374,7 +374,7 @@ class PhpDumperTest extends TestCase */ public function testInvalidFactories($factory) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Cannot dump definition'); $container = new ContainerBuilder(); $def = new Definition('stdClass'); @@ -442,7 +442,7 @@ class PhpDumperTest extends TestCase public function testOverrideServiceWhenUsingADumpedContainer() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "decorator_service" service is already initialized, you cannot replace it.'); require_once self::$fixturesPath.'/php/services9_compiled.php'; @@ -659,7 +659,7 @@ class PhpDumperTest extends TestCase public function testUnusedEnvParameter() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\EnvParameterException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvParameterException::class); $this->expectExceptionMessage('Environment variables "FOO" are never used. Please, check your container\'s configuration.'); $container = new ContainerBuilder(); $container->getParameter('env(FOO)'); @@ -670,7 +670,7 @@ class PhpDumperTest extends TestCase public function testCircularDynamicEnv() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException::class); $this->expectExceptionMessage('Circular reference detected for parameter "env(resolve:DUMMY_ENV_VAR)" ("env(resolve:DUMMY_ENV_VAR)" > "env(resolve:DUMMY_ENV_VAR)").'); $container = new ContainerBuilder(); $container->setParameter('foo', '%bar%'); @@ -820,11 +820,11 @@ class PhpDumperTest extends TestCase switch (++$i) { case 0: $this->assertEquals('k1', $k); - $this->assertInstanceOf('stdCLass', $v); + $this->assertInstanceOf(\stdCLass::class, $v); break; case 1: $this->assertEquals('k2', $k); - $this->assertInstanceOf('Symfony_DI_PhpDumper_Test_Lazy_Argument_Provide_Generator', $v); + $this->assertInstanceOf(\Symfony_DI_PhpDumper_Test_Lazy_Argument_Provide_Generator::class, $v); break; } } @@ -965,7 +965,7 @@ class PhpDumperTest extends TestCase eval('?>'.$dumper->dump(['class' => 'Symfony_DI_PhpDumper_Test_Private_With_Ignore_On_Invalid_Reference'])); $container = new \Symfony_DI_PhpDumper_Test_Private_With_Ignore_On_Invalid_Reference(); - $this->assertInstanceOf('BazClass', $container->get('bar')->getBaz()); + $this->assertInstanceOf(\BazClass::class, $container->get('bar')->getBaz()); } public function testArrayParameters() @@ -1093,7 +1093,7 @@ class PhpDumperTest extends TestCase $this->assertSame($manager3, $listener3->manager); $listener4 = $container->get('listener4'); - $this->assertInstanceOf('stdClass', $listener4); + $this->assertInstanceOf(\stdClass::class, $listener4); } public function provideAlmostCircular() @@ -1172,7 +1172,7 @@ class PhpDumperTest extends TestCase $container = new \Symfony_DI_PhpDumper_Test_Literal_Class_With_Root_Namespace(); - $this->assertInstanceOf('stdClass', $container->get('foo')); + $this->assertInstanceOf(\stdClass::class, $container->get('foo')); } public function testDumpHandlesObjectClassNames() @@ -1197,7 +1197,7 @@ class PhpDumperTest extends TestCase $container = new \Symfony_DI_PhpDumper_Test_Object_Class_Name(); - $this->assertInstanceOf('stdClass', $container->get('bar')); + $this->assertInstanceOf(\stdClass::class, $container->get('bar')); } public function testUninitializedSyntheticReference() @@ -1276,7 +1276,7 @@ class PhpDumperTest extends TestCase public function testErroredDefinition() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Service "errored_definition" is broken.'); $container = include self::$fixturesPath.'/containers/container9.php'; $container->setParameter('foo_bar', 'foo_bar'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PreloaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PreloaderTest.php index ff70bb75ea..9d3817e6ca 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PreloaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PreloaderTest.php @@ -28,10 +28,10 @@ class PreloaderTest extends TestCase $r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\Dummy', &$preloaded]); - self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\Dummy', false)); - self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\A', false)); - self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\B', false)); - self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\C', false)); + self::assertTrue(class_exists(\Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\Dummy::class, false)); + self::assertTrue(class_exists(\Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\A::class, false)); + self::assertTrue(class_exists(\Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\B::class, false)); + self::assertTrue(class_exists(\Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\C::class, false)); } /** @@ -45,7 +45,7 @@ class PreloaderTest extends TestCase $preloaded = []; $r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\DummyWithInterface', &$preloaded]); - self::assertFalse(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\DummyWithInterface', false)); + self::assertFalse(class_exists(\Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\DummyWithInterface::class, false)); } /** @@ -60,8 +60,8 @@ class PreloaderTest extends TestCase $r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\UnionDummy', &$preloaded]); - self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\UnionDummy', false)); - self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\D', false)); - self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\E', false)); + self::assertTrue(class_exists(\Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\UnionDummy::class, false)); + self::assertTrue(class_exists(\Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\D::class, false)); + self::assertTrue(class_exists(\Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\E::class, false)); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php b/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php index e3630aa421..80b10e0fb1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php @@ -106,7 +106,7 @@ class EnvVarProcessorTest extends TestCase */ public function testGetEnvIntInvalid($value) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Non-numeric env var'); $processor = new EnvVarProcessor(new Container()); @@ -156,7 +156,7 @@ class EnvVarProcessorTest extends TestCase */ public function testGetEnvFloatInvalid($value) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Non-numeric env var'); $processor = new EnvVarProcessor(new Container()); @@ -205,7 +205,7 @@ class EnvVarProcessorTest extends TestCase */ public function testGetEnvConstInvalid($value) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('undefined constant'); $processor = new EnvVarProcessor(new Container()); @@ -283,7 +283,7 @@ class EnvVarProcessorTest extends TestCase public function testGetEnvInvalidJson() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Syntax error'); $processor = new EnvVarProcessor(new Container()); @@ -299,7 +299,7 @@ class EnvVarProcessorTest extends TestCase */ public function testGetEnvJsonOther($value) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Invalid JSON env var'); $processor = new EnvVarProcessor(new Container()); @@ -323,7 +323,7 @@ class EnvVarProcessorTest extends TestCase public function testGetEnvUnknown() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Unsupported env var prefix'); $processor = new EnvVarProcessor(new Container()); @@ -336,7 +336,7 @@ class EnvVarProcessorTest extends TestCase public function testGetEnvKeyInvalidKey() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Invalid env "key:foo": a key specifier should be provided.'); $processor = new EnvVarProcessor(new Container()); @@ -350,7 +350,7 @@ class EnvVarProcessorTest extends TestCase */ public function testGetEnvKeyNoArrayResult($value) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Resolved value of "foo" did not result in an array value.'); $processor = new EnvVarProcessor(new Container()); @@ -376,7 +376,7 @@ class EnvVarProcessorTest extends TestCase */ public function testGetEnvKeyArrayKeyNotFound($value) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\EnvNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvNotFoundException::class); $this->expectExceptionMessage('Key "index" not found in'); $processor = new EnvVarProcessor(new Container()); @@ -465,7 +465,7 @@ class EnvVarProcessorTest extends TestCase public function testRequireMissingFile() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\EnvNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvNotFoundException::class); $this->expectExceptionMessage('missing-file'); $processor = new EnvVarProcessor(new Container()); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php index 16a1d39e29..a781472ed3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php @@ -36,7 +36,7 @@ class ExtensionTest extends TestCase public function testIsConfigEnabledOnNonEnableableConfig() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The config array has no \'enabled\' key.'); $extension = new EnableableExtension(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container14.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container14.php index 191afb8cdd..0086010c43 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container14.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container14.php @@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; * This file is included in Tests\Dumper\GraphvizDumperTest::testDumpWithFrozenCustomClassContainer * and Tests\Dumper\XmlDumperTest::testCompiledContainerCanBeDumped. */ -if (!class_exists('Container14\ProjectServiceContainer')) { +if (!class_exists(\Container14\ProjectServiceContainer::class)) { class ProjectServiceContainer extends ContainerBuilder { } diff --git a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php index 7f757297bc..fb97b31df3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/LazyProxy/Instantiator/RealServiceInstantiatorTest.php @@ -26,7 +26,7 @@ class RealServiceInstantiatorTest extends TestCase { $instantiator = new RealServiceInstantiator(); $instance = new \stdClass(); - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock(); $callback = function () use ($instance) { return $instance; }; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/DirectoryLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/DirectoryLoaderTest.php index 1029d84c0a..a62f7059f6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/DirectoryLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/DirectoryLoaderTest.php @@ -60,7 +60,7 @@ class DirectoryLoaderTest extends TestCase public function testExceptionIsRaisedWhenDirectoryDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The file "foo" does not exist (in:'); $this->loader->load('foo/'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php index f4c304117f..0570152fe5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php @@ -215,7 +215,7 @@ class FileLoaderTest extends TestCase public function testRegisterClassesWithBadPrefix() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/Expected to find class "Symfony\\\Component\\\DependencyInjection\\\Tests\\\Fixtures\\\Prototype\\\Bar" in file ".+" while importing services from resource "Prototype\/Sub\/\*", but it was not found\! Check the namespace prefix used with the resource/'); $container = new ContainerBuilder(); $loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures')); @@ -226,7 +226,7 @@ class FileLoaderTest extends TestCase public function testRegisterClassesWithIncompatibleExclude() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "exclude" pattern when importing classes for "Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\": make sure your "exclude" pattern (yaml/*) is a subset of the "resource" pattern (Prototype/*)'); $container = new ContainerBuilder(); $loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures')); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php index 52c3129fbd..edbbb70128 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php @@ -92,21 +92,21 @@ class IniFileLoaderTest extends TestCase public function testExceptionIsRaisedWhenIniFileDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The file "foo.ini" does not exist (in:'); $this->loader->load('foo.ini'); } public function testExceptionIsRaisedWhenIniFileCannotBeParsed() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "nonvalid.ini" file is not valid.'); @$this->loader->load('nonvalid.ini'); } public function testExceptionIsRaisedWhenIniFileIsAlmostValid() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "almostvalid.ini" file is not valid.'); @$this->loader->load('almostvalid.ini'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php index dd02ddb7e1..98a7f0add0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/PhpFileLoaderTest.php @@ -81,7 +81,7 @@ class PhpFileLoaderTest extends TestCase public function testAutoConfigureAndChildDefinitionNotAllowed() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The service "child_service" cannot have a "parent" and also have "autoconfigure". Try disabling autoconfiguration for the service.'); $fixtures = realpath(__DIR__.'/../Fixtures'); $container = new ContainerBuilder(); @@ -92,7 +92,7 @@ class PhpFileLoaderTest extends TestCase public function testFactoryShortNotationNotAllowed() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid factory "factory:method": the "service:method" notation is not available when using PHP-based DI configuration. Use "[ref(\'factory\'), \'method\']" instead.'); $fixtures = realpath(__DIR__.'/../Fixtures'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index e09bca14fb..cb35f1cae6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -55,7 +55,7 @@ class XmlFileLoaderTest extends TestCase $loader->load('foo.xml'); $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not exist'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the loaded file does not exist'); $this->assertStringStartsWith('The file "foo.xml" does not exist (in:', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not exist'); } } @@ -71,11 +71,11 @@ class XmlFileLoaderTest extends TestCase $m->invoke($loader, self::$fixturesPath.'/ini/parameters.ini'); $this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'parameters.ini'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $e = $e->getPrevious(); - $this->assertInstanceOf('InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $this->assertStringStartsWith('[ERROR 4] Start tag expected, \'<\' not found (in', $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); } @@ -85,16 +85,16 @@ class XmlFileLoaderTest extends TestCase $m->invoke($loader, self::$fixturesPath.'/xml/nonvalid.xml'); $this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid.xml'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $e = $e->getPrevious(); - $this->assertInstanceOf('InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); $this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); } $xml = $m->invoke($loader, self::$fixturesPath.'/xml/services1.xml'); - $this->assertInstanceOf('DOMDocument', $xml, '->parseFileToDOM() returns an SimpleXMLElement object'); + $this->assertInstanceOf(\DOMDocument::class, $xml, '->parseFileToDOM() returns an SimpleXMLElement object'); } public function testLoadWithExternalEntitiesDisabled() @@ -195,11 +195,11 @@ class XmlFileLoaderTest extends TestCase $loader->load('services4_bad_import_with_errors.xml'); $this->fail('->load() throws a LoaderLoadException if the imported xml file configuration does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the imported xml file configuration does not exist'); + $this->assertInstanceOf(\Symfony\Component\Config\Exception\LoaderLoadException::class, $e, '->load() throws a LoaderLoadException if the imported xml file configuration does not exist'); $this->assertMatchesRegularExpression(sprintf('#^The file "%1$s" does not exist \(in: .+\) in %1$s \(which is being imported from ".+%2$s"\)\.$#', 'foo_fake\.xml', 'services4_bad_import_with_errors\.xml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported xml file configuration does not exist'); $e = $e->getPrevious(); - $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\FileLocatorFileNotFoundException', $e, '->load() throws a FileLocatorFileNotFoundException if the imported xml file configuration does not exist'); + $this->assertInstanceOf(\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException::class, $e, '->load() throws a FileLocatorFileNotFoundException if the imported xml file configuration does not exist'); $this->assertMatchesRegularExpression(sprintf('#^The file "%s" does not exist \(in: .+\)\.$#', 'foo_fake\.xml'), $e->getMessage(), '->load() throws a FileLocatorFileNotFoundException if the imported xml file configuration does not exist'); } @@ -207,15 +207,15 @@ class XmlFileLoaderTest extends TestCase $loader->load('services4_bad_import_nonvalid.xml'); $this->fail('->load() throws an LoaderLoadException if the imported configuration does not validate the XSD'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the imported configuration does not validate the XSD'); + $this->assertInstanceOf(\Symfony\Component\Config\Exception\LoaderLoadException::class, $e, '->load() throws a LoaderLoadException if the imported configuration does not validate the XSD'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid\.xml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported configuration does not validate the XSD'); $e = $e->getPrevious(); - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid\.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $e = $e->getPrevious(); - $this->assertInstanceOf('Symfony\\Component\\Config\\Util\\Exception\\XmlParsingException', $e, '->load() throws a XmlParsingException if the configuration does not validate the XSD'); + $this->assertInstanceOf(\Symfony\Component\Config\Util\Exception\XmlParsingException::class, $e, '->load() throws a XmlParsingException if the configuration does not validate the XSD'); $this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->load() throws a XmlParsingException if the loaded file does not validate the XSD'); } } @@ -231,7 +231,7 @@ class XmlFileLoaderTest extends TestCase // anonymous service as an argument $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->assertInstanceOf(Reference::class, $args[0], '->load() converts anonymous services to references to "normal" services'); $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'); @@ -240,7 +240,7 @@ class XmlFileLoaderTest extends TestCase // inner anonymous services $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->assertInstanceOf(Reference::class, $args[0], '->load() converts anonymous services to references to "normal" services'); $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'); @@ -249,7 +249,7 @@ class XmlFileLoaderTest extends TestCase // anonymous service as a property $properties = $services['foo']->getProperties(); $property = $properties['p']; - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $property, '->load() converts anonymous services to references to "normal" services'); + $this->assertInstanceOf(Reference::class, $property, '->load() converts anonymous services to references to "normal" services'); $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'); @@ -265,7 +265,7 @@ class XmlFileLoaderTest extends TestCase public function testLoadAnonymousServicesWithoutId() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Top-level services must have "id" attribute, none found in'); $container = new ContainerBuilder(); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); @@ -291,7 +291,7 @@ class XmlFileLoaderTest extends TestCase $services = $container->getDefinitions(); $this->assertArrayHasKey('foo', $services, '->load() parses elements'); $this->assertFalse($services['not_shared']->isShared(), '->load() parses shared flag'); - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts element to Definition instances'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Definition::class, $services['foo'], '->load() converts element to Definition instances'); $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag'); $this->assertEquals(['foo', new Reference('foo'), [true, false]], $services['arguments']->getArguments(), '->load() parses the argument tags'); @@ -373,7 +373,7 @@ class XmlFileLoaderTest extends TestCase public function testParseTagsWithoutNameThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $container = new ContainerBuilder(); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); $loader->load('tag_without_name.xml'); @@ -381,7 +381,7 @@ class XmlFileLoaderTest extends TestCase public function testParseTagWithEmptyNameThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The tag name for service ".+" in .* must be a non-empty string/'); $container = new ContainerBuilder(); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); @@ -494,11 +494,11 @@ class XmlFileLoaderTest extends TestCase $loader->load('extensions/services3.xml'); $this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'services3.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $e = $e->getPrevious(); - $this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertStringContainsString('The attribute \'bar\' is not allowed', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); } @@ -531,11 +531,11 @@ class XmlFileLoaderTest extends TestCase $loader->load('extensions/services7.xml'); $this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'services7.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $e = $e->getPrevious(); - $this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertStringContainsString('The attribute \'bar\' is not allowed', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); } } @@ -582,11 +582,11 @@ class XmlFileLoaderTest extends TestCase $loader->load('withdoctype.xml'); $this->fail('->load() throws an InvalidArgumentException if the configuration contains a document type'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration contains a document type'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'withdoctype.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type'); $e = $e->getPrevious(); - $this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration contains a document type'); $this->assertSame('Document types are not allowed.', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type'); } } @@ -731,7 +731,7 @@ class XmlFileLoaderTest extends TestCase public function testAliasDefinitionContainsUnsupportedElements() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid attribute "class" defined for alias "bar" in'); $container = new ContainerBuilder(); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); @@ -814,7 +814,7 @@ class XmlFileLoaderTest extends TestCase public function testInstanceOfAndChildDefinitionNotAllowed() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The service "child_service" cannot use the "parent" option in the same file where "instanceof" configuration is defined as using both is not supported. Move your child definitions to a separate file.'); $container = new ContainerBuilder(); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); @@ -824,7 +824,7 @@ class XmlFileLoaderTest extends TestCase public function testAutoConfigureAndChildDefinitionNotAllowed() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The service "child_service" cannot have a "parent" and also have "autoconfigure". Try setting autoconfigure="false" for the service.'); $container = new ContainerBuilder(); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); @@ -834,7 +834,7 @@ class XmlFileLoaderTest extends TestCase public function testDefaultsAndChildDefinitionNotAllowed() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Attribute "autowire" on service "child_service" cannot be inherited from "defaults" when a "parent" is set. Move your child definitions to a separate file or define this attribute explicitly.'); $container = new ContainerBuilder(); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index e79e6f58cc..71142af296 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -49,7 +49,7 @@ class YamlFileLoaderTest extends TestCase public function testLoadUnExistFile() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The file ".+" does not exist./'); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini')); $r = new \ReflectionObject($loader); @@ -61,7 +61,7 @@ class YamlFileLoaderTest extends TestCase public function testLoadInvalidYamlFile() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The file ".+" does not contain valid YAML./'); $path = self::$fixturesPath.'/ini'; $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator($path)); @@ -77,7 +77,7 @@ class YamlFileLoaderTest extends TestCase */ public function testLoadInvalidFile($file) { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader->load($file.'.yml'); @@ -143,11 +143,11 @@ class YamlFileLoaderTest extends TestCase $loader->load('services4_bad_import_with_errors.yml'); $this->fail('->load() throws a LoaderLoadException if the imported yaml file does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the imported yaml file does not exist'); + $this->assertInstanceOf(\Symfony\Component\Config\Exception\LoaderLoadException::class, $e, '->load() throws a LoaderLoadException if the imported yaml file does not exist'); $this->assertMatchesRegularExpression(sprintf('#^The file "%1$s" does not exist \(in: .+\) in %1$s \(which is being imported from ".+%2$s"\)\.$#', 'foo_fake\.yml', 'services4_bad_import_with_errors\.yml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported yaml file does not exist'); $e = $e->getPrevious(); - $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\FileLocatorFileNotFoundException', $e, '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist'); + $this->assertInstanceOf(\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException::class, $e, '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist'); $this->assertMatchesRegularExpression(sprintf('#^The file "%s" does not exist \(in: .+\)\.$#', 'foo_fake\.yml'), $e->getMessage(), '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist'); } @@ -155,11 +155,11 @@ class YamlFileLoaderTest extends TestCase $loader->load('services4_bad_import_nonvalid.yml'); $this->fail('->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid'); + $this->assertInstanceOf(\Symfony\Component\Config\Exception\LoaderLoadException::class, $e, '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid'); $this->assertMatchesRegularExpression(sprintf('#^The service file ".+%1$s" is not valid\. It should contain an array\. Check your YAML syntax in .+%1$s \(which is being imported from ".+%2$s"\)\.$#', 'nonvalid2\.yml', 'services4_bad_import_nonvalid.yml'), $e->getMessage(), '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid'); $e = $e->getPrevious(); - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag in the imported yaml file is not valid'); + $this->assertInstanceOf(InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tag in the imported yaml file is not valid'); $this->assertMatchesRegularExpression(sprintf('#^The service file ".+%s" is not valid\. It should contain an array\. Check your YAML syntax\.$#', 'nonvalid2\.yml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the tag in the imported yaml file is not valid'); } } @@ -172,7 +172,7 @@ class YamlFileLoaderTest extends TestCase $services = $container->getDefinitions(); $this->assertArrayHasKey('foo', $services, '->load() parses service elements'); $this->assertFalse($services['not_shared']->isShared(), '->load() parses the shared flag'); - $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts service element to Definition instances'); + $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Definition::class, $services['foo'], '->load() converts service element to Definition instances'); $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag'); $this->assertEquals(['foo', new Reference('foo'), [true, false]], $services['arguments']->getArguments(), '->load() parses the argument tags'); @@ -319,7 +319,7 @@ class YamlFileLoaderTest extends TestCase $loader->load('badtag1.yml'); $this->fail('->load() should throw an exception when the tags key of a service is not an array'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tags key is not an array'); + $this->assertInstanceOf(InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tags key is not an array'); $this->assertStringStartsWith('Parameter "tags" must be an array for service', $e->getMessage(), '->load() throws an InvalidArgumentException if the tags key is not an array'); } } @@ -331,7 +331,7 @@ class YamlFileLoaderTest extends TestCase $loader->load('badtag2.yml'); $this->fail('->load() should throw an exception when a tag is missing the name key'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if a tag is missing the name key'); + $this->assertInstanceOf(InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if a tag is missing the name key'); $this->assertStringStartsWith('A "tags" entry is missing a "name" key for service ', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag is missing the name key'); } } @@ -352,7 +352,7 @@ class YamlFileLoaderTest extends TestCase $taggedIterator = new TaggedIteratorArgument('foo', 'barfoo', 'foobar', true, 'getPriority'); $this->assertEquals(new ServiceLocatorArgument($taggedIterator), $container->getDefinition('foo_service_tagged_locator')->getArgument(0)); - if (is_subclass_of('Symfony\Component\Yaml\Exception\ExceptionInterface', 'Throwable')) { + if (is_subclass_of(\Symfony\Component\Yaml\Exception\ExceptionInterface::class, 'Throwable')) { // this test is not compatible with Yaml v3 $taggedIterator = new TaggedIteratorArgument('foo', null, null, true); $this->assertEquals(new ServiceLocatorArgument($taggedIterator), $container->getDefinition('bar_service_tagged_locator')->getArgument(0)); @@ -375,7 +375,7 @@ class YamlFileLoaderTest extends TestCase $loader->load('badtag3.yml'); $this->fail('->load() should throw an exception when a tag-attribute is not a scalar'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar'); + $this->assertInstanceOf(InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar'); $this->assertStringStartsWith('A "tags" attribute must be of a scalar-type for service "foo_service", tag "foo", attribute "bar"', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar'); } } @@ -394,7 +394,7 @@ class YamlFileLoaderTest extends TestCase public function testTagWithEmptyNameThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/'); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('tag_name_empty_string.yml'); @@ -402,7 +402,7 @@ class YamlFileLoaderTest extends TestCase public function testTagWithNonStringNameThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/'); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('tag_name_no_string.yml'); @@ -502,7 +502,7 @@ class YamlFileLoaderTest extends TestCase public function testPrototypeWithNamespaceAndNoResource() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/A "resource" attribute must be set when the "namespace" attribute is set for service ".+" in .+/'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -576,7 +576,7 @@ class YamlFileLoaderTest extends TestCase public function testInstanceOfAndChildDefinitionNotAllowed() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The service "child_service" cannot use the "parent" option in the same file where "_instanceof" configuration is defined as using both is not supported. Move your child definitions to a separate file.'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -586,7 +586,7 @@ class YamlFileLoaderTest extends TestCase public function testAutoConfigureAndChildDefinitionNotAllowed() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The service "child_service" cannot have a "parent" and also have "autoconfigure". Try setting "autoconfigure: false" for the service.'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -596,7 +596,7 @@ class YamlFileLoaderTest extends TestCase public function testDefaultsAndChildDefinitionNotAllowed() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Attribute "autowire" on service "child_service" cannot be inherited from "_defaults" when a "parent" is set. Move your child definitions to a separate file or define this attribute explicitly.'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -606,7 +606,7 @@ class YamlFileLoaderTest extends TestCase public function testChildDefinitionWithWrongSyntaxThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The value of the "parent" option for the "bar" service must be the id of the service without the "@" prefix (replace "@foo" with "foo").'); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('bad_parent.yml'); @@ -614,7 +614,7 @@ class YamlFileLoaderTest extends TestCase public function testDecoratedServicesWithWrongSyntaxThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The value of the "decorates" option for the "bar" service must be the id of the service without the "@" prefix (replace "@foo" with "foo").'); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('bad_decorates.yml'); @@ -622,7 +622,7 @@ class YamlFileLoaderTest extends TestCase public function testDecoratedServicesWithWrongOnInvalidSyntaxThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Did you mean null (without quotes)'); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('bad_decoration_on_invalid_null.yml'); @@ -630,7 +630,7 @@ class YamlFileLoaderTest extends TestCase public function testInvalidTagsWithDefaults() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./'); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('services31_invalid_tags.yml'); @@ -638,7 +638,7 @@ class YamlFileLoaderTest extends TestCase public function testUnderscoreServiceId() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Service names that start with an underscore are reserved. Rename the "_foo" service or define it in XML instead.'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -720,7 +720,7 @@ class YamlFileLoaderTest extends TestCase public function testAnonymousServicesWithAliases() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -729,7 +729,7 @@ class YamlFileLoaderTest extends TestCase public function testAnonymousServicesInParameters() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -748,7 +748,7 @@ class YamlFileLoaderTest extends TestCase public function testEmptyDefaultsThrowsClearException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/Service "_defaults" key must be an array, "NULL" given in ".+bad_empty_defaults\.yml"\./'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -757,7 +757,7 @@ class YamlFileLoaderTest extends TestCase public function testEmptyInstanceofThrowsClearException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/Service "_instanceof" key must be an array, "NULL" given in ".+bad_empty_instanceof\.yml"\./'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -766,7 +766,7 @@ class YamlFileLoaderTest extends TestCase public function testUnsupportedKeywordThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/^The configuration key "private" is unsupported for definition "bar"/'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -775,7 +775,7 @@ class YamlFileLoaderTest extends TestCase public function testUnsupportedKeywordInServiceAliasThrowsException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/^The configuration key "calls" is unsupported for the service "bar" which is defined as an alias/'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); @@ -835,7 +835,7 @@ class YamlFileLoaderTest extends TestCase public function testProcessNotExistingActionParam() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Cannot autowire service "Symfony\Component\DependencyInjection\Tests\Fixtures\ConstructNotExists": argument "$notExist" of method "__construct()" has type "Symfony\Component\DependencyInjection\Tests\Fixtures\NotExist" but this class was not found.'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ContainerBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ContainerBagTest.php index 81be4fb74e..c4c690c592 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ContainerBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ContainerBagTest.php @@ -50,7 +50,7 @@ class ContainerBagTest extends TestCase public function testGetParameterNotFound() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->containerBag->get('bar'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php index fa00ad13fc..a6c929d880 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php @@ -18,7 +18,7 @@ class EnvPlaceholderParameterBagTest extends TestCase { public function testGetThrowsInvalidArgumentExceptionIfEnvNameContainsNonWordCharacters() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $bag = new EnvPlaceholderParameterBag(); $bag->get('env(%foo%)'); } @@ -161,7 +161,7 @@ class EnvPlaceholderParameterBagTest extends TestCase public function testResolveThrowsOnBadDefaultValue() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('The default value of env parameter "ARRAY_VAR" must be scalar or null, "array" given.'); $bag = new EnvPlaceholderParameterBag(); $bag->get('env(ARRAY_VAR)'); @@ -181,7 +181,7 @@ class EnvPlaceholderParameterBagTest extends TestCase public function testGetThrowsOnBadDefaultValue() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('The default value of an env() parameter must be scalar or null, but "array" given to "env(ARRAY_VAR)".'); $bag = new EnvPlaceholderParameterBag(); $bag->set('env(ARRAY_VAR)', []); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php index ed89c8e4e4..40630364d8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php @@ -28,28 +28,28 @@ class FrozenParameterBagTest extends TestCase public function testClear() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $bag = new FrozenParameterBag([]); $bag->clear(); } public function testSet() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $bag = new FrozenParameterBag([]); $bag->set('foo', 'bar'); } public function testAdd() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $bag = new FrozenParameterBag([]); $bag->add([]); } public function testRemove() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $bag = new FrozenParameterBag(['foo' => 'bar']); $bag->remove('foo'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php index 1a442967a4..8bdabb7bb8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php @@ -61,7 +61,7 @@ class ParameterBagTest extends TestCase $bag->get('baba'); $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); + $this->assertInstanceOf(ParameterNotFoundException::class, $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); $this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php b/src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php index 025691d74a..7e415b226a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php @@ -25,7 +25,7 @@ class ServiceLocatorTest extends BaseServiceLocatorTest public function testGetThrowsOnUndefinedService() { - $this->expectException('Psr\Container\NotFoundExceptionInterface'); + $this->expectException(\Psr\Container\NotFoundExceptionInterface::class); $this->expectExceptionMessage('Service "dummy" not found: the container inside "Symfony\Component\DependencyInjection\Tests\ServiceLocatorTest" is a smaller service locator that only knows about the "foo" and "bar" services.'); $locator = $this->getServiceLocator([ 'foo' => function () { return 'bar'; }, @@ -37,14 +37,14 @@ class ServiceLocatorTest extends BaseServiceLocatorTest public function testThrowsOnCircularReference() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class); $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".'); parent::testThrowsOnCircularReference(); } public function testThrowsInServiceSubscriber() { - $this->expectException('Psr\Container\NotFoundExceptionInterface'); + $this->expectException(\Psr\Container\NotFoundExceptionInterface::class); $this->expectExceptionMessage('Service "foo" not found: even though it exists in the app\'s container, the container inside "caller" is a smaller service locator that only knows about the "bar" service. Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "SomeServiceSubscriber::getSubscribedServices()".'); $container = new Container(); $container->set('foo', new \stdClass()); @@ -57,7 +57,7 @@ class ServiceLocatorTest extends BaseServiceLocatorTest public function testGetThrowsServiceNotFoundException() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class); $this->expectExceptionMessage('Service "foo" not found: even though it exists in the app\'s container, the container inside "foo" is a smaller service locator that is empty... Try using dependency injection instead.'); $container = new Container(); $container->set('foo', new \stdClass()); diff --git a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php index 3b25fee5dc..9868e49c53 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php @@ -78,14 +78,14 @@ abstract class AbstractCrawlerTest extends TestCase public function testAddInvalidType() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $crawler = $this->createCrawler(); $crawler->add(1); } public function testAddMultipleDocumentNode() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Attaching DOM nodes from multiple documents in the same crawler is forbidden.'); $crawler = $this->createTestCrawler(); $crawler->addHtmlContent($this->getDoctype().'
', 'UTF-8'); @@ -247,7 +247,7 @@ abstract class AbstractCrawlerTest extends TestCase { $crawler = $this->createTestCrawler()->filterXPath('//li'); $this->assertNotSame($crawler, $crawler->eq(0), '->eq() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->eq(0), '->eq() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->eq(0), '->eq() returns a new instance of a crawler'); $this->assertEquals('Two', $crawler->eq(1)->text(), '->eq() returns the nth node of the list'); $this->assertCount(0, $crawler->eq(100), '->eq() returns an empty crawler if the nth node does not exist'); @@ -282,7 +282,7 @@ abstract class AbstractCrawlerTest extends TestCase { $crawler = $this->createTestCrawler()->filterXPath('//li'); - $this->assertInstanceOf('Traversable', $crawler); + $this->assertInstanceOf(\Traversable::class, $crawler); $this->assertContainsOnlyInstancesOf('DOMElement', iterator_to_array($crawler), 'Iterating a Crawler gives DOMElement instances'); } @@ -290,7 +290,7 @@ abstract class AbstractCrawlerTest extends TestCase { $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); $this->assertNotSame($crawler->slice(), $crawler, '->slice() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->slice(), '->slice() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->slice(), '->slice() returns a new instance of a crawler'); $this->assertCount(3, $crawler->slice(), '->slice() does not slice the nodes in the list if any param is entered'); $this->assertCount(1, $crawler->slice(1, 1), '->slice() slices the nodes in the list'); @@ -303,7 +303,7 @@ abstract class AbstractCrawlerTest extends TestCase return 1 !== $i; }); $this->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $nodes, '->reduce() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $nodes, '->reduce() returns a new instance of a crawler'); $this->assertCount(2, $nodes, '->reduce() filters the nodes in the list'); } @@ -412,7 +412,7 @@ abstract class AbstractCrawlerTest extends TestCase { $crawler = $this->createTestCrawler(); $this->assertNotSame($crawler, $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler'); $crawler = $this->createTestCrawler()->filterXPath('//ul'); $this->assertCount(6, $crawler->filterXPath('//li'), '->filterXPath() filters the node list with the XPath expression'); @@ -579,7 +579,7 @@ abstract class AbstractCrawlerTest extends TestCase { $crawler = $this->createTestCrawler(); $this->assertNotSame($crawler, $crawler->filter('li'), '->filter() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->filter('li'), '->filter() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->filter('li'), '->filter() returns a new instance of a crawler'); $crawler = $this->createTestCrawler()->filter('ul'); @@ -632,7 +632,7 @@ abstract class AbstractCrawlerTest extends TestCase { $crawler = $this->createTestCrawler(); $this->assertNotSame($crawler, $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler'); $this->assertCount(1, $crawler->selectLink('Fabien\'s Foo'), '->selectLink() selects links by the node values'); $this->assertCount(1, $crawler->selectLink('Fabien\'s Bar'), '->selectLink() selects links by the alt attribute of a clickable image'); @@ -651,7 +651,7 @@ abstract class AbstractCrawlerTest extends TestCase { $crawler = $this->createTestCrawler(); $this->assertNotSame($crawler, $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->selectImage('Bar'), '->selectImage() returns a new instance of a crawler'); $this->assertCount(1, $crawler->selectImage('Fabien\'s Bar'), '->selectImage() selects images by alt attribute'); $this->assertCount(2, $crawler->selectImage('Fabien"s Bar'), '->selectImage() selects images by alt attribute'); @@ -662,7 +662,7 @@ abstract class AbstractCrawlerTest extends TestCase { $crawler = $this->createTestCrawler(); $this->assertNotSame($crawler, $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler'); $this->assertEquals(1, $crawler->selectButton('FooValue')->count(), '->selectButton() selects buttons'); $this->assertEquals(1, $crawler->selectButton('FooName')->count(), '->selectButton() selects buttons'); @@ -719,7 +719,7 @@ HTML; public function testLink() { $crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Link', $crawler->link(), '->link() returns a Link instance'); + $this->assertInstanceOf(\Symfony\Component\DomCrawler\Link::class, $crawler->link(), '->link() returns a Link instance'); $this->assertEquals('POST', $crawler->link('post')->getMethod(), '->link() takes a method as its argument'); @@ -736,7 +736,7 @@ HTML; public function testInvalidLink() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The selected node should be instance of DOMElement'); $crawler = $this->createTestCrawler('http://example.com/bar/'); $crawler->filterXPath('//li/text()')->link(); @@ -744,7 +744,7 @@ HTML; public function testInvalidLinks() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The selected node should be instance of DOMElement'); $crawler = $this->createTestCrawler('http://example.com/bar/'); $crawler->filterXPath('//li/text()')->link(); @@ -753,7 +753,7 @@ HTML; public function testImage() { $crawler = $this->createTestCrawler('http://example.com/bar/')->selectImage('Bar'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Image', $crawler->image(), '->image() returns an Image instance'); + $this->assertInstanceOf(\Symfony\Component\DomCrawler\Image::class, $crawler->image(), '->image() returns an Image instance'); try { $this->createTestCrawler()->filterXPath('//ol')->image(); @@ -829,8 +829,8 @@ HTML; $testCrawler = $this->createTestCrawler('http://example.com/bar/'); $crawler = $testCrawler->selectButton('FooValue'); $crawler2 = $testCrawler->selectButton('FooBarValue'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Form', $crawler->form(), '->form() returns a Form instance'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Form', $crawler2->form(), '->form() returns a Form instance'); + $this->assertInstanceOf(\Symfony\Component\DomCrawler\Form::class, $crawler->form(), '->form() returns a Form instance'); + $this->assertInstanceOf(\Symfony\Component\DomCrawler\Form::class, $crawler2->form(), '->form() returns a Form instance'); $this->assertEquals($crawler->form()->getFormNode()->getAttribute('id'), $crawler2->form()->getFormNode()->getAttribute('id'), '->form() works on elements with form attribute'); @@ -848,7 +848,7 @@ HTML; public function testInvalidForm() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The selected node should be instance of DOMElement'); $crawler = $this->createTestCrawler('http://example.com/bar/'); $crawler->filterXPath('//li/text()')->form(); @@ -858,7 +858,7 @@ HTML; { $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); $this->assertNotSame($crawler, $crawler->last(), '->last() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->last(), '->last() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->last(), '->last() returns a new instance of a crawler'); $this->assertEquals('Three', $crawler->last()->text()); } @@ -867,7 +867,7 @@ HTML; { $crawler = $this->createTestCrawler()->filterXPath('//li'); $this->assertNotSame($crawler, $crawler->first(), '->first() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->first(), '->first() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->first(), '->first() returns a new instance of a crawler'); $this->assertEquals('One', $crawler->first()->text()); } @@ -876,7 +876,7 @@ HTML; { $crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1); $this->assertNotSame($crawler, $crawler->siblings(), '->siblings() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->siblings(), '->siblings() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->siblings(), '->siblings() returns a new instance of a crawler'); $nodes = $crawler->siblings(); $this->assertEquals(2, $nodes->count()); @@ -999,7 +999,7 @@ HTML; { $crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1); $this->assertNotSame($crawler, $crawler->nextAll(), '->nextAll() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->nextAll(), '->nextAll() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->nextAll(), '->nextAll() returns a new instance of a crawler'); $nodes = $crawler->nextAll(); $this->assertEquals(1, $nodes->count()); @@ -1017,7 +1017,7 @@ HTML; { $crawler = $this->createTestCrawler()->filterXPath('//li')->eq(2); $this->assertNotSame($crawler, $crawler->previousAll(), '->previousAll() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->previousAll(), '->previousAll() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->previousAll(), '->previousAll() returns a new instance of a crawler'); $nodes = $crawler->previousAll(); $this->assertEquals(2, $nodes->count()); @@ -1035,7 +1035,7 @@ HTML; { $crawler = $this->createTestCrawler()->filterXPath('//ul'); $this->assertNotSame($crawler, $crawler->children(), '->children() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->children(), '->children() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->children(), '->children() returns a new instance of a crawler'); $nodes = $crawler->children(); $this->assertEquals(3, $nodes->count()); @@ -1095,7 +1095,7 @@ HTML; { $crawler = $this->createTestCrawler()->filterXPath('//li[1]'); $this->assertNotSame($crawler, $crawler->parents(), '->parents() returns a new instance of a crawler'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->parents(), '->parents() returns a new instance of a crawler'); + $this->assertInstanceOf(Crawler::class, $crawler->parents(), '->parents() returns a new instance of a crawler'); $nodes = $crawler->parents(); $this->assertEquals(3, $nodes->count()); @@ -1199,7 +1199,7 @@ HTML; public function testEvaluateThrowsAnExceptionIfDocumentIsEmpty() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->createCrawler()->evaluate('//form/input[1]'); } diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index db390efcca..52a59090c1 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -21,7 +21,7 @@ class FormTest extends TestCase public static function setUpBeforeClass(): void { // Ensure that the private helper class FormFieldRegistry is loaded - class_exists('Symfony\\Component\\DomCrawler\\Form'); + class_exists(Form::class); } public function testConstructorThrowsExceptionIfTheNodeHasNoFormAncestor() @@ -70,7 +70,7 @@ class FormTest extends TestCase */ public function testConstructorThrowsExceptionIfNoRelatedForm(\DOMElement $node) { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); new Form($node, 'http://example.com'); } @@ -682,7 +682,7 @@ class FormTest extends TestCase { $form = $this->createForm('
'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Field\\InputFormField', $form->get('bar'), '->get() returns the field object associated with the given name'); + $this->assertInstanceOf(\Symfony\Component\DomCrawler\Field\InputFormField::class, $form->get('bar'), '->get() returns the field object associated with the given name'); try { $form->get('foo'); @@ -698,7 +698,7 @@ class FormTest extends TestCase $fields = $form->all(); $this->assertCount(1, $fields, '->all() return an array of form field objects'); - $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Field\\InputFormField', $fields['bar'], '->all() return an array of form field objects'); + $this->assertInstanceOf(\Symfony\Component\DomCrawler\Field\InputFormField::class, $fields['bar'], '->all() return an array of form field objects'); } public function testSubmitWithoutAFormButton() @@ -741,14 +741,14 @@ class FormTest extends TestCase public function testFormFieldRegistryGetThrowAnExceptionWhenTheFieldDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $registry = new FormFieldRegistry(); $registry->get('foo'); } public function testFormFieldRegistrySetThrowAnExceptionWhenTheFieldDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $registry = new FormFieldRegistry(); $registry->set('foo', null); } @@ -827,7 +827,7 @@ class FormTest extends TestCase public function testFormRegistrySetValueOnCompoundField() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Cannot set value on a compound field "foo[bar]".'); $registry = new FormFieldRegistry(); $registry->add($this->getFormFieldMock('foo[bar][baz]')); @@ -837,7 +837,7 @@ class FormTest extends TestCase public function testFormRegistrySetArrayOnNotCompoundField() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Unreachable field "0"'); $registry = new FormFieldRegistry(); $registry->add($this->getFormFieldMock('bar')); @@ -864,13 +864,13 @@ class FormTest extends TestCase '); $form = new Form($dom->getElementsByTagName('form')->item(0), 'http://example.com'); - $this->assertInstanceOf('Symfony\Component\DomCrawler\Field\ChoiceFormField', $form->get('option')); + $this->assertInstanceOf(\Symfony\Component\DomCrawler\Field\ChoiceFormField::class, $form->get('option')); } protected function getFormFieldMock($name, $value = null) { $field = $this - ->getMockBuilder('Symfony\\Component\\DomCrawler\\Field\\FormField') + ->getMockBuilder(\Symfony\Component\DomCrawler\Field\FormField::class) ->setMethods(['getName', 'getValue', 'setValue', 'initialize']) ->disableOriginalConstructor() ->getMock() diff --git a/src/Symfony/Component/DomCrawler/Tests/ImageTest.php b/src/Symfony/Component/DomCrawler/Tests/ImageTest.php index 28ab693065..c8c3b0a723 100644 --- a/src/Symfony/Component/DomCrawler/Tests/ImageTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/ImageTest.php @@ -18,7 +18,7 @@ class ImageTest extends TestCase { public function testConstructorWithANonImgTag() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $dom = new \DOMDocument(); $dom->loadHTML('
'); @@ -36,7 +36,7 @@ class ImageTest extends TestCase public function testAbsoluteBaseUriIsMandatoryWhenImageUrlIsRelative() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $dom = new \DOMDocument(); $dom->loadHTML('foo'); diff --git a/src/Symfony/Component/DomCrawler/Tests/LinkTest.php b/src/Symfony/Component/DomCrawler/Tests/LinkTest.php index 258fb8bb5b..084a6efd77 100644 --- a/src/Symfony/Component/DomCrawler/Tests/LinkTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/LinkTest.php @@ -18,7 +18,7 @@ class LinkTest extends TestCase { public function testConstructorWithANonATag() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $dom = new \DOMDocument(); $dom->loadHTML('
'); @@ -36,7 +36,7 @@ class LinkTest extends TestCase public function testAbsoluteBaseUriIsMandatoryWhenLinkUrlIsRelative() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $dom = new \DOMDocument(); $dom->loadHTML('foo'); diff --git a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php index 9cf3b66e2c..c375efe47d 100644 --- a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php +++ b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php @@ -322,7 +322,7 @@ class DotenvTest extends TestCase public function testLoadDirectory() { - $this->expectException('Symfony\Component\Dotenv\Exception\PathException'); + $this->expectException(\Symfony\Component\Dotenv\Exception\PathException::class); $dotenv = new Dotenv(true); $dotenv->load(__DIR__); } diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index 6385d28db2..45dc5d43b7 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -231,8 +231,8 @@ class DebugClassLoader public static function enable(): void { // Ensures we don't hit https://bugs.php.net/42098 - class_exists('Symfony\Component\ErrorHandler\ErrorHandler'); - class_exists('Psr\Log\LogLevel'); + class_exists(\Symfony\Component\ErrorHandler\ErrorHandler::class); + class_exists(\Psr\Log\LogLevel::class); if (!\is_array($functions = spl_autoload_functions())) { return; diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index 5b5ab34433..29f674443d 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -187,7 +187,7 @@ class ErrorHandler $this->bootstrappingLogger = $bootstrappingLogger; $this->setDefaultLogger($bootstrappingLogger); } - $this->traceReflector = new \ReflectionProperty('Exception', 'trace'); + $this->traceReflector = new \ReflectionProperty(\Exception::class, 'trace'); $this->traceReflector->setAccessible(true); $this->debug = $debug; } diff --git a/src/Symfony/Component/ErrorHandler/Resources/views/exception_full.html.php b/src/Symfony/Component/ErrorHandler/Resources/views/exception_full.html.php index 4d46d59de5..6898ce028d 100644 --- a/src/Symfony/Component/ErrorHandler/Resources/views/exception_full.html.php +++ b/src/Symfony/Component/ErrorHandler/Resources/views/exception_full.html.php @@ -11,7 +11,7 @@ - +

include('assets/images/symfony-logo.svg'); ?> Symfony Exception

diff --git a/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php index c77d3711fc..141459f72c 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php @@ -51,7 +51,7 @@ class DebugClassLoaderTest extends TestCase $reflProp = $reflClass->getProperty('classLoader'); $reflProp->setAccessible(true); - $this->assertNotInstanceOf('Symfony\Component\ErrorHandler\DebugClassLoader', $reflProp->getValue($function[0])); + $this->assertNotInstanceOf(DebugClassLoader::class, $reflProp->getValue($function[0])); return; } @@ -62,7 +62,7 @@ class DebugClassLoaderTest extends TestCase public function testThrowingClass() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('boo'); try { class_exists(Fixtures\Throwing::class); @@ -77,14 +77,14 @@ class DebugClassLoaderTest extends TestCase public function testNameCaseMismatch() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Case mismatch between loaded and declared class names'); class_exists(TestingCaseMismatch::class, true); } public function testFileCaseMismatch() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Case mismatch between class and real file names'); if (!file_exists(__DIR__.'/Fixtures/CaseMismatch.php')) { $this->markTestSkipped('Can only be run on case insensitive filesystems'); @@ -95,7 +95,7 @@ class DebugClassLoaderTest extends TestCase public function testPsr4CaseMismatch() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Case mismatch between loaded and declared class names'); class_exists(__NAMESPACE__.'\Fixtures\Psr4CaseMismatch', true); } @@ -176,7 +176,7 @@ class DebugClassLoaderTest extends TestCase $e = error_reporting(0); trigger_error('', E_USER_NOTICE); - class_exists('Symfony\Bridge\ErrorHandler\Tests\Fixtures\ExtendsDeprecatedParent', true); + class_exists(\Symfony\Bridge\ErrorHandler\Tests\Fixtures\ExtendsDeprecatedParent::class, true); error_reporting($e); restore_error_handler(); diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php index 6b566bf623..f3f67b9716 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php @@ -35,7 +35,7 @@ class ErrorHandlerTest extends TestCase $handler = ErrorHandler::register(); try { - $this->assertInstanceOf('Symfony\Component\ErrorHandler\ErrorHandler', $handler); + $this->assertInstanceOf(ErrorHandler::class, $handler); $this->assertSame($handler, ErrorHandler::register()); $newHandler = new ErrorHandler(); @@ -62,7 +62,7 @@ class ErrorHandlerTest extends TestCase public function testErrorGetLast() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger); $handler->screamAt(\E_ALL); @@ -194,7 +194,7 @@ class ErrorHandlerTest extends TestCase public function testDefaultLogger() { try { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger, \E_NOTICE); @@ -269,7 +269,7 @@ class ErrorHandlerTest extends TestCase restore_error_handler(); restore_exception_handler(); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $warnArgCheck = function ($logLevel, $message, $context) { $this->assertEquals('info', $logLevel); @@ -294,7 +294,7 @@ class ErrorHandlerTest extends TestCase restore_error_handler(); restore_exception_handler(); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $line = null; $logArgCheck = function ($level, $message, $context) use (&$line) { @@ -395,7 +395,7 @@ class ErrorHandlerTest extends TestCase $this->assertSame('User Deprecated: Foo deprecation', $exception->getMessage()); }; - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger ->expects($this->once()) ->method('log') @@ -413,7 +413,7 @@ class ErrorHandlerTest extends TestCase public function testHandleException(string $expectedMessage, \Throwable $exception) { try { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $logArgCheck = function ($level, $message, $context) use ($expectedMessage, $exception) { @@ -505,7 +505,7 @@ class ErrorHandlerTest extends TestCase $bootLogger->log(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); - $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $mockLogger->expects($this->once()) ->method('log') ->with(LogLevel::WARNING, 'Foo message', ['exception' => $exception]); @@ -520,7 +520,7 @@ class ErrorHandlerTest extends TestCase $exception = new \Exception('Foo message'); - $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $mockLogger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $mockLogger->expects($this->once()) ->method('log') ->with(LogLevel::CRITICAL, 'Uncaught Exception: Foo message', ['exception' => $exception]); @@ -535,7 +535,7 @@ class ErrorHandlerTest extends TestCase public function testHandleFatalError() { try { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $handler = ErrorHandler::register(); $error = [ @@ -584,7 +584,7 @@ class ErrorHandlerTest extends TestCase public function testCustomExceptionHandler() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $handler = new ErrorHandler(); $handler->setExceptionHandler(function ($e) use ($handler) { $handler->setExceptionHandler(null); diff --git a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php index a2b3231637..c4623bdbcb 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php @@ -28,7 +28,7 @@ class RegisterListenersPassTest extends TestCase */ public function testEventSubscriberWithoutInterface() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $builder = new ContainerBuilder(); $builder->register('event_dispatcher'); $builder->register('my_event_subscriber', 'stdClass') @@ -98,7 +98,7 @@ class RegisterListenersPassTest extends TestCase public function testAbstractEventListener() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The service "foo" tagged "kernel.event_listener" must not be abstract.'); $container = new ContainerBuilder(); $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', []); @@ -110,7 +110,7 @@ class RegisterListenersPassTest extends TestCase public function testAbstractEventSubscriber() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The service "foo" tagged "kernel.event_subscriber" must not be abstract.'); $container = new ContainerBuilder(); $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_subscriber', []); @@ -159,7 +159,7 @@ class RegisterListenersPassTest extends TestCase public function testEventSubscriberUnresolvableClassName() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('You have requested a non-existent parameter "subscriber.class"'); $container = new ContainerBuilder(); $container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', []); diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index 5fb1658388..c3ed0cf20b 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -134,8 +134,8 @@ class EventDispatcherTest extends TestCase $this->dispatcher->dispatch(new Event(), self::preFoo); $this->assertTrue($this->listener->preFooInvoked); $this->assertFalse($this->listener->postFooInvoked); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), 'noevent')); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), self::preFoo)); + $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), 'noevent')); + $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), self::preFoo)); $event = new Event(); $return = $this->dispatcher->dispatch($event, self::preFoo); $this->assertSame($event, $return); @@ -148,8 +148,8 @@ class EventDispatcherTest extends TestCase $this->dispatcher->dispatch(new ContractsEvent(), self::preFoo); $this->assertTrue($this->listener->preFooInvoked); $this->assertFalse($this->listener->postFooInvoked); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), 'noevent')); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), self::preFoo)); + $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), 'noevent')); + $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), self::preFoo)); $event = new Event(); $return = $this->dispatcher->dispatch($event, self::preFoo); $this->assertSame($event, $return); @@ -228,7 +228,7 @@ class EventDispatcherTest extends TestCase $listeners = $this->dispatcher->getListeners('pre.foo'); $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); $this->assertCount(2, $listeners); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]); + $this->assertInstanceOf(\Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities::class, $listeners[0][0]); } public function testAddSubscriberWithMultipleListeners() diff --git a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php index e0b99f9086..ce6eeaaa70 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php @@ -33,7 +33,7 @@ class ImmutableEventDispatcherTest extends TestCase protected function setUp(): void { - $this->innerDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->innerDispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher); } @@ -79,7 +79,7 @@ class ImmutableEventDispatcherTest extends TestCase public function testAddSubscriberDisallowed() { $this->expectException(\BadMethodCallException::class); - $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock(); + $subscriber = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventSubscriberInterface::class)->getMock(); $this->dispatcher->addSubscriber($subscriber); } @@ -93,7 +93,7 @@ class ImmutableEventDispatcherTest extends TestCase public function testRemoveSubscriberDisallowed() { $this->expectException(\BadMethodCallException::class); - $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock(); + $subscriber = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventSubscriberInterface::class)->getMock(); $this->dispatcher->removeSubscriber($subscriber); } diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionFunctionTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionFunctionTest.php index d7e23cb41a..996361f58f 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionFunctionTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionFunctionTest.php @@ -23,14 +23,14 @@ class ExpressionFunctionTest extends TestCase { public function testFunctionDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('PHP function "fn_does_not_exist" does not exist.'); ExpressionFunction::fromPhp('fn_does_not_exist'); } public function testFunctionNamespaced() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('An expression function name must be defined when PHP function "Symfony\Component\ExpressionLanguage\Tests\fn_namespaced" is namespaced.'); ExpressionFunction::fromPhp('Symfony\Component\ExpressionLanguage\Tests\fn_namespaced'); } diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php index bd044621fe..4311e98eef 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php @@ -21,8 +21,8 @@ class ExpressionLanguageTest extends TestCase { public function testCachedParse() { - $cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock(); - $cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock(); + $cacheMock = $this->getMockBuilder(\Psr\Cache\CacheItemPoolInterface::class)->getMock(); + $cacheItemMock = $this->getMockBuilder(\Psr\Cache\CacheItemInterface::class)->getMock(); $savedParsedExpression = null; $expressionLanguage = new ExpressionLanguage($cacheMock); @@ -107,7 +107,7 @@ class ExpressionLanguageTest extends TestCase public function testParseThrowsInsteadOfNotice() { - $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError'); + $this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class); $this->expectExceptionMessage('Unexpected end of expression around position 6 for expression `node.`.'); $expressionLanguage = new ExpressionLanguage(); $expressionLanguage->parse('node.', ['node']); @@ -115,7 +115,7 @@ class ExpressionLanguageTest extends TestCase public function shortCircuitProviderEvaluate() { - $object = $this->getMockBuilder('stdClass')->setMethods(['foo'])->getMock(); + $object = $this->getMockBuilder(\stdClass::class)->setMethods(['foo'])->getMock(); $object->expects($this->never())->method('foo'); return [ @@ -155,8 +155,8 @@ class ExpressionLanguageTest extends TestCase public function testCachingWithDifferentNamesOrder() { - $cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock(); - $cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock(); + $cacheMock = $this->getMockBuilder(\Psr\Cache\CacheItemPoolInterface::class)->getMock(); + $cacheItemMock = $this->getMockBuilder(\Psr\Cache\CacheItemInterface::class)->getMock(); $expressionLanguage = new ExpressionLanguage($cacheMock); $savedParsedExpression = null; @@ -211,7 +211,7 @@ class ExpressionLanguageTest extends TestCase */ public function testRegisterAfterParse($registerCallback) { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $el = new ExpressionLanguage(); $el->parse('1 + 1', []); $registerCallback($el); @@ -222,7 +222,7 @@ class ExpressionLanguageTest extends TestCase */ public function testRegisterAfterEval($registerCallback) { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $el = new ExpressionLanguage(); $el->evaluate('1 + 1'); $registerCallback($el); @@ -230,7 +230,7 @@ class ExpressionLanguageTest extends TestCase public function testCallBadCallable() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessageMatches('/Unable to call method "\w+" of object "\w+"./'); $el = new ExpressionLanguage(); $el->evaluate('foo.myfunction()', ['foo' => new \stdClass()]); @@ -241,7 +241,7 @@ class ExpressionLanguageTest extends TestCase */ public function testRegisterAfterCompile($registerCallback) { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $el = new ExpressionLanguage(); $el->compile('1 + 1'); $registerCallback($el); diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php index 35aead6862..c909eacc25 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php @@ -39,7 +39,7 @@ class LexerTest extends TestCase public function testTokenizeThrowsErrorWithMessage() { - $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError'); + $this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class); $this->expectExceptionMessage('Unexpected character "\'" around position 33 for expression `service(faulty.expression.example\').dummyMethod()`.'); $expression = "service(faulty.expression.example').dummyMethod()"; $this->lexer->tokenize($expression); @@ -47,7 +47,7 @@ class LexerTest extends TestCase public function testTokenizeThrowsErrorOnUnclosedBrace() { - $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError'); + $this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class); $this->expectExceptionMessage('Unclosed "(" around position 7 for expression `service(unclosed.expression.dummyMethod()`.'); $expression = 'service(unclosed.expression.dummyMethod()'; $this->lexer->tokenize($expression); diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php index 2d5a0a6c8c..ef8fcb6ba1 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php @@ -20,7 +20,7 @@ class ParserTest extends TestCase { public function testParseWithInvalidName() { - $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError'); + $this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class); $this->expectExceptionMessage('Variable "foo" is not valid around position 1 for expression `foo`.'); $lexer = new Lexer(); $parser = new Parser([]); @@ -29,7 +29,7 @@ class ParserTest extends TestCase public function testParseWithZeroInNames() { - $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError'); + $this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class); $this->expectExceptionMessage('Variable "foo" is not valid around position 1 for expression `foo`.'); $lexer = new Lexer(); $parser = new Parser([]); @@ -197,7 +197,7 @@ class ParserTest extends TestCase */ public function testParseWithInvalidPostfixData($expr, $names = []) { - $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError'); + $this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class); $lexer = new Lexer(); $parser = new Parser([]); $parser->parse($lexer->tokenize($expr), $names); @@ -227,7 +227,7 @@ class ParserTest extends TestCase public function testNameProposal() { - $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError'); + $this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class); $this->expectExceptionMessage('Did you mean "baz"?'); $lexer = new Lexer(); $parser = new Parser([]); diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index b697d7f478..a0de640d03 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -33,7 +33,7 @@ class FilesystemTest extends FilesystemTestCase public function testCopyFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file'; $targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file'; @@ -42,7 +42,7 @@ class FilesystemTest extends FilesystemTestCase public function testCopyUnreadableFileFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); // skip test on Windows; PHP can't easily set file as unreadable on Windows if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test cannot run on Windows.'); @@ -118,7 +118,7 @@ class FilesystemTest extends FilesystemTestCase public function testCopyWithOverrideWithReadOnlyTargetFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); // skip test on Windows; PHP can't easily set file as unwritable on Windows if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test cannot run on Windows.'); @@ -220,7 +220,7 @@ class FilesystemTest extends FilesystemTestCase public function testMkdirCreatesDirectoriesFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $basePath = $this->workspace.\DIRECTORY_SEPARATOR; $dir = $basePath.'2'; @@ -240,7 +240,7 @@ class FilesystemTest extends FilesystemTestCase public function testTouchFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $file = $this->workspace.\DIRECTORY_SEPARATOR.'1'.\DIRECTORY_SEPARATOR.'2'; $this->filesystem->touch($file); @@ -396,7 +396,7 @@ class FilesystemTest extends FilesystemTestCase public function testFilesExistsFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); if ('\\' !== \DIRECTORY_SEPARATOR) { $this->markTestSkipped('Long file names are an issue on Windows'); } @@ -623,7 +623,7 @@ class FilesystemTest extends FilesystemTestCase public function testChownSymlinkFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfSymlinkIsMissing(); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; @@ -638,7 +638,7 @@ class FilesystemTest extends FilesystemTestCase public function testChownLinkFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfLinkIsMissing(); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; @@ -653,7 +653,7 @@ class FilesystemTest extends FilesystemTestCase public function testChownFail() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfPosixIsMissing(); $dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir'; @@ -726,7 +726,7 @@ class FilesystemTest extends FilesystemTestCase public function testChgrpSymlinkFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfSymlinkIsMissing(); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; @@ -741,7 +741,7 @@ class FilesystemTest extends FilesystemTestCase public function testChgrpLinkFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfLinkIsMissing(); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; @@ -756,7 +756,7 @@ class FilesystemTest extends FilesystemTestCase public function testChgrpFail() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $this->markAsSkippedIfPosixIsMissing(); $dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir'; @@ -779,7 +779,7 @@ class FilesystemTest extends FilesystemTestCase public function testRenameThrowsExceptionIfTargetAlreadyExists() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $file = $this->workspace.\DIRECTORY_SEPARATOR.'file'; $newPath = $this->workspace.\DIRECTORY_SEPARATOR.'new_file'; @@ -805,7 +805,7 @@ class FilesystemTest extends FilesystemTestCase public function testRenameThrowsExceptionOnError() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $file = $this->workspace.\DIRECTORY_SEPARATOR.uniqid('fs_test_', true); $newPath = $this->workspace.\DIRECTORY_SEPARATOR.'new_file'; @@ -1150,14 +1150,14 @@ class FilesystemTest extends FilesystemTestCase public function testMakePathRelativeWithRelativeStartPath() { - $this->expectException('Symfony\Component\Filesystem\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Filesystem\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The start path "var/lib/symfony/src/Symfony/Component" is not absolute.'); $this->assertSame('../../../', $this->filesystem->makePathRelative('/var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component')); } public function testMakePathRelativeWithRelativeEndPath() { - $this->expectException('Symfony\Component\Filesystem\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Filesystem\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The end path "var/lib/symfony/" is not absolute.'); $this->assertSame('../../../', $this->filesystem->makePathRelative('var/lib/symfony/', '/var/lib/symfony/src/Symfony/Component')); } @@ -1440,7 +1440,7 @@ class FilesystemTest extends FilesystemTestCase public function testTempnamWithZlibSchemeFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $scheme = 'compress.zlib://'; $dirname = $scheme.$this->workspace; @@ -1463,7 +1463,7 @@ class FilesystemTest extends FilesystemTestCase public function testTempnamWithPharSchemeFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); // Skip test if Phar disabled phar.readonly must be 0 in php.ini if (!\Phar::canWrite()) { $this->markTestSkipped('This test cannot run when phar.readonly is 1.'); @@ -1480,7 +1480,7 @@ class FilesystemTest extends FilesystemTestCase public function testTempnamWithHTTPSchemeFails() { - $this->expectException('Symfony\Component\Filesystem\Exception\IOException'); + $this->expectException(IOException::class); $scheme = 'http://'; $dirname = $scheme.$this->workspace; diff --git a/src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php b/src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php index 2f56092ed8..8108c3a358 100644 --- a/src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php +++ b/src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php @@ -23,7 +23,7 @@ class ComparatorTest extends TestCase $comparator->setOperator('foo'); $this->fail('->setOperator() throws an \InvalidArgumentException if the operator is not valid.'); } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '->setOperator() throws an \InvalidArgumentException if the operator is not valid.'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->setOperator() throws an \InvalidArgumentException if the operator is not valid.'); } $comparator = new Comparator(); diff --git a/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php b/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php index 3aebf52449..f89a1a283d 100644 --- a/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php +++ b/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php @@ -22,14 +22,14 @@ class DateComparatorTest extends TestCase new DateComparator('foobar'); $this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.'); } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.'); } try { new DateComparator(''); $this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.'); } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.'); } } diff --git a/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php b/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php index 5b49b660a7..6458133ebd 100644 --- a/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php +++ b/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php @@ -30,7 +30,7 @@ class NumberComparatorTest extends TestCase new NumberComparator($f); $this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.'); } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.'); } } } diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index efdb4c7447..f1a3af4321 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -17,7 +17,7 @@ class FinderTest extends Iterator\RealIteratorTestCase { public function testCreate() { - $this->assertInstanceOf('Symfony\Component\Finder\Finder', Finder::create()); + $this->assertInstanceOf(Finder::class, Finder::create()); } public function testDirectories() @@ -923,14 +923,14 @@ class FinderTest extends Iterator\RealIteratorTestCase public function testInWithNonExistentDirectory() { - $this->expectException('Symfony\Component\Finder\Exception\DirectoryNotFoundException'); + $this->expectException(\Symfony\Component\Finder\Exception\DirectoryNotFoundException::class); $finder = new Finder(); $finder->in('foobar'); } public function testInWithNonExistentDirectoryLegacyException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $finder = new Finder(); $finder->in('foobar'); } @@ -945,7 +945,7 @@ class FinderTest extends Iterator\RealIteratorTestCase public function testInWithNonDirectoryGlob() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $finder = new Finder(); $finder->in(__DIR__.'/Fixtures/A/a*'); } @@ -964,7 +964,7 @@ class FinderTest extends Iterator\RealIteratorTestCase public function testGetIteratorWithoutIn() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $finder = Finder::create(); $finder->getIterator(); } @@ -1105,7 +1105,7 @@ class FinderTest extends Iterator\RealIteratorTestCase public function testAppendReturnsAFinder() { - $this->assertInstanceOf('Symfony\\Component\\Finder\\Finder', Finder::create()->append([])); + $this->assertInstanceOf(Finder::class, Finder::create()->append([])); } public function testAppendDoesNotRequireIn() @@ -1144,7 +1144,7 @@ class FinderTest extends Iterator\RealIteratorTestCase public function testCountWithoutIn() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $finder = Finder::create()->files(); \count($finder); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php index 56d958cb60..4d55b112dc 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php @@ -17,7 +17,7 @@ class CustomFilterIteratorTest extends IteratorTestCase { public function testWithInvalidFilter() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new CustomFilterIterator(new Iterator(), ['foo']); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/IteratorTestCase.php b/src/Symfony/Component/Finder/Tests/Iterator/IteratorTestCase.php index 9bfc479de5..71db60b48c 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/IteratorTestCase.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/IteratorTestCase.php @@ -68,7 +68,7 @@ abstract class IteratorTestCase extends TestCase { $values = []; foreach ($iterator as $file) { - $this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file); + $this->assertInstanceOf(\Symfony\Component\Finder\SplFileInfo::class, $file); $values[] = $file->getPathname(); } @@ -85,7 +85,7 @@ abstract class IteratorTestCase extends TestCase { $values = []; foreach ($iterator as $file) { - $this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file); + $this->assertInstanceOf(\Symfony\Component\Finder\SplFileInfo::class, $file); $values[] = $file->getPathname(); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php index add8e7df59..12eacb8661 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php @@ -21,7 +21,7 @@ class SortableIteratorTest extends RealIteratorTestCase new SortableIterator(new Iterator([]), 'foobar'); $this->fail('__construct() throws an \InvalidArgumentException exception if the mode is not valid'); } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException exception if the mode is not valid'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '__construct() throws an \InvalidArgumentException exception if the mode is not valid'); } } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 0a20d94e66..47ac0ca036 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -124,7 +124,7 @@ class DateType extends AbstractType $dateFormat, $timeFormat, // see https://bugs.php.net/66323 - class_exists('IntlTimeZone', false) ? \IntlTimeZone::createDefault() : null, + class_exists(\IntlTimeZone::class, false) ? \IntlTimeZone::createDefault() : null, $calendar, $pattern ); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php index 9dd06af214..81d0eb06b9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php @@ -121,7 +121,7 @@ class FileType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $dataClass = null; - if (class_exists('Symfony\Component\HttpFoundation\File\File')) { + if (class_exists(\Symfony\Component\HttpFoundation\File\File::class)) { $dataClass = function (Options $options) { return $options['multiple'] ? null : 'Symfony\Component\HttpFoundation\File\File'; }; diff --git a/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php b/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php index ce3e63416e..6612c51d25 100644 --- a/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractExtensionTest.php @@ -28,7 +28,7 @@ class AbstractExtensionTest extends TestCase public function testGetType() { $loader = new ConcreteExtension(); - $this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('Symfony\Component\Form\Tests\Fixtures\FooType')); + $this->assertInstanceOf(FooType::class, $loader->getType('Symfony\Component\Form\Tests\Fixtures\FooType')); } } diff --git a/src/Symfony/Component/Form/Tests/AbstractFormTest.php b/src/Symfony/Component/Form/Tests/AbstractFormTest.php index 5dc1ad2311..a893861680 100644 --- a/src/Symfony/Component/Form/Tests/AbstractFormTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractFormTest.php @@ -38,7 +38,7 @@ abstract class AbstractFormTest extends TestCase protected function setUp(): void { $this->dispatcher = new EventDispatcher(); - $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(); $this->form = $this->createForm(); } @@ -58,16 +58,16 @@ abstract class AbstractFormTest extends TestCase protected function getDataMapper(): MockObject { - return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Form\DataMapperInterface::class)->getMock(); } protected function getDataTransformer(): MockObject { - return $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Form\DataTransformerInterface::class)->getMock(); } protected function getFormValidator(): MockObject { - return $this->getMockBuilder('Symfony\Component\Form\FormValidatorInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Form\FormValidatorInterface::class)->getMock(); } } diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 38ba3bf531..fc736eb7a3 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -34,7 +34,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase \Locale::setDefault('en'); - $this->csrfTokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); + $this->csrfTokenManager = $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock(); parent::setUp(); } diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php index 5e8facd4cf..5feeef083a 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php @@ -42,7 +42,7 @@ abstract class AbstractRequestHandlerTest extends TestCase protected function setUp(): void { - $this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Util\ServerParams')->setMethods(['getNormalizedIniPostMaxSize', 'getContentLength'])->getMock(); + $this->serverParams = $this->getMockBuilder(\Symfony\Component\Form\Util\ServerParams::class)->setMethods(['getNormalizedIniPostMaxSize', 'getContentLength'])->getMock(); $this->requestHandler = $this->getRequestHandler(); $this->factory = Forms::createFormFactoryBuilder()->getFormFactory(); $this->request = null; @@ -405,7 +405,7 @@ abstract class AbstractRequestHandlerTest extends TestCase protected function createBuilder($name, $compound = false, array $options = []) { - $builder = new FormBuilder($name, null, new EventDispatcher(), $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(), $options); + $builder = new FormBuilder($name, null, new EventDispatcher(), $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(), $options); $builder->setCompound($compound); if ($compound) { diff --git a/src/Symfony/Component/Form/Tests/AbstractTypeExtensionTest.php b/src/Symfony/Component/Form/Tests/AbstractTypeExtensionTest.php index 83019f488a..87ebad542a 100644 --- a/src/Symfony/Component/Form/Tests/AbstractTypeExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractTypeExtensionTest.php @@ -21,7 +21,7 @@ class AbstractTypeExtensionTest extends TestCase */ public function testImplementingNeitherGetExtendedTypeNorExtendsTypeThrowsException() { - $this->expectException('Symfony\Component\Form\Exception\LogicException'); + $this->expectException(\Symfony\Component\Form\Exception\LogicException::class); $this->expectExceptionMessage('You need to implement the static getExtendedTypes() method when implementing the "Symfony\Component\Form\FormTypeExtensionInterface" in "Symfony\Component\Form\Tests\TypeExtensionWithoutExtendedTypes".'); $extension = new TypeExtensionWithoutExtendedTypes(); $extension->getExtendedType(); diff --git a/src/Symfony/Component/Form/Tests/ButtonTest.php b/src/Symfony/Component/Form/Tests/ButtonTest.php index a69cc10687..bd132f4519 100644 --- a/src/Symfony/Component/Form/Tests/ButtonTest.php +++ b/src/Symfony/Component/Form/Tests/ButtonTest.php @@ -26,13 +26,13 @@ class ButtonTest extends TestCase protected function setUp(): void { - $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); + $this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(); } public function testSetParentOnSubmittedButton() { - $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException'); + $this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class); $button = $this->getButtonBuilder('button') ->getForm() ; diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index 51c4506057..3cdd93f479 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -34,7 +34,7 @@ class CachingFactoryDecoratorTest extends TestCase protected function setUp(): void { - $this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock(); + $this->decoratedFactory = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface::class)->getMock(); $this->factory = new CachingFactoryDecorator($this->decoratedFactory); } @@ -163,7 +163,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateFromLoaderSameLoader() { - $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $list = new ArrayChoiceList([]); $this->decoratedFactory->expects($this->once()) @@ -177,8 +177,8 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateFromLoaderDifferentLoader() { - $loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); - $loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader1 = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); + $loader2 = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $list1 = new ArrayChoiceList([]); $list2 = new ArrayChoiceList([]); @@ -196,7 +196,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateFromLoaderSameValueClosure() { - $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $list = new ArrayChoiceList([]); $closure = function () {}; @@ -211,7 +211,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateFromLoaderDifferentValueClosure() { - $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $list1 = new ArrayChoiceList([]); $list2 = new ArrayChoiceList([]); $closure1 = function () {}; @@ -232,7 +232,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateViewSamePreferredChoices() { $preferred = ['a']; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) @@ -248,7 +248,7 @@ class CachingFactoryDecoratorTest extends TestCase { $preferred1 = ['a']; $preferred2 = ['b']; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view1 = new ChoiceListView(); $view2 = new ChoiceListView(); @@ -267,7 +267,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateViewSamePreferredChoicesClosure() { $preferred = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) @@ -283,7 +283,7 @@ class CachingFactoryDecoratorTest extends TestCase { $preferred1 = function () {}; $preferred2 = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view1 = new ChoiceListView(); $view2 = new ChoiceListView(); @@ -302,7 +302,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateViewSameLabelClosure() { $labels = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) @@ -318,7 +318,7 @@ class CachingFactoryDecoratorTest extends TestCase { $labels1 = function () {}; $labels2 = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view1 = new ChoiceListView(); $view2 = new ChoiceListView(); @@ -337,7 +337,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateViewSameIndexClosure() { $index = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) @@ -353,7 +353,7 @@ class CachingFactoryDecoratorTest extends TestCase { $index1 = function () {}; $index2 = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view1 = new ChoiceListView(); $view2 = new ChoiceListView(); @@ -372,7 +372,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateViewSameGroupByClosure() { $groupBy = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) @@ -388,7 +388,7 @@ class CachingFactoryDecoratorTest extends TestCase { $groupBy1 = function () {}; $groupBy2 = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view1 = new ChoiceListView(); $view2 = new ChoiceListView(); @@ -407,7 +407,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateViewSameAttributes() { $attr = ['class' => 'foobar']; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) @@ -423,7 +423,7 @@ class CachingFactoryDecoratorTest extends TestCase { $attr1 = ['class' => 'foobar1']; $attr2 = ['class' => 'foobar2']; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view1 = new ChoiceListView(); $view2 = new ChoiceListView(); @@ -442,7 +442,7 @@ class CachingFactoryDecoratorTest extends TestCase public function testCreateViewSameAttributesClosure() { $attr = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view = new ChoiceListView(); $this->decoratedFactory->expects($this->once()) @@ -458,7 +458,7 @@ class CachingFactoryDecoratorTest extends TestCase { $attr1 = function () {}; $attr2 = function () {}; - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $view1 = new ChoiceListView(); $view2 = new ChoiceListView(); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index 7c717f441b..a70c84bd4b 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -193,7 +193,7 @@ class DefaultChoiceListFactoryTest extends TestCase public function testCreateFromLoader() { - $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $list = $this->factory->createListFromLoader($loader); @@ -202,7 +202,7 @@ class DefaultChoiceListFactoryTest extends TestCase public function testCreateFromLoaderWithValues() { - $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $value = function () {}; $list = $this->factory->createListFromLoader($loader, $value); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 96df5959be..f62a0dcb13 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -35,7 +35,7 @@ class PropertyAccessDecoratorTest extends TestCase protected function setUp(): void { - $this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock(); + $this->decoratedFactory = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface::class)->getMock(); $this->factory = new PropertyAccessDecorator($this->decoratedFactory); } @@ -69,7 +69,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateFromLoaderPropertyPath() { - $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') @@ -99,7 +99,7 @@ class PropertyAccessDecoratorTest extends TestCase // https://github.com/symfony/symfony/issues/5494 public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadable() { - $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') @@ -113,7 +113,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateFromLoaderPropertyPathInstance() { - $loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') @@ -127,7 +127,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewPreferredChoicesAsPropertyPath() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -141,7 +141,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewPreferredChoicesAsPropertyPathInstance() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -156,7 +156,7 @@ class PropertyAccessDecoratorTest extends TestCase // https://github.com/symfony/symfony/issues/5494 public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -170,7 +170,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewLabelsAsPropertyPath() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -184,7 +184,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewLabelsAsPropertyPathInstance() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -198,7 +198,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewIndicesAsPropertyPath() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -212,7 +212,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewIndicesAsPropertyPathInstance() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -226,7 +226,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewGroupsAsPropertyPath() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -240,7 +240,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewGroupsAsPropertyPathInstance() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -255,7 +255,7 @@ class PropertyAccessDecoratorTest extends TestCase // https://github.com/symfony/symfony/issues/5494 public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -269,7 +269,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewAttrAsPropertyPath() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') @@ -283,7 +283,7 @@ class PropertyAccessDecoratorTest extends TestCase public function testCreateViewAttrAsPropertyPathInstance() { - $list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); + $list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); $this->decoratedFactory->expects($this->once()) ->method('createView') diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php index 50403931be..7d6ed23e2a 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php @@ -39,8 +39,8 @@ class LazyChoiceListTest extends TestCase protected function setUp(): void { - $this->loadedList = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); - $this->loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); + $this->loadedList = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock(); + $this->loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock(); $this->value = function () {}; $this->list = new LazyChoiceList($this->loader, $this->value); } diff --git a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php index 0c10fdd5a3..431fcc16a8 100644 --- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php @@ -87,7 +87,7 @@ TXT public function testDebugSingleFormTypeNotFound() { - $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Could not find type "NonExistentType"'); $tester = $this->createCommandTester(); $tester->execute(['class' => 'NonExistentType'], ['decorated' => false, 'interactive' => false]); @@ -142,7 +142,7 @@ TXT public function testDebugInvalidFormType() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->createCommandTester()->execute(['class' => 'test']); } diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index c586aaebf6..c5953dd3f9 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -272,7 +272,7 @@ class CompoundFormTest extends AbstractFormTest public function testAddThrowsExceptionIfAlreadySubmitted() { - $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException'); + $this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class); $this->form->submit([]); $this->form->add($this->getBuilder('foo')->getForm()); } @@ -289,7 +289,7 @@ class CompoundFormTest extends AbstractFormTest public function testRemoveThrowsExceptionIfAlreadySubmitted() { - $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException'); + $this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class); $this->form->add($this->getBuilder('foo')->setCompound(false)->getForm()); $this->form->submit(['foo' => 'bar']); $this->form->remove('foo'); @@ -350,7 +350,7 @@ class CompoundFormTest extends AbstractFormTest ->method('mapDataToForms') ->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class)) ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) { - $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertInstanceOf(\Symfony\Component\Form\Util\InheritDataAwareIterator::class, $iterator->getInnerIterator()); $this->assertSame([$child->getName() => $child], iterator_to_array($iterator)); }); @@ -440,7 +440,7 @@ class CompoundFormTest extends AbstractFormTest ->method('mapDataToForms') ->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class)) ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) { - $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertInstanceOf(\Symfony\Component\Form\Util\InheritDataAwareIterator::class, $iterator->getInnerIterator()); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); }); @@ -513,9 +513,9 @@ class CompoundFormTest extends AbstractFormTest $mapper->expects($this->once()) ->method('mapFormsToData') - ->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar') + ->with($this->isInstanceOf(\RecursiveIteratorIterator::class), 'bar') ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) { - $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertInstanceOf(\Symfony\Component\Form\Util\InheritDataAwareIterator::class, $iterator->getInnerIterator()); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); $this->assertEquals('Bernhard', $child1->getData()); $this->assertEquals('Schussek', $child2->getData()); @@ -585,9 +585,9 @@ class CompoundFormTest extends AbstractFormTest $mapper->expects($this->once()) ->method('mapFormsToData') - ->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object) + ->with($this->isInstanceOf(\RecursiveIteratorIterator::class), $object) ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) { - $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertInstanceOf(\Symfony\Component\Form\Util\InheritDataAwareIterator::class, $iterator->getInnerIterator()); $this->assertSame(['name' => $child], iterator_to_array($iterator)); }); @@ -887,7 +887,7 @@ class CompoundFormTest extends AbstractFormTest $this->assertSame($error1, $errorsAsArray[0]); $this->assertSame($error2, $errorsAsArray[1]); - $this->assertInstanceOf('Symfony\Component\Form\FormErrorIterator', $errorsAsArray[2]); + $this->assertInstanceOf(\Symfony\Component\Form\FormErrorIterator::class, $errorsAsArray[2]); $nestedErrorsAsArray = iterator_to_array($errorsAsArray[2]); @@ -940,9 +940,9 @@ class CompoundFormTest extends AbstractFormTest // Basic cases are covered in SimpleFormTest public function testCreateViewWithChildren() { - $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); - $type1 = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); - $type2 = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); + $type1 = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); + $type2 = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); $options = ['a' => 'Foo', 'b' => 'Bar']; $field1 = $this->getBuilder('foo') ->setType($type1) @@ -996,7 +996,7 @@ class CompoundFormTest extends AbstractFormTest public function testNoClickedButton() { - $button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton') + $button = $this->getMockBuilder(\Symfony\Component\Form\SubmitButton::class) ->setConstructorArgs([new SubmitButtonBuilder('submit')]) ->setMethods(['isClicked']) ->getMock(); @@ -1018,7 +1018,7 @@ class CompoundFormTest extends AbstractFormTest public function testClickedButton() { - $button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton') + $button = $this->getMockBuilder(\Symfony\Component\Form\SubmitButton::class) ->setConstructorArgs([new SubmitButtonBuilder('submit')]) ->setMethods(['isClicked']) ->getMock(); @@ -1037,7 +1037,7 @@ class CompoundFormTest extends AbstractFormTest { $button = $this->getBuilder('submit')->getForm(); - $nestedForm = $this->getMockBuilder('Symfony\Component\Form\Form') + $nestedForm = $this->getMockBuilder(\Symfony\Component\Form\Form::class) ->setConstructorArgs([$this->getBuilder('nested')]) ->setMethods(['getClickedButton']) ->getMock(); @@ -1056,7 +1056,7 @@ class CompoundFormTest extends AbstractFormTest { $button = $this->getBuilder('submit')->getForm(); - $parentForm = $this->getMockBuilder('Symfony\Component\Form\Form') + $parentForm = $this->getMockBuilder(\Symfony\Component\Form\Form::class) ->setConstructorArgs([$this->getBuilder('parent')]) ->setMethods(['getClickedButton']) ->getMock(); diff --git a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php index 7e379f8a26..f750b42011 100644 --- a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php +++ b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php @@ -284,7 +284,7 @@ class FormPassTest extends TestCase public function testAddTaggedFormTypeExtensionWithoutExtendedTypeAttributeNorImplementingGetExtendedTypes() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('"form.type_extension" tagged services have to implement the static getExtendedTypes() method. Class "stdClass" for service "my.type_extension" does not implement it.'); $container = $this->createContainerBuilder(); @@ -298,7 +298,7 @@ class FormPassTest extends TestCase public function testAddTaggedFormTypeExtensionWithoutExtendingAnyType() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The getExtendedTypes() method for service "my.type_extension" does not return any extended types.'); $container = $this->createContainerBuilder(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php index 23246c4e3d..105df0514b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php @@ -70,7 +70,7 @@ class ArrayToPartsTransformerTest extends TestCase public function testTransformRequiresArray() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->transformer->transform('12345'); } @@ -123,7 +123,7 @@ class ArrayToPartsTransformerTest extends TestCase public function testReverseTransformPartiallyNull() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $input = [ 'first' => [ 'a' => '1', @@ -138,7 +138,7 @@ class ArrayToPartsTransformerTest extends TestCase public function testReverseTransformRequiresArray() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->transformer->reverseTransform('12345'); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php index 5aa87d6004..5aa4a865f4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php @@ -17,15 +17,15 @@ class BaseDateTimeTransformerTest extends TestCase { public function testConstructFailsIfInputTimezoneIsInvalid() { - $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('this_timezone_does_not_exist'); - $this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs(['this_timezone_does_not_exist'])->getMock(); + $this->getMockBuilder(\Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer::class)->setConstructorArgs(['this_timezone_does_not_exist'])->getMock(); } public function testConstructFailsIfOutputTimezoneIsInvalid() { - $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('that_timezone_does_not_exist'); - $this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs([null, 'that_timezone_does_not_exist'])->getMock(); + $this->getMockBuilder(\Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer::class)->setConstructorArgs([null, 'that_timezone_does_not_exist'])->getMock(); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php index e9f9ea6bdc..0252f42259 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php @@ -47,13 +47,13 @@ class BooleanToStringTransformerTest extends TestCase public function testTransformFailsIfString() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->transformer->transform('1'); } public function testReverseTransformFailsIfInteger() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->transformer->reverseTransform(1); } @@ -75,7 +75,7 @@ class BooleanToStringTransformerTest extends TestCase public function testTrueValueContainedInFalseValues() { - $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); new BooleanToStringTransformer('0', [null, '0']); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php index 8d812ab371..65089b0fef 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php @@ -91,7 +91,7 @@ class ChoiceToValueTransformerTest extends TestCase */ public function testReverseTransformExpectsStringOrNull($value) { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->transformer->reverseTransform($value); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php index 40a242ff8e..a330273cad 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php @@ -55,7 +55,7 @@ class ChoicesToValuesTransformerTest extends TestCase public function testTransformExpectsArray() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->transformer->transform('foobar'); } @@ -81,7 +81,7 @@ class ChoicesToValuesTransformerTest extends TestCase public function testReverseTransformExpectsArray() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->transformer->reverseTransform('foobar'); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php index 2c685a4197..f8038b0c20 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php @@ -18,12 +18,12 @@ class DataTransformerChainTest extends TestCase { public function testTransform() { - $transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); + $transformer1 = $this->getMockBuilder(\Symfony\Component\Form\DataTransformerInterface::class)->getMock(); $transformer1->expects($this->once()) ->method('transform') ->with($this->identicalTo('foo')) ->willReturn('bar'); - $transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); + $transformer2 = $this->getMockBuilder(\Symfony\Component\Form\DataTransformerInterface::class)->getMock(); $transformer2->expects($this->once()) ->method('transform') ->with($this->identicalTo('bar')) @@ -36,12 +36,12 @@ class DataTransformerChainTest extends TestCase public function testReverseTransform() { - $transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); + $transformer2 = $this->getMockBuilder(\Symfony\Component\Form\DataTransformerInterface::class)->getMock(); $transformer2->expects($this->once()) ->method('reverseTransform') ->with($this->identicalTo('foo')) ->willReturn('bar'); - $transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); + $transformer1 = $this->getMockBuilder(\Symfony\Component\Form\DataTransformerInterface::class)->getMock(); $transformer1->expects($this->once()) ->method('reverseTransform') ->with($this->identicalTo('bar')) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php index c8b6549778..d73c7b99be 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php @@ -54,7 +54,7 @@ class DateTimeImmutableToDateTimeTransformerTest extends TestCase public function testTransformFail() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('Expected a \DateTimeImmutable.'); $transformer = new DateTimeImmutableToDateTimeTransformer(); $transformer->transform(new \DateTime()); @@ -82,7 +82,7 @@ class DateTimeImmutableToDateTimeTransformerTest extends TestCase public function testReverseTransformFail() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('Expected a \DateTime.'); $transformer = new DateTimeImmutableToDateTimeTransformer(); $transformer->reverseTransform(new \DateTimeImmutable()); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php index 92b01dd29b..0a8b17ae9e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php @@ -139,7 +139,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testTransformRequiresDateTime() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform('12345'); } @@ -211,7 +211,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformPartiallyEmptyYear() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'month' => '2', @@ -224,7 +224,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformPartiallyEmptyMonth() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -237,7 +237,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformPartiallyEmptyDay() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -250,7 +250,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformPartiallyEmptyHour() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -263,7 +263,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformPartiallyEmptyMinute() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -276,7 +276,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformPartiallyEmptySecond() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -334,14 +334,14 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformRequiresArray() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform('12345'); } public function testReverseTransformWithNegativeYear() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '-1', @@ -355,7 +355,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithNegativeMonth() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -369,7 +369,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithNegativeDay() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -383,7 +383,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithNegativeHour() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -397,7 +397,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithNegativeMinute() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -411,7 +411,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithNegativeSecond() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -425,7 +425,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithInvalidMonth() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -439,7 +439,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithInvalidDay() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -453,7 +453,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithStringDay() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -467,7 +467,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithStringMonth() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -481,7 +481,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithStringYear() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => 'bazinga', @@ -495,7 +495,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithEmptyStringHour() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -509,7 +509,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithEmptyStringMinute() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', @@ -523,7 +523,7 @@ class DateTimeToArrayTransformerTest extends TestCase public function testReverseTransformWithEmptyStringSecond() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToArrayTransformer(); $transformer->reverseTransform([ 'year' => '2010', diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php index aef3e68829..97bda01756 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php @@ -73,7 +73,7 @@ class DateTimeToHtml5LocalDateTimeTransformerTest extends TestCase public function testTransformRequiresValidDateTime() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToHtml5LocalDateTimeTransformer(); $transformer->transform('2010-01-01'); } @@ -94,14 +94,14 @@ class DateTimeToHtml5LocalDateTimeTransformerTest extends TestCase public function testReverseTransformRequiresString() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToHtml5LocalDateTimeTransformer(); $transformer->reverseTransform(12345); } public function testReverseTransformWithNonExistingDate() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToHtml5LocalDateTimeTransformer('UTC', 'UTC'); $transformer->reverseTransform('2010-04-31T04:05'); @@ -109,7 +109,7 @@ class DateTimeToHtml5LocalDateTimeTransformerTest extends TestCase public function testReverseTransformExpectsValidDateString() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToHtml5LocalDateTimeTransformer('UTC', 'UTC'); $transformer->reverseTransform('2010-2010-2010'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index ae23428a43..68518baf95 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -180,7 +180,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase public function testTransformRequiresValidDateTime() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer(); $transformer->transform('2010-01-01'); } @@ -193,7 +193,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase // HOW TO REPRODUCE? - //$this->expectException('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException'); + //$this->expectException(\Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException::class); //$transformer->transform(1.5); } @@ -288,21 +288,21 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase public function testReverseTransformRequiresString() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer(); $transformer->reverseTransform(12345); } public function testReverseTransformWrapsIntlErrors() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer(); $transformer->reverseTransform('12345'); } public function testReverseTransformWithNonExistingDate() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::SHORT); $this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05')); @@ -310,21 +310,21 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase public function testReverseTransformOutOfTimestampRange() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC'); $transformer->reverseTransform('1789-07-14'); } public function testReverseTransformFiveDigitYears() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, null, \IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd'); $transformer->reverseTransform('20107-03-21'); } public function testReverseTransformFiveDigitYearsWithTimestamp() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, null, \IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd HH:mm:ss'); $transformer->reverseTransform('20107-03-21 12:34:56'); } @@ -337,7 +337,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase $this->iniSet('intl.error_level', \E_WARNING); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer(); $transformer->reverseTransform('12345'); } @@ -350,7 +350,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase $this->iniSet('intl.use_exceptions', 1); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer(); $transformer->reverseTransform('12345'); } @@ -364,7 +364,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase $this->iniSet('intl.use_exceptions', 1); $this->iniSet('intl.error_level', \E_WARNING); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToLocalizedStringTransformer(); $transformer->reverseTransform('12345'); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php index e2944a9370..d34e52ab38 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php @@ -86,7 +86,7 @@ class DateTimeToRfc3339TransformerTest extends TestCase public function testTransformRequiresValidDateTime() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToRfc3339Transformer(); $transformer->transform('2010-01-01'); } @@ -107,14 +107,14 @@ class DateTimeToRfc3339TransformerTest extends TestCase public function testReverseTransformRequiresString() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToRfc3339Transformer(); $transformer->reverseTransform(12345); } public function testReverseTransformWithNonExistingDate() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC'); $transformer->reverseTransform('2010-04-31T04:05Z'); @@ -125,7 +125,7 @@ class DateTimeToRfc3339TransformerTest extends TestCase */ public function testReverseTransformExpectsValidDateString($date) { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC'); $transformer->reverseTransform($date); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index 939c61847f..ffd92d31f3 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -111,7 +111,7 @@ class DateTimeToStringTransformerTest extends TestCase { $transformer = new DateTimeToStringTransformer(); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer->transform('1234'); } @@ -150,7 +150,7 @@ class DateTimeToStringTransformerTest extends TestCase { $reverseTransformer = new DateTimeToStringTransformer(); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $reverseTransformer->reverseTransform(1234); } @@ -159,7 +159,7 @@ class DateTimeToStringTransformerTest extends TestCase { $reverseTransformer = new DateTimeToStringTransformer(); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $reverseTransformer->reverseTransform('2010-2010-2010'); } @@ -168,7 +168,7 @@ class DateTimeToStringTransformerTest extends TestCase { $reverseTransformer = new DateTimeToStringTransformer(); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $reverseTransformer->reverseTransform('2010-04-31'); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php index 4462108cf8..0f5ff2fb7a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php @@ -72,7 +72,7 @@ class DateTimeToTimestampTransformerTest extends TestCase { $transformer = new DateTimeToTimestampTransformer(); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer->transform('1234'); } @@ -109,7 +109,7 @@ class DateTimeToTimestampTransformerTest extends TestCase { $reverseTransformer = new DateTimeToTimestampTransformer(); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $reverseTransformer->reverseTransform('2010-2010-2010'); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeZoneToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeZoneToStringTransformerTest.php index 20897c7170..ed1df8717c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeZoneToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeZoneToStringTransformerTest.php @@ -40,13 +40,13 @@ class DateTimeZoneToStringTransformerTest extends TestCase public function testInvalidTimezone() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); (new DateTimeZoneToStringTransformer())->transform(1); } public function testUnknownTimezone() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); (new DateTimeZoneToStringTransformer(true))->reverseTransform(['Foo/Bar']); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php index eacf1d971b..a137599757 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php @@ -232,7 +232,7 @@ class IntegerToLocalizedStringTransformerTest extends TestCase public function testReverseTransformExpectsString() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new IntegerToLocalizedStringTransformer(); $transformer->reverseTransform(1); @@ -240,7 +240,7 @@ class IntegerToLocalizedStringTransformerTest extends TestCase public function testReverseTransformExpectsValidNumber() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new IntegerToLocalizedStringTransformer(); $transformer->reverseTransform('foo'); @@ -251,7 +251,7 @@ class IntegerToLocalizedStringTransformerTest extends TestCase */ public function testReverseTransformExpectsInteger($number, $locale) { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); IntlTestHelper::requireFullIntl($this, false); \Locale::setDefault($locale); @@ -271,7 +271,7 @@ class IntegerToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsNaN() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new IntegerToLocalizedStringTransformer(); $transformer->reverseTransform('NaN'); @@ -279,7 +279,7 @@ class IntegerToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsNaN2() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new IntegerToLocalizedStringTransformer(); $transformer->reverseTransform('nan'); @@ -287,7 +287,7 @@ class IntegerToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsInfinity() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new IntegerToLocalizedStringTransformer(); $transformer->reverseTransform('∞'); @@ -295,7 +295,7 @@ class IntegerToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsNegativeInfinity() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new IntegerToLocalizedStringTransformer(); $transformer->reverseTransform('-∞'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformerTest.php index 44f6ae02ae..464c266e7b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformerTest.php @@ -43,13 +43,13 @@ class IntlTimeZoneToStringTransformerTest extends TestCase public function testInvalidTimezone() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); (new IntlTimeZoneToStringTransformer())->transform(1); } public function testUnknownTimezone() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); (new IntlTimeZoneToStringTransformer(true))->reverseTransform(['Foo/Bar']); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php index 5e6068a44f..489f8457b8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php @@ -45,7 +45,7 @@ class MoneyToLocalizedStringTransformerTest extends TestCase { $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer->transform('abcd'); } @@ -73,7 +73,7 @@ class MoneyToLocalizedStringTransformerTest extends TestCase { $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer->reverseTransform(12345); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index e838e8b7b9..e776ea34eb 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -399,7 +399,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); // Since we test against "de_DE", we need the full implementation IntlTestHelper::requireFullIntl($this, '4.8.1.1'); @@ -412,7 +412,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); // Since we test against "de_DE", we need the full implementation IntlTestHelper::requireFullIntl($this, '4.8.1.1'); @@ -454,7 +454,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); IntlTestHelper::requireFullIntl($this, '4.8.1.1'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -464,7 +464,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); IntlTestHelper::requireFullIntl($this, '4.8.1.1'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -482,7 +482,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testTransformExpectsNumeric() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new NumberToLocalizedStringTransformer(); $transformer->transform('foo'); @@ -490,7 +490,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformExpectsString() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new NumberToLocalizedStringTransformer(); $transformer->reverseTransform(1); @@ -498,7 +498,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformExpectsValidNumber() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new NumberToLocalizedStringTransformer(); $transformer->reverseTransform('foo'); @@ -511,7 +511,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase */ public function testReverseTransformDisallowsNaN($nan) { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new NumberToLocalizedStringTransformer(); $transformer->reverseTransform($nan); @@ -528,7 +528,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsInfinity() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new NumberToLocalizedStringTransformer(); $transformer->reverseTransform('∞'); @@ -536,7 +536,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsInfinity2() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new NumberToLocalizedStringTransformer(); $transformer->reverseTransform('∞,123'); @@ -544,7 +544,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsNegativeInfinity() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new NumberToLocalizedStringTransformer(); $transformer->reverseTransform('-∞'); @@ -552,7 +552,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsLeadingExtraCharacters() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new NumberToLocalizedStringTransformer(); $transformer->reverseTransform('foo123'); @@ -560,7 +560,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsCenteredExtraCharacters() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('The number contains unrecognized characters: "foo3"'); $transformer = new NumberToLocalizedStringTransformer(); @@ -569,7 +569,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('The number contains unrecognized characters: "foo8"'); // Since we test against other locales, we need the full implementation IntlTestHelper::requireFullIntl($this, false); @@ -583,7 +583,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('The number contains unrecognized characters: "foo8"'); // Since we test against other locales, we need the full implementation IntlTestHelper::requireFullIntl($this, false); @@ -597,7 +597,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsTrailingExtraCharacters() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('The number contains unrecognized characters: "foo"'); $transformer = new NumberToLocalizedStringTransformer(); @@ -606,7 +606,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('The number contains unrecognized characters: "foo"'); // Since we test against other locales, we need the full implementation IntlTestHelper::requireFullIntl($this, false); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php index f0fe4392cf..af487827a1 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php @@ -112,7 +112,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase { $transformer = new PercentToLocalizedStringTransformer(); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer->transform('foo'); } @@ -121,7 +121,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase { $transformer = new PercentToLocalizedStringTransformer(); - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer->reverseTransform(1); } @@ -144,7 +144,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); // Since we test against "de_DE", we need the full implementation IntlTestHelper::requireFullIntl($this, '4.8.1.1'); @@ -157,7 +157,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); // Since we test against "de_DE", we need the full implementation IntlTestHelper::requireFullIntl($this, '4.8.1.1'); @@ -199,7 +199,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); IntlTestHelper::requireFullIntl($this, '4.8.1.1'); $transformer = new PercentToLocalizedStringTransformer(1, 'integer'); @@ -209,7 +209,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); IntlTestHelper::requireFullIntl($this, '4.8.1.1'); $transformer = new PercentToLocalizedStringTransformer(1, 'integer'); @@ -223,7 +223,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, 1); $formatter->setAttribute(\NumberFormatter::GROUPING_USED, false); - $transformer = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer') + $transformer = $this->getMockBuilder(PercentToLocalizedStringTransformer::class) ->setMethods(['getNumberFormatter']) ->setConstructorArgs([1, 'integer']) ->getMock(); @@ -237,7 +237,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsLeadingExtraCharacters() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new PercentToLocalizedStringTransformer(); $transformer->reverseTransform('foo123'); @@ -245,7 +245,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsCenteredExtraCharacters() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('The number contains unrecognized characters: "foo3"'); $transformer = new PercentToLocalizedStringTransformer(); @@ -257,7 +257,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase */ public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('The number contains unrecognized characters: "foo8"'); // Since we test against other locales, we need the full implementation IntlTestHelper::requireFullIntl($this, false); @@ -271,7 +271,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase public function testReverseTransformDisallowsTrailingExtraCharacters() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('The number contains unrecognized characters: "foo"'); $transformer = new PercentToLocalizedStringTransformer(); @@ -283,7 +283,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase */ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectExceptionMessage('The number contains unrecognized characters: "foo"'); // Since we test against other locales, we need the full implementation IntlTestHelper::requireFullIntl($this, false); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php index 3de0383c07..ee4e4f8a65 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php @@ -39,14 +39,14 @@ class StringToFloatTransformerTest extends TestCase public function testFailIfTransformingANonString() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new StringToFloatTransformer(); $transformer->transform(1.0); } public function testFailIfTransformingANonNumericString() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new StringToFloatTransformer(); $transformer->transform('foobar'); } @@ -79,7 +79,7 @@ class StringToFloatTransformerTest extends TestCase public function testFailIfReverseTransformingANonNumeric() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $transformer = new StringToFloatTransformer(); $transformer->reverseTransform('foobar'); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php index ec19ddf92f..b723a857e5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php @@ -107,7 +107,7 @@ class ValueToDuplicatesTransformerTest extends TestCase public function testReverseTransformPartiallyNull() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $input = [ 'a' => 'Foo', 'b' => 'Foo', @@ -119,7 +119,7 @@ class ValueToDuplicatesTransformerTest extends TestCase public function testReverseTransformDifferences() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $input = [ 'a' => 'Foo', 'b' => 'Bar', @@ -131,7 +131,7 @@ class ValueToDuplicatesTransformerTest extends TestCase public function testReverseTransformRequiresArray() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->transformer->reverseTransform('12345'); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php index bf7b5c0070..98a93d196a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php @@ -185,7 +185,7 @@ abstract class MergeCollectionListenerTest extends TestCase */ public function testRequireArrayOrTraversable($allowAdd, $allowDelete) { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $newData = 'no array or traversable'; $event = new FormEvent($this->form, $newData); $listener = new MergeCollectionListener($allowAdd, $allowDelete); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php index 3411fdb7d5..b33038bcd8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php @@ -68,7 +68,7 @@ class ResizeFormListenerTest extends TestCase public function testPreSetDataRequiresArrayOrTraversable() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $data = 'no array or traversable'; $event = new FormEvent($this->form, $data); $listener = new ResizeFormListener('text', [], false, false); @@ -201,7 +201,7 @@ class ResizeFormListenerTest extends TestCase public function testOnSubmitNormDataRequiresArrayOrTraversable() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $data = 'no array or traversable'; $event = new FormEvent($this->form, $data); $listener = new ResizeFormListener('text', [], false, false); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php index 3ca4cf07a7..d682a6b1c2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php @@ -20,7 +20,7 @@ class BirthdayTypeTest extends DateTypeTest public function testSetInvalidYearsOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'years' => 'bad value', ]); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php index ed1957c7c9..6479333875 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php @@ -20,7 +20,7 @@ class ButtonTypeTest extends BaseTypeTest public function testCreateButtonInstances() { - $this->assertInstanceOf('Symfony\Component\Form\Button', $this->factory->create(static::TESTED_TYPE)); + $this->assertInstanceOf(\Symfony\Component\Form\Button::class, $this->factory->create(static::TESTED_TYPE)); } /** @@ -29,7 +29,7 @@ class ButtonTypeTest extends BaseTypeTest */ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'empty', $expectedData = null) { - $this->expectException('Symfony\Component\Form\Exception\BadMethodCallException'); + $this->expectException(\Symfony\Component\Form\Exception\BadMethodCallException::class); $this->expectExceptionMessage('Buttons do not support empty data.'); parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php index 6f872bbd73..c8c03db043 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php @@ -196,7 +196,7 @@ class CheckboxTypeTest extends BaseTypeTest public function testDontAllowNonArrayFalseValues() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->expectExceptionMessageMatches('/"false_values" with value "invalid" is expected to be of type "array"/'); $this->factory->create(static::TESTED_TYPE, null, [ 'false_values' => 'invalid', 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 c7d40ed2e1..c07722c9e3 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -82,7 +82,7 @@ class ChoiceTypeTest extends BaseTypeTest public function testChoicesOptionExpectsArrayOrTraversable() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'choices' => new \stdClass(), ]); @@ -90,7 +90,7 @@ class ChoiceTypeTest extends BaseTypeTest public function testChoiceLoaderOptionExpectsChoiceLoaderInterface() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'choice_loader' => new \stdClass(), ]); @@ -98,7 +98,7 @@ class ChoiceTypeTest extends BaseTypeTest public function testChoiceListAndChoicesCanBeEmpty() { - $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->create(static::TESTED_TYPE, null, [])); + $this->assertInstanceOf(\Symfony\Component\Form\FormInterface::class, $this->factory->create(static::TESTED_TYPE, null, [])); } public function testExpandedChoicesOptionsTurnIntoChildren() @@ -1802,7 +1802,7 @@ class ChoiceTypeTest extends BaseTypeTest // https://github.com/symfony/symfony/issues/3298 public function testInitializeWithEmptyChoices() { - $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->createNamed('name', static::TESTED_TYPE, null, [ + $this->assertInstanceOf(\Symfony\Component\Form\FormInterface::class, $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'choices' => [], ])); } 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 6f0510c08b..1a56dd0474 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -37,8 +37,8 @@ class CollectionTypeTest extends BaseTypeTest ]); $form->setData(['foo@foo.com', 'foo@bar.com']); - $this->assertInstanceOf('Symfony\Component\Form\Form', $form[0]); - $this->assertInstanceOf('Symfony\Component\Form\Form', $form[1]); + $this->assertInstanceOf(\Symfony\Component\Form\Form::class, $form[0]); + $this->assertInstanceOf(\Symfony\Component\Form\Form::class, $form[1]); $this->assertCount(2, $form); $this->assertEquals('foo@foo.com', $form[0]->getData()); $this->assertEquals('foo@bar.com', $form[1]->getData()); @@ -48,7 +48,7 @@ class CollectionTypeTest extends BaseTypeTest $this->assertEquals(20, $formAttrs1['maxlength']); $form->setData(['foo@baz.com']); - $this->assertInstanceOf('Symfony\Component\Form\Form', $form[0]); + $this->assertInstanceOf(\Symfony\Component\Form\Form::class, $form[0]); $this->assertArrayNotHasKey(1, $form); $this->assertCount(1, $form); $this->assertEquals('foo@baz.com', $form[0]->getData()); @@ -61,7 +61,7 @@ class CollectionTypeTest extends BaseTypeTest $form = $this->factory->create(static::TESTED_TYPE, null, [ 'entry_type' => TextTypeTest::TESTED_TYPE, ]); - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $form->setData(new \stdClass()); } 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 934886b1df..506ec11f78 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -322,7 +322,7 @@ class DateTimeTypeTest extends BaseTypeTest { // Throws an exception if "data_class" option is not explicitly set // to null in the type - $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->create(static::TESTED_TYPE, new \DateTime())); + $this->assertInstanceOf(FormInterface::class, $this->factory->create(static::TESTED_TYPE, new \DateTime())); } public function testSingleTextWidgetShouldUseTheRightInputType() 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 38423e0459..58a42fd603 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -38,7 +38,7 @@ class DateTypeTest extends BaseTypeTest public function testInvalidWidgetOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'widget' => 'fake_widget', ]); @@ -46,7 +46,7 @@ class DateTypeTest extends BaseTypeTest public function testInvalidInputOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'input' => 'fake_input', ]); @@ -373,7 +373,7 @@ class DateTypeTest extends BaseTypeTest */ public function testThrowExceptionIfFormatIsNoPattern() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'format' => '0', 'html5' => false, @@ -384,7 +384,7 @@ class DateTypeTest extends BaseTypeTest public function testThrowExceptionIfFormatDoesNotContainYearMonthAndDay() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->expectExceptionMessage('The "format" option should contain the letters "y", "M" and "d". Its current value is "yy".'); $this->factory->create(static::TESTED_TYPE, null, [ 'months' => [6, 7], @@ -394,7 +394,7 @@ class DateTypeTest extends BaseTypeTest public function testThrowExceptionIfFormatMissesYearMonthAndDayWithSingleTextWidget() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->expectExceptionMessage('The "format" option should contain the letters "y", "M" or "d". Its current value is "wrong".'); $this->factory->create(static::TESTED_TYPE, null, [ 'widget' => 'single_text', @@ -405,7 +405,7 @@ class DateTypeTest extends BaseTypeTest public function testThrowExceptionIfFormatIsNoConstant() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'format' => 105, ]); @@ -413,7 +413,7 @@ class DateTypeTest extends BaseTypeTest public function testThrowExceptionIfFormatIsInvalid() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'format' => [], ]); @@ -421,7 +421,7 @@ class DateTypeTest extends BaseTypeTest public function testThrowExceptionIfYearsIsInvalid() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'years' => 'bad value', ]); @@ -429,7 +429,7 @@ class DateTypeTest extends BaseTypeTest public function testThrowExceptionIfMonthsIsInvalid() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'months' => 'bad value', ]); @@ -437,7 +437,7 @@ class DateTypeTest extends BaseTypeTest public function testThrowExceptionIfDaysIsInvalid() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'days' => 'bad value', ]); @@ -733,7 +733,7 @@ class DateTypeTest extends BaseTypeTest { // Throws an exception if "data_class" option is not explicitly set // to null in the type - $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->create(static::TESTED_TYPE, new \DateTime())); + $this->assertInstanceOf(FormInterface::class, $this->factory->create(static::TESTED_TYPE, new \DateTime())); } public function testSingleTextWidgetShouldUseTheRightInputType() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php index 9a005d57c5..0e737721e9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php @@ -63,7 +63,7 @@ class FormTypeTest extends BaseTypeTest public function testCreateFormInstances() { - $this->assertInstanceOf('Symfony\Component\Form\Form', $this->factory->create(static::TESTED_TYPE)); + $this->assertInstanceOf(\Symfony\Component\Form\Form::class, $this->factory->create(static::TESTED_TYPE)); } public function testPassRequiredAsOption() @@ -149,28 +149,28 @@ class FormTypeTest extends BaseTypeTest public function testDataClassMayBeNull() { - $this->assertInstanceOf('Symfony\Component\Form\FormBuilderInterface', $this->factory->createBuilder(static::TESTED_TYPE, null, [ + $this->assertInstanceOf(\Symfony\Component\Form\FormBuilderInterface::class, $this->factory->createBuilder(static::TESTED_TYPE, null, [ 'data_class' => null, ])); } public function testDataClassMayBeAbstractClass() { - $this->assertInstanceOf('Symfony\Component\Form\FormBuilderInterface', $this->factory->createBuilder(static::TESTED_TYPE, null, [ + $this->assertInstanceOf(\Symfony\Component\Form\FormBuilderInterface::class, $this->factory->createBuilder(static::TESTED_TYPE, null, [ 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AbstractAuthor', ])); } public function testDataClassMayBeInterface() { - $this->assertInstanceOf('Symfony\Component\Form\FormBuilderInterface', $this->factory->createBuilder(static::TESTED_TYPE, null, [ + $this->assertInstanceOf(\Symfony\Component\Form\FormBuilderInterface::class, $this->factory->createBuilder(static::TESTED_TYPE, null, [ 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AuthorInterface', ])); } public function testDataClassMustBeValidClassOrInterface() { - $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); $this->factory->createBuilder(static::TESTED_TYPE, null, [ 'data_class' => 'foobar', ]); @@ -337,7 +337,7 @@ class FormTypeTest extends BaseTypeTest public function testAttributesException() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, ['attr' => '']); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php index c31d732888..7ea85586fa 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php @@ -200,7 +200,7 @@ class NumberTypeTest extends BaseTypeTest public function testGroupingNotAllowedWithHtml5Widget() { - $this->expectException('Symfony\Component\Form\Exception\LogicException'); + $this->expectException(\Symfony\Component\Form\Exception\LogicException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'grouping' => true, 'html5' => true, diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php index 04e53697ae..d4233aa58d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php @@ -116,7 +116,7 @@ class RepeatedTypeTest extends BaseTypeTest public function testSetInvalidOptions() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'type' => TextTypeTest::TESTED_TYPE, 'options' => 'bad value', @@ -125,7 +125,7 @@ class RepeatedTypeTest extends BaseTypeTest public function testSetInvalidFirstOptions() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'type' => TextTypeTest::TESTED_TYPE, 'first_options' => 'bad value', @@ -134,7 +134,7 @@ class RepeatedTypeTest extends BaseTypeTest public function testSetInvalidSecondOptions() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'type' => TextTypeTest::TESTED_TYPE, 'second_options' => 'bad value', diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php index 5b12ced9f2..fdabed0d0d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php @@ -20,7 +20,7 @@ class SubmitTypeTest extends ButtonTypeTest public function testCreateSubmitButtonInstances() { - $this->assertInstanceOf('Symfony\Component\Form\SubmitButton', $this->factory->create(static::TESTED_TYPE)); + $this->assertInstanceOf(\Symfony\Component\Form\SubmitButton::class, $this->factory->create(static::TESTED_TYPE)); } public function testNotClickedByDefault() 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 433a7456ae..4607738670 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -661,7 +661,7 @@ class TimeTypeTest extends BaseTypeTest { // Throws an exception if "data_class" option is not explicitly set // to null in the type - $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->create(static::TESTED_TYPE, new \DateTime())); + $this->assertInstanceOf(FormInterface::class, $this->factory->create(static::TESTED_TYPE, new \DateTime())); } public function testSingleTextWidgetShouldUseTheRightInputType() @@ -858,7 +858,7 @@ class TimeTypeTest extends BaseTypeTest public function testInitializeWithSecondsAndWithoutMinutes() { - $this->expectException('Symfony\Component\Form\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidConfigurationException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'with_minutes' => false, 'with_seconds' => true, @@ -867,7 +867,7 @@ class TimeTypeTest extends BaseTypeTest public function testThrowExceptionIfHoursIsInvalid() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'hours' => 'bad value', ]); @@ -875,7 +875,7 @@ class TimeTypeTest extends BaseTypeTest public function testThrowExceptionIfMinutesIsInvalid() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'minutes' => 'bad value', ]); @@ -883,7 +883,7 @@ class TimeTypeTest extends BaseTypeTest public function testThrowExceptionIfSecondsIsInvalid() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'seconds' => 'bad value', ]); @@ -891,7 +891,7 @@ class TimeTypeTest extends BaseTypeTest public function testReferenceDateTimezoneMustMatchModelTimezone() { - $this->expectException('Symfony\Component\Form\Exception\InvalidConfigurationException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidConfigurationException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'model_timezone' => 'UTC', 'view_timezone' => 'Europe/Berlin', diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php index c7dc10f05b..50e7a045c2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php @@ -90,7 +90,7 @@ class TimezoneTypeTest extends BaseTypeTest */ public function testFilterByRegionsWithIntl() { - $this->expectException('Symfony\Component\Form\Exception\LogicException'); + $this->expectException(\Symfony\Component\Form\Exception\LogicException::class); $this->expectExceptionMessage('The "regions" option can only be used if the "intl" option is set to false.'); $this->factory->create(static::TESTED_TYPE, null, ['regions' => \DateTimeZone::EUROPE, 'intl' => true]); } @@ -192,7 +192,7 @@ class TimezoneTypeTest extends BaseTypeTest public function testChoiceTranslationLocaleOptionWithoutIntl() { - $this->expectException('Symfony\Component\Form\Exception\LogicException'); + $this->expectException(\Symfony\Component\Form\Exception\LogicException::class); $this->expectExceptionMessage('The "choice_translation_locale" option can only be used if the "intl" option is set to true.'); $this->factory->create(static::TESTED_TYPE, null, [ 'choice_translation_locale' => 'uk', diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php index 5a829c95bb..efcda84261 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php @@ -75,7 +75,7 @@ class UrlTypeTest extends TextTypeTest public function testThrowExceptionIfDefaultProtocolIsInvalid() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->factory->create(static::TESTED_TYPE, null, [ 'default_protocol' => [], ]); diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php index 313827ef46..c5a5fe1003 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php @@ -29,7 +29,7 @@ class DataCollectorExtensionTest extends TestCase protected function setUp(): void { - $this->dataCollector = $this->getMockBuilder('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface')->getMock(); + $this->dataCollector = $this->getMockBuilder(\Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface::class)->getMock(); $this->extension = new DataCollectorExtension($this->dataCollector); } @@ -39,6 +39,6 @@ class DataCollectorExtensionTest extends TestCase $this->assertIsArray($typeExtensions); $this->assertCount(1, $typeExtensions); - $this->assertInstanceOf('Symfony\Component\Form\Extension\DataCollector\Type\DataCollectorTypeExtension', array_shift($typeExtensions)); + $this->assertInstanceOf(\Symfony\Component\Form\Extension\DataCollector\Type\DataCollectorTypeExtension::class, array_shift($typeExtensions)); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php index 4cf38c4132..7d8c952ae0 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php @@ -77,7 +77,7 @@ class FormDataCollectorTest extends TestCase protected function setUp(): void { - $this->dataExtractor = $this->getMockBuilder('Symfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface')->getMock(); + $this->dataExtractor = $this->getMockBuilder(\Symfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface::class)->getMock(); $this->dataCollector = new FormDataCollector($this->dataExtractor); $this->dispatcher = new EventDispatcher(); $this->factory = new FormFactory(new FormRegistry([new CoreExtension()], new ResolvedFormTypeFactory())); diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php index efef29a7ba..cda0bd24da 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php @@ -49,13 +49,13 @@ class FormDataExtractorTest extends TestCase protected function setUp(): void { $this->dataExtractor = new FormDataExtractor(); - $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); + $this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(); } public function testExtractConfiguration() { - $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); $type->expects($this->any()) ->method('getInnerType') ->willReturn(new HiddenType()); @@ -76,7 +76,7 @@ class FormDataExtractorTest extends TestCase public function testExtractConfigurationSortsPassedOptions() { - $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); $type->expects($this->any()) ->method('getInnerType') ->willReturn(new HiddenType()); @@ -110,7 +110,7 @@ class FormDataExtractorTest extends TestCase public function testExtractConfigurationSortsResolvedOptions() { - $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); $type->expects($this->any()) ->method('getInnerType') ->willReturn(new HiddenType()); @@ -141,18 +141,18 @@ class FormDataExtractorTest extends TestCase public function testExtractConfigurationBuildsIdRecursively() { - $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); $type->expects($this->any()) ->method('getInnerType') ->willReturn(new HiddenType()); $grandParent = $this->createBuilder('grandParent') ->setCompound(true) - ->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock()) + ->setDataMapper($this->getMockBuilder(\Symfony\Component\Form\DataMapperInterface::class)->getMock()) ->getForm(); $parent = $this->createBuilder('parent') ->setCompound(true) - ->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock()) + ->setDataMapper($this->getMockBuilder(\Symfony\Component\Form\DataMapperInterface::class)->getMock()) ->getForm(); $form = $this->createBuilder('name') ->setType($type) diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php index 97b89849d1..69c40605c9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php @@ -29,7 +29,7 @@ class DataCollectorTypeExtensionTest extends TestCase protected function setUp(): void { - $this->dataCollector = $this->getMockBuilder('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface')->getMock(); + $this->dataCollector = $this->getMockBuilder(\Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface::class)->getMock(); $this->extension = new DataCollectorTypeExtension($this->dataCollector); } @@ -43,10 +43,10 @@ class DataCollectorTypeExtensionTest extends TestCase public function testBuildForm() { - $builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock(); + $builder = $this->getMockBuilder(\Symfony\Component\Form\Test\FormBuilderInterface::class)->getMock(); $builder->expects($this->atLeastOnce()) ->method('addEventSubscriber') - ->with($this->isInstanceOf('Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener')); + ->with($this->isInstanceOf(\Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener::class)); $this->extension->buildForm($builder, []); } diff --git a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php index 26db2d8cea..157ebe3390 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php @@ -43,7 +43,7 @@ class DependencyInjectionExtensionTest extends TestCase public function testThrowExceptionForInvalidExtendedType() { - $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); $this->expectExceptionMessage(sprintf('The extended type "unmatched" specified for the type extension class "%s" does not match any of the actual extended types (["test"]).', TestTypeExtension::class)); $extensions = [ diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php index 771cdcd6fc..d2bdedaeeb 100644 --- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php @@ -23,13 +23,13 @@ class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest { public function testRequestShouldNotBeNull() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $this->requestHandler->handleRequest($this->createForm('name', 'GET')); } public function testRequestShouldBeInstanceOfRequest() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $this->requestHandler->handleRequest($this->createForm('name', 'GET'), new \stdClass()); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php index 81baf3dc8f..7062ed53d3 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php @@ -78,7 +78,7 @@ abstract class BaseValidatorExtensionTest extends TypeTestCase 'validation_groups' => new GroupSequence(['group1', 'group2']), ]); - $this->assertInstanceOf('Symfony\Component\Validator\Constraints\GroupSequence', $form->getConfig()->getOption('validation_groups')); + $this->assertInstanceOf(GroupSequence::class, $form->getConfig()->getOption('validation_groups')); } abstract protected function createForm(array $options = []); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php index 10cc93d8f3..f6ac355176 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php @@ -134,7 +134,7 @@ class ValidatorTypeGuesserTest extends TestCase $constraint = new Length(['max' => '2']); $result = $this->guesser->guessMaxLengthForConstraint($constraint); - $this->assertInstanceOf('Symfony\Component\Form\Guess\ValueGuess', $result); + $this->assertInstanceOf(ValueGuess::class, $result); $this->assertEquals(2, $result->getValue()); $this->assertEquals(Guess::HIGH_CONFIDENCE, $result->getConfidence()); } @@ -154,7 +154,7 @@ class ValidatorTypeGuesserTest extends TestCase $mimeTypes = ['image/png', 'image/jpeg']; $constraint = new File(['mimeTypes' => $mimeTypes]); $typeGuess = $this->guesser->guessTypeForConstraint($constraint); - $this->assertInstanceOf('Symfony\Component\Form\Guess\TypeGuess', $typeGuess); + $this->assertInstanceOf(TypeGuess::class, $typeGuess); $this->assertArrayHasKey('attr', $typeGuess->getOptions()); $this->assertArrayHasKey('accept', $typeGuess->getOptions()['attr']); $this->assertEquals(implode(',', $mimeTypes), $typeGuess->getOptions()['attr']['accept']); @@ -164,7 +164,7 @@ class ValidatorTypeGuesserTest extends TestCase { $constraint = new File(); $typeGuess = $this->guesser->guessTypeForConstraint($constraint); - $this->assertInstanceOf('Symfony\Component\Form\Guess\TypeGuess', $typeGuess); + $this->assertInstanceOf(TypeGuess::class, $typeGuess); $this->assertArrayNotHasKey('attr', $typeGuess->getOptions()); } @@ -172,7 +172,7 @@ class ValidatorTypeGuesserTest extends TestCase { $constraint = new File(['mimeTypes' => 'image/*']); $typeGuess = $this->guesser->guessTypeForConstraint($constraint); - $this->assertInstanceOf('Symfony\Component\Form\Guess\TypeGuess', $typeGuess); + $this->assertInstanceOf(TypeGuess::class, $typeGuess); $this->assertArrayHasKey('attr', $typeGuess->getOptions()); $this->assertArrayHasKey('accept', $typeGuess->getOptions()['attr']); $this->assertEquals('image/*', $typeGuess->getOptions()['attr']['accept']); @@ -182,7 +182,7 @@ class ValidatorTypeGuesserTest extends TestCase { $constraint = new File(['mimeTypes' => '']); $typeGuess = $this->guesser->guessTypeForConstraint($constraint); - $this->assertInstanceOf('Symfony\Component\Form\Guess\TypeGuess', $typeGuess); + $this->assertInstanceOf(TypeGuess::class, $typeGuess); $this->assertArrayNotHasKey('attr', $typeGuess->getOptions()); } @@ -204,7 +204,7 @@ class ValidatorTypeGuesserTest extends TestCase $constraint = new Type($type); $result = $this->guesser->guessMaxLengthForConstraint($constraint); - $this->assertInstanceOf('Symfony\Component\Form\Guess\ValueGuess', $result); + $this->assertInstanceOf(ValueGuess::class, $result); $this->assertNull($result->getValue()); $this->assertEquals(Guess::MEDIUM_CONFIDENCE, $result->getConfidence()); } 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 02e7523c29..7b9dec34c2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php @@ -142,7 +142,7 @@ class ViolationPathTest extends TestCase public function testGetElementDoesNotAcceptInvalidIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $path = new ViolationPath('children[address].data[street].name'); $path->getElement(3); @@ -150,7 +150,7 @@ class ViolationPathTest extends TestCase public function testGetElementDoesNotAcceptNegativeIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $path = new ViolationPath('children[address].data[street].name'); $path->getElement(-1); @@ -166,7 +166,7 @@ class ViolationPathTest extends TestCase public function testIsPropertyDoesNotAcceptInvalidIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $path = new ViolationPath('children[address].data[street].name'); $path->isProperty(3); @@ -174,7 +174,7 @@ class ViolationPathTest extends TestCase public function testIsPropertyDoesNotAcceptNegativeIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $path = new ViolationPath('children[address].data[street].name'); $path->isProperty(-1); @@ -190,7 +190,7 @@ class ViolationPathTest extends TestCase public function testIsIndexDoesNotAcceptInvalidIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $path = new ViolationPath('children[address].data[street].name'); $path->isIndex(3); @@ -198,7 +198,7 @@ class ViolationPathTest extends TestCase public function testIsIndexDoesNotAcceptNegativeIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $path = new ViolationPath('children[address].data[street].name'); $path->isIndex(-1); @@ -215,7 +215,7 @@ class ViolationPathTest extends TestCase public function testMapsFormDoesNotAcceptInvalidIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $path = new ViolationPath('children[address].data[street].name'); $path->mapsForm(3); @@ -223,7 +223,7 @@ class ViolationPathTest extends TestCase public function testMapsFormDoesNotAcceptNegativeIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $path = new ViolationPath('children[address].data[street].name'); $path->mapsForm(-1); diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index cf5ba94aee..6db3cc1628 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -26,8 +26,8 @@ class FormBuilderTest extends TestCase protected function setUp(): void { - $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + $this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); + $this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(); $this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); } @@ -51,13 +51,13 @@ class FormBuilderTest extends TestCase public function testAddNameNoStringAndNoInteger() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $this->builder->add(true); } public function testAddTypeNoString() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $this->builder->add('foo', 1234); } @@ -139,7 +139,7 @@ class FormBuilderTest extends TestCase $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $this->builder->remove('foo'); $form = $this->builder->getForm(); - $this->assertInstanceOf('Symfony\Component\Form\Form', $form); + $this->assertInstanceOf(\Symfony\Component\Form\Form::class, $form); } public function testCreateNoTypeNo() @@ -162,7 +162,7 @@ class FormBuilderTest extends TestCase public function testGetUnknown() { - $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The child with the name "foo" does not exist.'); $this->builder->get('foo'); @@ -229,7 +229,7 @@ class FormBuilderTest extends TestCase private function getFormBuilder($name = 'name') { - $mock = $this->getMockBuilder('Symfony\Component\Form\FormBuilder') + $mock = $this->getMockBuilder(FormBuilder::class) ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/Form/Tests/FormConfigTest.php b/src/Symfony/Component/Form/Tests/FormConfigTest.php index a8755cae5f..cc943fcda2 100644 --- a/src/Symfony/Component/Form/Tests/FormConfigTest.php +++ b/src/Symfony/Component/Form/Tests/FormConfigTest.php @@ -65,7 +65,7 @@ class FormConfigTest extends TestCase */ public function testNameAcceptsOnlyNamesValidAsIdsInHtml4($name, $expectedException = null) { - $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); if (null !== $expectedException) { $this->expectException($expectedException); @@ -80,7 +80,7 @@ class FormConfigTest extends TestCase { $config = $this->getConfigBuilder()->getFormConfig(); - $this->assertInstanceOf('Symfony\Component\Form\NativeRequestHandler', $config->getRequestHandler()); + $this->assertInstanceOf(\Symfony\Component\Form\NativeRequestHandler::class, $config->getRequestHandler()); } public function testGetRequestHandlerReusesNativeRequestHandlerInstance() @@ -133,7 +133,7 @@ class FormConfigTest extends TestCase private function getConfigBuilder($name = 'name') { - $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); return new FormConfigBuilder($name, null, $dispatcher); } diff --git a/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php b/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php index 4ed30414f3..1d21b074f5 100644 --- a/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php +++ b/src/Symfony/Component/Form/Tests/FormErrorIteratorTest.php @@ -33,7 +33,7 @@ class FormErrorIteratorTest extends TestCase 'form', null, new EventDispatcher(), - $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(), [] ); diff --git a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php index 9a236cc009..22f6c49f2f 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php @@ -23,11 +23,11 @@ class FormFactoryBuilderTest extends TestCase protected function setUp(): void { - $factory = new \ReflectionClass('Symfony\Component\Form\FormFactory'); + $factory = new \ReflectionClass(\Symfony\Component\Form\FormFactory::class); $this->registry = $factory->getProperty('registry'); $this->registry->setAccessible(true); - $this->guesser = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); + $this->guesser = $this->getMockBuilder(\Symfony\Component\Form\FormTypeGuesserInterface::class)->getMock(); $this->type = new FooType(); } diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index 0206aa0f78..e60bacaee6 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -53,10 +53,10 @@ class FormFactoryTest extends TestCase protected function setUp(): void { - $this->guesser1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); - $this->guesser2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); - $this->registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock(); - $this->builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock(); + $this->guesser1 = $this->getMockBuilder(\Symfony\Component\Form\FormTypeGuesserInterface::class)->getMock(); + $this->guesser2 = $this->getMockBuilder(\Symfony\Component\Form\FormTypeGuesserInterface::class)->getMock(); + $this->registry = $this->getMockBuilder(\Symfony\Component\Form\FormRegistryInterface::class)->getMock(); + $this->builder = $this->getMockBuilder(\Symfony\Component\Form\Test\FormBuilderInterface::class)->getMock(); $this->factory = new FormFactory($this->registry); $this->registry->expects($this->any()) @@ -151,14 +151,14 @@ class FormFactoryTest extends TestCase public function testCreateNamedBuilderThrowsUnderstandableException() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $this->expectExceptionMessage('Expected argument of type "string", "stdClass" given'); $this->factory->createNamedBuilder('name', new \stdClass()); } public function testCreateThrowsUnderstandableException() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $this->expectExceptionMessage('Expected argument of type "string", "stdClass" given'); $this->factory->create(new \stdClass()); } @@ -169,7 +169,7 @@ class FormFactoryTest extends TestCase $resolvedOptions = ['a' => '2', 'b' => '3']; // the interface does not have the method, so use the real class - $resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') + $resolvedType = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormType::class) ->disableOriginalConstructor() ->getMock(); @@ -239,8 +239,8 @@ class FormFactoryTest extends TestCase public function testCreateBuilderForPropertyWithoutTypeGuesser() { - $registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock(); - $factory = $this->getMockBuilder('Symfony\Component\Form\FormFactory') + $registry = $this->getMockBuilder(\Symfony\Component\Form\FormRegistryInterface::class)->getMock(); + $factory = $this->getMockBuilder(FormFactory::class) ->setMethods(['createNamedBuilder']) ->setConstructorArgs([$registry]) ->getMock(); @@ -477,7 +477,7 @@ class FormFactoryTest extends TestCase private function getMockFactory(array $methods = []) { - return $this->getMockBuilder('Symfony\Component\Form\FormFactory') + return $this->getMockBuilder(FormFactory::class) ->setMethods($methods) ->setConstructorArgs([$this->registry]) ->getMock(); @@ -485,6 +485,6 @@ class FormFactoryTest extends TestCase private function getMockResolvedType() { - return $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); } } diff --git a/src/Symfony/Component/Form/Tests/FormRegistryTest.php b/src/Symfony/Component/Form/Tests/FormRegistryTest.php index 56bb9ffd35..3b1518f549 100644 --- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php +++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php @@ -65,9 +65,9 @@ class FormRegistryTest extends TestCase protected function setUp(): void { - $this->resolvedTypeFactory = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeFactory')->getMock(); - $this->guesser1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); - $this->guesser2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); + $this->resolvedTypeFactory = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeFactory::class)->getMock(); + $this->guesser1 = $this->getMockBuilder(\Symfony\Component\Form\FormTypeGuesserInterface::class)->getMock(); + $this->guesser2 = $this->getMockBuilder(\Symfony\Component\Form\FormTypeGuesserInterface::class)->getMock(); $this->extension1 = new TestExtension($this->guesser1); $this->extension2 = new TestExtension($this->guesser2); $this->registry = new FormRegistry([ @@ -106,13 +106,13 @@ class FormRegistryTest extends TestCase public function testFailIfUnregisteredTypeNoClass() { - $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); $this->registry->getType('Symfony\Blubb'); } public function testFailIfUnregisteredTypeNoFormType() { - $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); $this->registry->getType('stdClass'); } @@ -158,7 +158,7 @@ class FormRegistryTest extends TestCase public function testFormCannotHaveItselfAsAParent() { - $this->expectException('Symfony\Component\Form\Exception\LogicException'); + $this->expectException(\Symfony\Component\Form\Exception\LogicException::class); $this->expectExceptionMessage('Circular reference detected for form type "Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType" (Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType > Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType).'); $type = new FormWithSameParentType(); @@ -169,7 +169,7 @@ class FormRegistryTest extends TestCase public function testRecursiveFormDependencies() { - $this->expectException('Symfony\Component\Form\Exception\LogicException'); + $this->expectException(\Symfony\Component\Form\Exception\LogicException::class); $this->expectExceptionMessage('Circular reference detected for form type "Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo" (Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo > Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBar > Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBaz > Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo).'); $foo = new RecursiveFormTypeFoo(); $bar = new RecursiveFormTypeBar(); @@ -184,7 +184,7 @@ class FormRegistryTest extends TestCase public function testGetTypeThrowsExceptionIfTypeNotFound() { - $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); $this->registry->getType('bar'); } @@ -230,7 +230,7 @@ class FormRegistryTest extends TestCase $this->assertEquals($expectedGuesser, $this->registry->getTypeGuesser()); $registry = new FormRegistry( - [$this->getMockBuilder('Symfony\Component\Form\FormExtensionInterface')->getMock()], + [$this->getMockBuilder(\Symfony\Component\Form\FormExtensionInterface::class)->getMock()], $this->resolvedTypeFactory ); diff --git a/src/Symfony/Component/Form/Tests/FormRendererTest.php b/src/Symfony/Component/Form/Tests/FormRendererTest.php index 452bb71e89..66fbdd79ec 100644 --- a/src/Symfony/Component/Form/Tests/FormRendererTest.php +++ b/src/Symfony/Component/Form/Tests/FormRendererTest.php @@ -17,7 +17,7 @@ class FormRendererTest extends TestCase { public function testHumanize() { - $renderer = $this->getMockBuilder('Symfony\Component\Form\FormRenderer') + $renderer = $this->getMockBuilder(\Symfony\Component\Form\FormRenderer::class) ->setMethods(null) ->disableOriginalConstructor() ->getMock() diff --git a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php index ad1ea18e4a..d9e055b86b 100644 --- a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php @@ -50,7 +50,7 @@ class NativeRequestHandlerTest extends AbstractRequestHandlerTest public function testRequestShouldBeNull() { - $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class); $this->requestHandler->handleRequest($this->createForm('name', 'GET'), 'request'); } diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index d024828d87..5eb7433489 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -73,9 +73,9 @@ class ResolvedFormTypeTest extends TestCase protected function setUp(): void { - $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); - $this->dataMapper = $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); + $this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); + $this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(); + $this->dataMapper = $this->getMockBuilder(\Symfony\Component\Form\DataMapperInterface::class)->getMock(); $this->parentType = $this->getMockFormType(); $this->type = $this->getMockFormType(); $this->extension1 = $this->getMockFormTypeExtension(); @@ -129,9 +129,9 @@ class ResolvedFormTypeTest extends TestCase { $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom']; $resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default']; - $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock(); + $optionsResolver = $this->getMockBuilder(OptionsResolver::class)->getMock(); - $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') + $this->resolvedType = $this->getMockBuilder(ResolvedFormType::class) ->setConstructorArgs([$this->type, [$this->extension1, $this->extension2], $this->parentResolvedType]) ->setMethods(['getOptionsResolver']) ->getMock(); @@ -157,9 +157,9 @@ class ResolvedFormTypeTest extends TestCase { $givenOptions = ['data_class' => 'Foo']; $resolvedOptions = ['data_class' => \stdClass::class]; - $optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock(); + $optionsResolver = $this->getMockBuilder(OptionsResolver::class)->getMock(); - $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') + $this->resolvedType = $this->getMockBuilder(ResolvedFormType::class) ->setConstructorArgs([$this->type, [$this->extension1, $this->extension2], $this->parentResolvedType]) ->setMethods(['getOptionsResolver']) ->getMock(); @@ -183,7 +183,7 @@ class ResolvedFormTypeTest extends TestCase public function testFailsCreateBuilderOnInvalidFormOptionsResolution() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class); $this->expectExceptionMessage('An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\HiddenType": The required option "foo" is missing.'); $optionsResolver = (new OptionsResolver()) ->setRequired('foo') @@ -219,7 +219,7 @@ class ResolvedFormTypeTest extends TestCase }; $options = ['a' => 'Foo', 'b' => 'Bar']; - $builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock(); + $builder = $this->getMockBuilder(\Symfony\Component\Form\Test\FormBuilderInterface::class)->getMock(); // First the form is built for the super type $this->parentType->expects($this->once()) @@ -253,18 +253,18 @@ class ResolvedFormTypeTest extends TestCase $view = $this->resolvedType->createView($form); - $this->assertInstanceOf('Symfony\Component\Form\FormView', $view); + $this->assertInstanceOf(\Symfony\Component\Form\FormView::class, $view); $this->assertNull($view->parent); } public function testCreateViewWithParent() { $form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock()); - $parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); + $parentView = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock(); $view = $this->resolvedType->createView($form, $parentView); - $this->assertInstanceOf('Symfony\Component\Form\FormView', $view); + $this->assertInstanceOf(\Symfony\Component\Form\FormView::class, $view); $this->assertSame($parentView, $view->parent); } @@ -272,7 +272,7 @@ class ResolvedFormTypeTest extends TestCase { $options = ['a' => '1', 'b' => '2']; $form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock()); - $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); + $view = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock(); $i = 0; @@ -314,7 +314,7 @@ class ResolvedFormTypeTest extends TestCase { $options = ['a' => '1', 'b' => '2']; $form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock()); - $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); + $view = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock(); $i = 0; @@ -392,11 +392,11 @@ class ResolvedFormTypeTest extends TestCase private function getMockFormTypeExtension(): MockObject { - return $this->getMockBuilder('Symfony\Component\Form\AbstractTypeExtension')->setMethods(['getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm'])->getMock(); + return $this->getMockBuilder(\Symfony\Component\Form\AbstractTypeExtension::class)->setMethods(['getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm'])->getMock(); } private function getMockFormFactory(): MockObject { - return $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(); } } diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 811ca4ef92..a79591006c 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -97,7 +97,7 @@ class SimpleFormTest extends AbstractFormTest public function testDataTransformationFailure() { - $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); + $this->expectException(TransformationFailedException::class); $this->expectExceptionMessage('Unable to transform data for property path "name": No mapping for value "arg"'); $model = new FixedDataTransformer([ 'default' => 'foo', @@ -174,7 +174,7 @@ class SimpleFormTest extends AbstractFormTest public function testSubmitThrowsExceptionIfAlreadySubmitted() { - $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException'); + $this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class); $this->form->submit([]); $this->form->submit([]); } @@ -366,7 +366,7 @@ class SimpleFormTest extends AbstractFormTest public function testSetParentThrowsExceptionIfAlreadySubmitted() { - $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException'); + $this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class); $this->form->submit([]); $this->form->setParent($this->getBuilder('parent')->getForm()); } @@ -386,7 +386,7 @@ class SimpleFormTest extends AbstractFormTest public function testSetDataThrowsExceptionIfAlreadySubmitted() { - $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException'); + $this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class); $this->form->submit([]); $this->form->setData(null); } @@ -695,7 +695,7 @@ class SimpleFormTest extends AbstractFormTest ->setEmptyData(function ($form) { // the form instance is passed to the closure to allow use // of form data when creating the empty value - $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $form); + $this->assertInstanceOf(FormInterface::class, $form); return 'foo'; }) @@ -721,8 +721,8 @@ class SimpleFormTest extends AbstractFormTest public function testCreateView() { - $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); - $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); + $type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); + $view = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock(); $form = $this->getBuilder()->setType($type)->getForm(); $type->expects($this->once()) @@ -735,11 +735,11 @@ class SimpleFormTest extends AbstractFormTest public function testCreateViewWithParent() { - $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); - $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); - $parentType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); + $type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); + $view = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock(); + $parentType = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); $parentForm = $this->getBuilder()->setType($parentType)->getForm(); - $parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); + $parentView = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock(); $form = $this->getBuilder()->setType($type)->getForm(); $form->setParent($parentForm); @@ -757,9 +757,9 @@ class SimpleFormTest extends AbstractFormTest public function testCreateViewWithExplicitParent() { - $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); - $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); - $parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); + $type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock(); + $view = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock(); + $parentView = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock(); $form = $this->getBuilder()->setType($type)->getForm(); $type->expects($this->once()) @@ -787,7 +787,7 @@ class SimpleFormTest extends AbstractFormTest public function testFormCannotHaveEmptyNameNotInRootLevel() { - $this->expectException('Symfony\Component\Form\Exception\LogicException'); + $this->expectException(\Symfony\Component\Form\Exception\LogicException::class); $this->expectExceptionMessage('A form with an empty name cannot have a parent form.'); $this->getBuilder() ->setCompound(true) @@ -882,7 +882,7 @@ class SimpleFormTest extends AbstractFormTest public function testViewDataMayBeArrayAccessIfDataClassIsNull() { - $arrayAccess = $this->getMockBuilder('\ArrayAccess')->getMock(); + $arrayAccess = $this->getMockBuilder(\ArrayAccess::class)->getMock(); $config = new FormConfigBuilder('name', null, $this->dispatcher); $config->addViewTransformer(new FixedDataTransformer([ '' => '', @@ -897,7 +897,7 @@ class SimpleFormTest extends AbstractFormTest public function testViewDataMustBeObjectIfDataClassIsSet() { - $this->expectException('Symfony\Component\Form\Exception\LogicException'); + $this->expectException(\Symfony\Component\Form\Exception\LogicException::class); $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); $config->addViewTransformer(new FixedDataTransformer([ '' => '', @@ -910,7 +910,7 @@ class SimpleFormTest extends AbstractFormTest public function testSetDataCannotInvokeItself() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData(). You should call setData() on the FormEvent object instead.'); // Cycle detection to prevent endless loops $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); @@ -944,7 +944,7 @@ class SimpleFormTest extends AbstractFormTest public function testHandleRequestForwardsToRequestHandler() { - $handler = $this->getMockBuilder('Symfony\Component\Form\RequestHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\Symfony\Component\Form\RequestHandlerInterface::class)->getMock(); $form = $this->getBuilder() ->setRequestHandler($handler) @@ -982,7 +982,7 @@ class SimpleFormTest extends AbstractFormTest public function testInheritDataDisallowsSetData() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $form = $this->getBuilder() ->setInheritData(true) ->getForm(); @@ -992,7 +992,7 @@ class SimpleFormTest extends AbstractFormTest public function testGetDataRequiresParentToBeSetIfInheritData() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $form = $this->getBuilder() ->setInheritData(true) ->getForm(); @@ -1002,7 +1002,7 @@ class SimpleFormTest extends AbstractFormTest public function testGetNormDataRequiresParentToBeSetIfInheritData() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $form = $this->getBuilder() ->setInheritData(true) ->getForm(); @@ -1012,7 +1012,7 @@ class SimpleFormTest extends AbstractFormTest public function testGetViewDataRequiresParentToBeSetIfInheritData() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $form = $this->getBuilder() ->setInheritData(true) ->getForm(); @@ -1050,7 +1050,7 @@ class SimpleFormTest extends AbstractFormTest public function testInitializeSetsDefaultData() { $config = $this->getBuilder()->setData('DEFAULT')->getFormConfig(); - $form = $this->getMockBuilder('Symfony\Component\Form\Form')->setMethods(['setData'])->setConstructorArgs([$config])->getMock(); + $form = $this->getMockBuilder(Form::class)->setMethods(['setData'])->setConstructorArgs([$config])->getMock(); $form->expects($this->once()) ->method('setData') @@ -1062,7 +1062,7 @@ class SimpleFormTest extends AbstractFormTest public function testInitializeFailsIfParent() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $parent = $this->getBuilder()->setRequired(false)->getForm(); $child = $this->getBuilder()->setRequired(true)->getForm(); @@ -1073,7 +1073,7 @@ class SimpleFormTest extends AbstractFormTest public function testCannotCallGetDataInPreSetDataListenerIfDataHasNotAlreadyBeenSet() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call getData() if the form data has not already been set. You should call getData() on the FormEvent object instead.'); $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); $config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { @@ -1086,7 +1086,7 @@ class SimpleFormTest extends AbstractFormTest public function testCannotCallGetNormDataInPreSetDataListener() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call getNormData() if the form data has not already been set.'); $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); $config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { @@ -1099,7 +1099,7 @@ class SimpleFormTest extends AbstractFormTest public function testCannotCallGetViewDataInPreSetDataListener() { - $this->expectException('Symfony\Component\Form\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class); $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call getViewData() if the form data has not already been set.'); $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); $config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { diff --git a/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php b/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php index 9d6f7ddf06..894da681d5 100644 --- a/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php +++ b/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php @@ -29,7 +29,7 @@ class OrderedHashMapTest extends TestCase public function testGetNonExistingFails() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $map = new OrderedHashMap(); $map['first']; diff --git a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php index f3ece3c140..0feccd22b7 100644 --- a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php +++ b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php @@ -193,28 +193,28 @@ class HttpClientTraitTest extends TestCase public function testInvalidAuthBearerOption() { - $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Option "auth_bearer" must be a string, "object" given.'); self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS); } public function testInvalidAuthBearerValue() { - $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid character found in option "auth_bearer": "a\nb".'); self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => "a\nb"], HttpClientInterface::OPTIONS_DEFAULTS); } public function testSetAuthBasicAndBearerOptions() { - $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Define either the "auth_basic" or the "auth_bearer" option, setting both is not supported.'); self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => 'foo', 'auth_basic' => 'foo:bar'], HttpClientInterface::OPTIONS_DEFAULTS); } public function testSetJSONAndBodyOptions() { - $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Define either the "json" or the "body" option, setting both is not supported'); self::prepareRequest('POST', 'http://example.com', ['json' => ['foo' => 'bar'], 'body' => ''], HttpClientInterface::OPTIONS_DEFAULTS); } @@ -256,14 +256,14 @@ class HttpClientTraitTest extends TestCase public function testNormalizePeerFingerprintException() { - $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Cannot auto-detect fingerprint algorithm for "foo".'); $this->normalizePeerFingerprint('foo'); } public function testNormalizePeerFingerprintTypeException() { - $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Option "peer_fingerprint" must be string or array, "object" given.'); $fingerprint = new \stdClass(); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 36506fdd06..b234dce44d 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1941,7 +1941,7 @@ class Request // setting the default locale, the intl module is not installed, and // the call can be ignored: try { - if (class_exists('Locale', false)) { + if (class_exists(\Locale::class, false)) { \Locale::setDefault($locale); } } catch (\Exception $e) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 2efbc2b8ae..bc3e67a0b6 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -48,7 +48,7 @@ class BinaryFileResponseTest extends ResponseTestCase public function testSetContent() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $response = new BinaryFileResponse(__FILE__); $response->setContent('foo'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index e39ca673e0..aad9cef034 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -43,7 +43,7 @@ class CookieTest extends TestCase */ public function testInstantiationThrowsExceptionIfRawCookieNameContainsSpecialCharacters($name) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); Cookie::create($name, null, 0, null, null, null, false, true); } @@ -57,13 +57,13 @@ class CookieTest extends TestCase public function testInstantiationThrowsExceptionIfCookieNameIsEmpty() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); Cookie::create(''); } public function testInvalidExpiration() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); Cookie::create('MyCookie', 'foo', 'bar'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php b/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php index 8a389329e4..aab5f739cc 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php @@ -20,7 +20,7 @@ class ExpressionRequestMatcherTest extends TestCase { public function testWhenNoExpressionIsSet() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $expressionRequestMatcher = new ExpressionRequestMatcher(); $expressionRequestMatcher->matches(new Request()); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php index 3559275df8..9b8272633c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php @@ -41,7 +41,7 @@ class FileTest extends TestCase public function testConstructWhenFileNotExists() { - $this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); + $this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class); new File(__DIR__.'/Fixtures/not_here'); } @@ -57,7 +57,7 @@ class FileTest extends TestCase $file = new File($path); $movedFile = $file->move($targetDir); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile); + $this->assertInstanceOf(File::class, $movedFile); $this->assertFileExists($targetPath); $this->assertFileDoesNotExist($path); @@ -111,7 +111,7 @@ class FileTest extends TestCase $file = new File($path); $movedFile = $file->move($targetDir, $filename); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile); + $this->assertInstanceOf(File::class, $movedFile); $this->assertFileExists($targetPath); $this->assertFileDoesNotExist($path); diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php index 4b568e5514..ca369a01df 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php @@ -39,7 +39,7 @@ class MimeTypeTest extends TestCase public function testGuessImageWithDirectory() { - $this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); + $this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class); MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory'); } @@ -68,7 +68,7 @@ class MimeTypeTest extends TestCase public function testGuessWithIncorrectPath() { - $this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); + $this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class); MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here'); } @@ -87,7 +87,7 @@ class MimeTypeTest extends TestCase @chmod($path, 0333); if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) { - $this->expectException('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException'); + $this->expectException(\Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException::class); MimeTypeGuesser::getInstance()->guess($path); } else { $this->markTestSkipped('Can not verify chmod operations, change of file permissions failed'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php index 678fdefe3c..cf0019212b 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php @@ -33,7 +33,7 @@ class UploadedFileTest extends TestCase public function testConstructWhenFileNotExists() { - $this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); + $this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class); new UploadedFile( __DIR__.'/Fixtures/not_here', @@ -144,7 +144,7 @@ class UploadedFileTest extends TestCase public function testMoveLocalFileIsNotAllowed() { - $this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileException'); + $this->expectException(FileException::class); $file = new UploadedFile( __DIR__.'/Fixtures/test.gif', 'original.gif', diff --git a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php index 69983ede49..7b33df471d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php @@ -25,7 +25,7 @@ class FileBagTest extends TestCase { public function testFileMustBeAnArrayOrUploadedFile() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new FileBag(['file' => 'foo']); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php index 3ce4a7dd4d..46fe20c213 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php @@ -45,7 +45,7 @@ class HeaderBagTest extends TestCase { $bag = new HeaderBag(['foo' => 'Tue, 4 Sep 2012 20:00:00 +0200']); $headerDate = $bag->getDate('foo'); - $this->assertInstanceOf('DateTime', $headerDate); + $this->assertInstanceOf(\DateTime::class, $headerDate); } public function testGetDateNull() @@ -57,7 +57,7 @@ class HeaderBagTest extends TestCase public function testGetDateException() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $bag = new HeaderBag(['foo' => 'Tue']); $bag->getDate('foo'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php b/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php index eafcd9311b..eb48c54464 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php @@ -99,7 +99,7 @@ class HeaderUtilsTest extends TestCase public function testMakeDispositionInvalidDisposition() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); HeaderUtils::makeDisposition('invalid', 'foo.html'); } @@ -128,7 +128,7 @@ class HeaderUtilsTest extends TestCase */ public function testMakeDispositionFail($disposition, $filename) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); HeaderUtils::makeDisposition($disposition, $filename); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php b/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php index 13b5743794..2510b830a1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php @@ -77,7 +77,7 @@ class IpUtilsTest extends TestCase */ public function testAnIpv6WithOptionDisabledIpv6() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); if (\defined('AF_INET6')) { $this->markTestSkipped('Only works when PHP is compiled with the option "disable-ipv6".'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php index 8c37fd771b..664f577b17 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php @@ -94,7 +94,7 @@ class JsonResponseTest extends TestCase { $response = JsonResponse::create(['foo' => 'bar'], 204); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals('{"foo":"bar"}', $response->getContent()); $this->assertEquals(204, $response->getStatusCode()); } @@ -102,41 +102,41 @@ class JsonResponseTest extends TestCase public function testStaticCreateEmptyJsonObject() { $response = JsonResponse::create(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame('{}', $response->getContent()); } public function testStaticCreateJsonArray() { $response = JsonResponse::create([0, 1, 2, 3]); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame('[0,1,2,3]', $response->getContent()); } public function testStaticCreateJsonObject() { $response = JsonResponse::create(['foo' => 'bar']); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame('{"foo":"bar"}', $response->getContent()); } public function testStaticCreateWithSimpleTypes() { $response = JsonResponse::create('foo'); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame('"foo"', $response->getContent()); $response = JsonResponse::create(0); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame('0', $response->getContent()); $response = JsonResponse::create(0.1); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals(0.1, $response->getContent()); $this->assertIsString($response->getContent()); $response = JsonResponse::create(true); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); + $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame('true', $response->getContent()); } @@ -209,22 +209,22 @@ class JsonResponseTest extends TestCase public function testSetCallbackInvalidIdentifier() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $response = new JsonResponse('foo'); $response->setCallback('+invalid'); } public function testSetContent() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); JsonResponse::create("\xB1\x31"); } public function testSetContentJsonSerializeError() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('This error is expected'); - if (!interface_exists('JsonSerializable', false)) { + if (!interface_exists(\JsonSerializable::class, false)) { $this->markTestSkipped('JsonSerializable is required.'); } @@ -280,7 +280,7 @@ class JsonResponseTest extends TestCase } } -if (interface_exists('JsonSerializable', false)) { +if (interface_exists(\JsonSerializable::class, false)) { class JsonSerializableObject implements \JsonSerializable { public function jsonSerialize() diff --git a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php index a4d99d839f..eddd4a5711 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php @@ -25,14 +25,14 @@ class RedirectResponseTest extends TestCase public function testRedirectResponseConstructorEmptyUrl() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Cannot redirect to an empty URL.'); new RedirectResponse(''); } public function testRedirectResponseConstructorWrongStatusCode() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new RedirectResponse('foo.bar', 404); } @@ -61,7 +61,7 @@ class RedirectResponseTest extends TestCase public function testSetTargetUrlNull() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $response = new RedirectResponse('foo.bar'); $response->setTargetUrl(null); } @@ -70,7 +70,7 @@ class RedirectResponseTest extends TestCase { $response = RedirectResponse::create('foo', 301); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); + $this->assertInstanceOf(RedirectResponse::class, $response); $this->assertEquals(301, $response->getStatusCode()); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index ef15ea8eff..e2d04185a0 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -918,7 +918,7 @@ class RequestTest extends TestCase public function testGetHostWithFakeHttpHostValue() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $request = new Request(); $request->initialize([], [], [], [], [], ['HTTP_HOST' => 'www.host.com?query=string']); $request->getHost(); @@ -1087,7 +1087,7 @@ class RequestTest extends TestCase */ public function testGetClientIpsWithConflictingHeaders($httpForwarded, $httpXForwardedFor) { - $this->expectException('Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException'); + $this->expectException(\Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException::class); $request = new Request(); $server = [ @@ -1825,7 +1825,7 @@ class RequestTest extends TestCase private function disableHttpMethodParameterOverride() { - $class = new \ReflectionClass('Symfony\\Component\\HttpFoundation\\Request'); + $class = new \ReflectionClass(Request::class); $property = $class->getProperty('httpMethodParameterOverride'); $property->setAccessible(true); $property->setValue(false); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index 8b54822ddb..81f8ba2894 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -250,7 +250,7 @@ class ResponseHeaderBagTest extends TestCase public function testGetCookiesWithInvalidArgument() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $bag = new ResponseHeaderBag(); $bag->getCookies('invalid_argument'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index cd133b8c30..23ac307daa 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -24,7 +24,7 @@ class ResponseTest extends ResponseTestCase { $response = Response::create('foo', 301, ['Foo' => 'bar']); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); + $this->assertInstanceOf(Response::class, $response); $this->assertEquals(301, $response->getStatusCode()); $this->assertEquals('bar', $response->headers->get('foo')); } @@ -611,7 +611,7 @@ class ResponseTest extends ResponseTestCase $response->setCache(['wrong option' => 'value']); $this->fail('->setCache() throws an InvalidArgumentException if an option is not supported'); } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '->setCache() throws an InvalidArgumentException if an option is not supported'); + $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->setCache() throws an InvalidArgumentException if an option is not supported'); $this->assertStringContainsString('"wrong option"', $e->getMessage()); } @@ -916,7 +916,7 @@ class ResponseTest extends ResponseTestCase */ public function testSetContentInvalid($content) { - $this->expectException('UnexpectedValueException'); + $this->expectException(\UnexpectedValueException::class); $response = new Response(); $response->setContent($content); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php index 576a31b23b..d54a419d75 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php @@ -212,7 +212,7 @@ class SessionTest extends TestCase public function testGetFlashBag() { - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface', $this->session->getFlashBag()); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface::class, $this->session->getFlashBag()); } public function testGetIterator() @@ -241,7 +241,7 @@ class SessionTest extends TestCase public function testGetMeta() { - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\MetadataBag', $this->session->getMetadataBag()); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag::class, $this->session->getMetadataBag()); } public function testIsEmpty() diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index 0f8d8989b7..c605607cb1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -38,7 +38,7 @@ class MemcachedSessionHandlerTest extends TestCase $this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower, or 3.0.0b1 or higher'); } - $this->memcached = $this->getMockBuilder('Memcached')->getMock(); + $this->memcached = $this->getMockBuilder(\Memcached::class)->getMock(); $this->storage = new MemcachedSessionHandler( $this->memcached, ['prefix' => self::PREFIX, 'expiretime' => self::TTL] diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index f0e2d4f504..01b92dfa22 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -55,7 +55,7 @@ class MongoDbSessionHandlerTest extends TestCase public function testConstructorShouldThrowExceptionForMissingOptions() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new MongoDbSessionHandler($this->mongo, []); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php index 368af6a3e3..89e628754c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -60,7 +60,7 @@ class NativeFileSessionHandlerTest extends TestCase public function testConstructException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new NativeFileSessionHandler('something;invalid;with;too-many-args'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index f84c824e6d..b5fb7067bd 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -50,7 +50,7 @@ class PdoSessionHandlerTest extends TestCase public function testWrongPdoErrMode() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $pdo = $this->getMemorySqlitePdo(); $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); @@ -59,7 +59,7 @@ class PdoSessionHandlerTest extends TestCase public function testInexistentTable() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $storage = new PdoSessionHandler($this->getMemorySqlitePdo(), ['db_table' => 'inexistent_table']); $storage->open('', 'sid'); $storage->read('id'); @@ -69,7 +69,7 @@ class PdoSessionHandlerTest extends TestCase public function testCreateTableTwice() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); $storage->createTable(); } @@ -131,7 +131,7 @@ class PdoSessionHandlerTest extends TestCase public function testReadConvertsStreamToString() { $pdo = new MockPdo('pgsql'); - $pdo->prepareResult = $this->getMockBuilder('PDOStatement')->getMock(); + $pdo->prepareResult = $this->getMockBuilder(\PDOStatement::class)->getMock(); $content = 'foobar'; $stream = $this->createStream($content); @@ -152,8 +152,8 @@ class PdoSessionHandlerTest extends TestCase } $pdo = new MockPdo('pgsql'); - $selectStmt = $this->getMockBuilder('PDOStatement')->getMock(); - $insertStmt = $this->getMockBuilder('PDOStatement')->getMock(); + $selectStmt = $this->getMockBuilder(\PDOStatement::class)->getMock(); + $insertStmt = $this->getMockBuilder(\PDOStatement::class)->getMock(); $pdo->prepareResult = function ($statement) use ($selectStmt, $insertStmt) { return 0 === strpos($statement, 'INSERT') ? $insertStmt : $selectStmt; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/RedisClusterSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/RedisClusterSessionHandlerTest.php index 278b3c8764..af5d9b2c73 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/RedisClusterSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/RedisClusterSessionHandlerTest.php @@ -18,7 +18,7 @@ class RedisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase { public static function setUpBeforeClass(): void { - if (!class_exists('RedisCluster')) { + if (!class_exists(\RedisCluster::class)) { self::markTestSkipped('The RedisCluster class is required.'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php index 6a0d16876e..1a632b248f 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php @@ -19,19 +19,19 @@ class StrictSessionHandlerTest extends TestCase { public function testOpen() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('open') ->with('path', 'name')->willReturn(true); $proxy = new StrictSessionHandler($handler); - $this->assertInstanceOf('SessionUpdateTimestampHandlerInterface', $proxy); + $this->assertInstanceOf(\SessionUpdateTimestampHandlerInterface::class, $proxy); $this->assertInstanceOf(AbstractSessionHandler::class, $proxy); $this->assertTrue($proxy->open('path', 'name')); } public function testCloseSession() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('close') ->willReturn(true); $proxy = new StrictSessionHandler($handler); @@ -41,7 +41,7 @@ class StrictSessionHandlerTest extends TestCase public function testValidateIdOK() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn('data'); $proxy = new StrictSessionHandler($handler); @@ -51,7 +51,7 @@ class StrictSessionHandlerTest extends TestCase public function testValidateIdKO() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn(''); $proxy = new StrictSessionHandler($handler); @@ -61,7 +61,7 @@ class StrictSessionHandlerTest extends TestCase public function testRead() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn('data'); $proxy = new StrictSessionHandler($handler); @@ -71,7 +71,7 @@ class StrictSessionHandlerTest extends TestCase public function testReadWithValidateIdOK() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn('data'); $proxy = new StrictSessionHandler($handler); @@ -82,7 +82,7 @@ class StrictSessionHandlerTest extends TestCase public function testReadWithValidateIdMismatch() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->exactly(2))->method('read') ->withConsecutive(['id1'], ['id2']) ->will($this->onConsecutiveCalls('data1', 'data2')); @@ -94,7 +94,7 @@ class StrictSessionHandlerTest extends TestCase public function testUpdateTimestamp() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('write') ->with('id', 'data')->willReturn(true); $proxy = new StrictSessionHandler($handler); @@ -104,7 +104,7 @@ class StrictSessionHandlerTest extends TestCase public function testWrite() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('write') ->with('id', 'data')->willReturn(true); $proxy = new StrictSessionHandler($handler); @@ -114,7 +114,7 @@ class StrictSessionHandlerTest extends TestCase public function testWriteEmptyNewSession() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn(''); $handler->expects($this->never())->method('write'); @@ -128,7 +128,7 @@ class StrictSessionHandlerTest extends TestCase public function testWriteEmptyExistingSession() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn('data'); $handler->expects($this->never())->method('write'); @@ -141,7 +141,7 @@ class StrictSessionHandlerTest extends TestCase public function testDestroy() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('destroy') ->with('id')->willReturn(true); $proxy = new StrictSessionHandler($handler); @@ -151,7 +151,7 @@ class StrictSessionHandlerTest extends TestCase public function testDestroyNewSession() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn(''); $handler->expects($this->once())->method('destroy')->willReturn(true); @@ -163,7 +163,7 @@ class StrictSessionHandlerTest extends TestCase public function testDestroyNonEmptyNewSession() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn(''); $handler->expects($this->once())->method('write') @@ -179,7 +179,7 @@ class StrictSessionHandlerTest extends TestCase public function testGc() { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $handler = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $handler->expects($this->once())->method('gc') ->with(123)->willReturn(true); $proxy = new StrictSessionHandler($handler); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php index b99e71985b..2428e9fc24 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php @@ -123,7 +123,7 @@ class MockArraySessionStorageTest extends TestCase public function testUnstartedSave() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->storage->save(); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php index 2ca81fed8f..3f994cb2a7 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php @@ -109,7 +109,7 @@ class MockFileSessionStorageTest extends TestCase public function testSaveWithoutStart() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $storage1 = $this->getStorage(); $storage1->save(); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 7de93f4441..c9aa9a27b5 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -71,14 +71,14 @@ class NativeSessionStorageTest extends TestCase public function testRegisterBagException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $storage = $this->getStorage(); $storage->getBag('non_existing'); } public function testRegisterBagForAStartedSessionThrowsException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $storage = $this->getStorage(); $storage->start(); $storage->registerBag(new AttributeBag()); @@ -207,7 +207,7 @@ class NativeSessionStorageTest extends TestCase public function testSetSaveHandlerException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $storage = $this->getStorage(); $storage->setSaveHandler(new \stdClass()); } @@ -217,22 +217,22 @@ class NativeSessionStorageTest extends TestCase $this->iniSet('session.save_handler', 'files'); $storage = $this->getStorage(); $storage->setSaveHandler(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); + $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler()); $storage->setSaveHandler(null); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); + $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler()); $storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler())); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); + $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler()); $storage->setSaveHandler(new NativeFileSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); + $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler()); $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); + $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler()); $storage->setSaveHandler(new NullSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); + $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler()); } public function testStarted() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $storage = $this->getStorage(); $this->assertFalse($storage->getSaveHandler()->isActive()); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php index 4820a6593b..c500829811 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php @@ -83,7 +83,7 @@ class AbstractProxyTest extends TestCase */ public function testNameException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); session_start(); $this->proxy->setName('foo'); } @@ -106,7 +106,7 @@ class AbstractProxyTest extends TestCase */ public function testIdException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); session_start(); $this->proxy->setId('foo'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index 81c90433d7..96792fd128 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -36,7 +36,7 @@ class SessionHandlerProxyTest extends TestCase protected function setUp(): void { - $this->mock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); + $this->mock = $this->getMockBuilder(\SessionHandlerInterface::class)->getMock(); $this->proxy = new SessionHandlerProxy($this->mock); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php index a084e917dc..3de3a70297 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php @@ -83,14 +83,14 @@ class StreamedResponseTest extends TestCase public function testSendContentWithNonCallable() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $response = new StreamedResponse(null); $response->sendContent(); } public function testSetContent() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $response = new StreamedResponse(function () { echo 'foo'; }); $response->setContent('foo'); } @@ -105,19 +105,19 @@ class StreamedResponseTest extends TestCase { $response = StreamedResponse::create(function () {}, 204); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response); + $this->assertInstanceOf(StreamedResponse::class, $response); $this->assertEquals(204, $response->getStatusCode()); } public function testReturnThis() { $response = new StreamedResponse(function () {}); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent()); + $this->assertInstanceOf(StreamedResponse::class, $response->sendContent()); + $this->assertInstanceOf(StreamedResponse::class, $response->sendContent()); $response = new StreamedResponse(function () {}); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders()); + $this->assertInstanceOf(StreamedResponse::class, $response->sendHeaders()); + $this->assertInstanceOf(StreamedResponse::class, $response->sendHeaders()); } public function testSetNotModified() diff --git a/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php b/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php index 9a750bd8a3..758b9c16a8 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php @@ -59,7 +59,7 @@ class UrlHelperTest extends TestCase */ public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected) { - if (!class_exists('Symfony\Component\Routing\RequestContext')) { + if (!class_exists(RequestContext::class)) { $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); } @@ -74,7 +74,7 @@ class UrlHelperTest extends TestCase */ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) { - if (!class_exists('Symfony\Component\Routing\RequestContext')) { + if (!class_exists(RequestContext::class)) { $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); } @@ -117,7 +117,7 @@ class UrlHelperTest extends TestCase */ public function testGenerateRelativePath($expected, $path, $pathinfo) { - if (!method_exists('Symfony\Component\HttpFoundation\Request', 'getRelativeUriForPath')) { + if (!method_exists(Request::class, 'getRelativeUriForPath')) { $this->markTestSkipped('Your version of Symfony HttpFoundation is too old.'); } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 179c7515c7..d4b298c594 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -69,7 +69,7 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => \PHP_VERSION, 'php_architecture' => \PHP_INT_SIZE * 8, - 'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', + 'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), 'apcu_enabled' => \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 22c3751b43..b91fc66a9f 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -748,7 +748,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl if ($this instanceof CompilerPassInterface) { $container->addCompilerPass($this, PassConfig::TYPE_BEFORE_OPTIMIZATION, -10000); } - if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator')) { + if (class_exists(\ProxyManager\Configuration::class) && class_exists(RuntimeInstantiator::class)) { $container->setProxyInstantiator(new RuntimeInstantiator()); } @@ -766,7 +766,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl // cache the container $dumper = new PhpDumper($container); - if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper')) { + if (class_exists(\ProxyManager\Configuration::class) && class_exists(ProxyDumper::class)) { $dumper->setProxyDumper(new ProxyDumper()); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php index be03734dc4..0937eebcc4 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php @@ -30,7 +30,7 @@ class BundleTest extends TestCase public function testGetContainerExtensionWithInvalidClass() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface'); $bundle = new ExtensionNotValidBundle(); $bundle->getContainerExtension(); diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php index b97559e321..a0b4bd8c41 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php @@ -41,6 +41,6 @@ class ChainCacheClearerTest extends TestCase protected function getMockClearer() { - return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface::class)->getMock(); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php index 6e0a47e930..c7c683428e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php @@ -39,7 +39,7 @@ class Psr6CacheClearerTest extends TestCase public function testClearPoolThrowsExceptionOnUnreferencedPool() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Cache pool not found: "unknown"'); (new Psr6CacheClearer())->clearPool('unknown'); } diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php index 4266c0a182..cf9493a295 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php @@ -70,7 +70,7 @@ class CacheWarmerAggregateTest extends TestCase protected function getCacheWarmerMock() { - $warmer = $this->getMockBuilder('Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface') + $warmer = $this->getMockBuilder(\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php index 8359d99f5f..c3286d0020 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php @@ -38,7 +38,7 @@ class CacheWarmerTest extends TestCase public function testWriteNonWritableCacheFileThrowsARuntimeException() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $nonWritableFile = '/this/file/is/very/probably/not/writable'; $warmer = new TestCacheWarmer($nonWritableFile); $warmer->warmUp(\dirname($nonWritableFile)); diff --git a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php index 6bfaeca2f5..d992286752 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php @@ -18,7 +18,7 @@ class FileLocatorTest extends TestCase { public function testLocate() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel ->expects($this->atLeastOnce()) ->method('locateResource') @@ -30,7 +30,7 @@ class FileLocatorTest extends TestCase $kernel ->expects($this->never()) ->method('locateResource'); - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $locator->locate('/some/path'); } @@ -39,7 +39,7 @@ class FileLocatorTest extends TestCase */ public function testLocateWithGlobalResourcePath() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel ->expects($this->atLeastOnce()) ->method('locateResource') diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php index 4f85b0f351..efb7322efa 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php @@ -55,7 +55,7 @@ class NotTaggedControllerValueResolverTest extends TestCase public function testController() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); @@ -66,7 +66,7 @@ class NotTaggedControllerValueResolverTest extends TestCase public function testControllerWithATrailingBackSlash() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); @@ -77,7 +77,7 @@ class NotTaggedControllerValueResolverTest extends TestCase public function testControllerWithMethodNameStartUppercase() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); @@ -88,7 +88,7 @@ class NotTaggedControllerValueResolverTest extends TestCase public function testControllerNameIsAnArray() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php index 4036727bce..743eefa3e5 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php @@ -107,7 +107,7 @@ class ServiceValueResolverTest extends TestCase public function testErrorIsTruncated() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Cannot autowire argument $dummy of "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyController::index()": it references class "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyService" but no such service exists.'); $container = new ContainerBuilder(); $container->addCompilerPass(new RegisterControllerArgumentLocatorsPass()); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php index c0ed800bb4..da521ff204 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php @@ -164,7 +164,7 @@ class ArgumentResolverTest extends TestCase public function testGetVariadicArgumentsWithoutArrayInRequest() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', 'foo'); @@ -175,7 +175,7 @@ class ArgumentResolverTest extends TestCase public function testGetArgumentWithoutArray() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $factory = new ArgumentMetadataFactory(); $valueResolver = $this->getMockBuilder(ArgumentValueResolverInterface::class)->getMock(); $resolver = new ArgumentResolver($factory, [$valueResolver]); @@ -192,7 +192,7 @@ class ArgumentResolverTest extends TestCase public function testIfExceptionIsThrownWhenMissingAnArgument() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $request = Request::create('/'); $controller = [$this, 'controllerWithFoo']; @@ -251,7 +251,7 @@ class ArgumentResolverTest extends TestCase public function testGetSessionMissMatchWithInterface() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $session = $this->getMockBuilder(SessionInterface::class)->getMock(); $request = Request::create('/'); $request->setSession($session); @@ -262,7 +262,7 @@ class ArgumentResolverTest extends TestCase public function testGetSessionMissMatchWithImplementation() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $session = new Session(new MockArraySessionStorage()); $request = Request::create('/'); $request->setSession($session); @@ -273,7 +273,7 @@ class ArgumentResolverTest extends TestCase public function testGetSessionMissMatchOnNull() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $request = Request::create('/'); $controller = [$this, 'controllerWithExtendingSession']; diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php index c39dac3ca5..7f4564688c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php @@ -151,7 +151,7 @@ class ContainerControllerResolverTest extends ControllerResolverTest public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsName() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->once()) @@ -175,7 +175,7 @@ class ContainerControllerResolverTest extends ControllerResolverTest public function testExceptionWhenUsingRemovedControllerService() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->once()) diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index de6dfc2546..834f925c43 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -20,7 +20,7 @@ class ControllerResolverTest extends TestCase { public function testGetControllerWithoutControllerParameter() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing.'); $resolver = $this->createControllerResolver($logger); @@ -94,7 +94,7 @@ class ControllerResolverTest extends TestCase public function testGetControllerOnObjectWithoutInvokeMethod() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $resolver = $this->createControllerResolver(); $request = Request::create('/'); diff --git a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php index 5ce4b1f76b..fef6cd0002 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php @@ -34,7 +34,7 @@ class ArgumentMetadataTest extends TestCase public function testDefaultValueUnavailable() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $argument = new ArgumentMetadata('foo', 'string', false, false, null, false); $this->assertFalse($argument->isNullable()); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index b7f2cd90f3..df6af954f3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -33,7 +33,7 @@ class ConfigDataCollectorTest extends TestCase $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', \PHP_VERSION); $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', \PHP_VERSION); $this->assertSame(\PHP_INT_SIZE * 8, $c->getPhpArchitecture()); - $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); + $this->assertSame(class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); $this->assertSame(4 === Kernel::MINOR_VERSION, $c->isSymfonyLts()); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index de9364bb47..4204b8ef03 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -24,7 +24,7 @@ class LoggerDataCollectorTest extends TestCase public function testCollectWithUnexpectedFormat() { $logger = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') + ->getMockBuilder(DebugLoggerInterface::class) ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); $logger->expects($this->once())->method('countErrors')->willReturn(123); @@ -91,7 +91,7 @@ class LoggerDataCollectorTest extends TestCase public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null) { $logger = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') + ->getMockBuilder(DebugLoggerInterface::class) ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); $logger->expects($this->once())->method('countErrors')->willReturn($nb); @@ -123,7 +123,7 @@ class LoggerDataCollectorTest extends TestCase public function testReset() { $logger = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') + ->getMockBuilder(DebugLoggerInterface::class) ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); $logger->expects($this->once())->method('clear'); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index 852839c9b1..bb29b4ba52 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -39,12 +39,12 @@ class RequestDataCollectorTest extends TestCase $attributes = $c->getRequestAttributes(); $this->assertSame('request', $c->getName()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestHeaders()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestServer()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestCookies()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestRequest()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery()); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestHeaders()); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestServer()); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestCookies()); + $this->assertInstanceOf(ParameterBag::class, $attributes); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestRequest()); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestQuery()); $this->assertInstanceOf(ParameterBag::class, $c->getResponseCookies()); $this->assertSame('html', $c->getFormat()); $this->assertEquals('foobar', $c->getRoute()); @@ -54,7 +54,7 @@ class RequestDataCollectorTest extends TestCase $this->assertContainsEquals(__FILE__, $attributes->get('resource')); $this->assertSame('stdClass', $attributes->get('object')->getType()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getResponseHeaders()); + $this->assertInstanceOf(ParameterBag::class, $c->getResponseHeaders()); $this->assertSame('OK', $c->getStatusText()); $this->assertSame(200, $c->getStatusCode()); $this->assertSame('application/json', $c->getContentType()); @@ -288,7 +288,7 @@ class RequestDataCollectorTest extends TestCase */ protected function injectController($collector, $controller, $request) { - $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); + $resolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ControllerResolverInterface::class)->getMock(); $httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMockBuilder(ArgumentResolverInterface::class)->getMock()); $event = new ControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST); $collector->onKernelController($event); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php index 9de9eb599a..ab231ac4c5 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -43,7 +43,7 @@ class TimeDataCollectorTest extends TestCase $c->collect($request, new Response()); $this->assertEquals(0, $c->getStartTime()); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel->expects($this->once())->method('getStartTime')->willReturn(123456.0); $c = new TimeDataCollector($kernel); diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index cf8a3b8a1e..c4d42ec648 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -45,7 +45,7 @@ class TraceableEventDispatcherTest extends TestCase public function testStopwatchCheckControllerOnRequestEvent() { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') + $stopwatch = $this->getMockBuilder(Stopwatch::class) ->setMethods(['isStarted']) ->getMock(); $stopwatch->expects($this->once()) @@ -61,7 +61,7 @@ class TraceableEventDispatcherTest extends TestCase public function testStopwatchStopControllerOnRequestEvent() { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') + $stopwatch = $this->getMockBuilder(Stopwatch::class) ->setMethods(['isStarted', 'stop']) ->getMock(); $stopwatch->expects($this->once()) @@ -110,9 +110,9 @@ class TraceableEventDispatcherTest extends TestCase protected function getHttpKernel($dispatcher, $controller) { - $controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock(); + $controllerResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ControllerResolverInterface::class)->getMock(); $controllerResolver->expects($this->once())->method('getController')->willReturn($controller); - $argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock(); + $argumentResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface::class)->getMock(); $argumentResolver->expects($this->once())->method('getArguments')->willReturn([]); return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php index 49567d40be..ab0efe32f5 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php @@ -29,7 +29,7 @@ class FragmentRendererPassTest extends TestCase */ public function testContentRendererWithoutInterface() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $builder = new ContainerBuilder(); $fragmentHandlerDefinition = $builder->register('fragment.handler'); $builder->register('my_content_renderer', 'Symfony\Component\DependencyInjection\Definition') diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php index 39a1cb73b1..493178d470 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php @@ -20,14 +20,14 @@ class LazyLoadingFragmentHandlerTest extends TestCase { public function testRender() { - $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); + $renderer = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface::class)->getMock(); $renderer->expects($this->once())->method('getName')->willReturn('foo'); $renderer->expects($this->any())->method('render')->willReturn(new Response()); - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $requestStack->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/')); - $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock(); + $container = $this->getMockBuilder(\Psr\Container\ContainerInterface::class)->getMock(); $container->expects($this->once())->method('has')->with('foo')->willReturn(true); $container->expects($this->once())->method('get')->willReturn($renderer); diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index a3b7969be1..8a65b4ff38 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -27,7 +27,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase { public function testInvalidClass() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Class "Symfony\Component\HttpKernel\Tests\DependencyInjection\NotFound" used for service "foo" cannot be found.'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -42,7 +42,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase public function testNoAction() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Missing "action" attribute on tag "controller.service_arguments" {"argument":"bar"} for service "foo".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -57,7 +57,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase public function testNoArgument() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Missing "argument" attribute on tag "controller.service_arguments" {"action":"fooAction"} for service "foo".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -72,7 +72,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase public function testNoService() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Missing "id" attribute on tag "controller.service_arguments" {"action":"fooAction","argument":"bar"} for service "foo".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -87,7 +87,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase public function testInvalidMethod() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "action" attribute on tag "controller.service_arguments" for service "foo": no public "barAction()" method found on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -102,7 +102,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase public function testInvalidArgument() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "controller.service_arguments" tag for service "foo": method "fooAction()" has no "baz" argument on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -197,7 +197,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase public function testExceptionOnNonExistentTypeHint() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClass". Did you forget to add a use statement?'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -211,7 +211,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase public function testExceptionOnNonExistentTypeHintDifferentNamespace() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassDifferentNamespaceController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Acme\NonExistentClass".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php index 9dbc2b08a4..b28f90d362 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php @@ -57,7 +57,7 @@ class ResettableServicePassTest extends TestCase public function testMissingMethod() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Tag "kernel.reset" requires the "method" attribute to be set.'); $container = new ContainerBuilder(); $container->register(ResettableService::class) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php index da8dc6fb0b..6c4459fc2a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -41,7 +41,7 @@ class AddRequestFormatsListenerTest extends TestCase public function testIsAnEventSubscriber() { - $this->assertInstanceOf('Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->listener); + $this->assertInstanceOf(\Symfony\Component\EventDispatcher\EventSubscriberInterface::class, $this->listener); } public function testRegisteredEvent() @@ -66,7 +66,7 @@ class AddRequestFormatsListenerTest extends TestCase protected function getRequestMock() { - return $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + return $this->getMockBuilder(Request::class)->getMock(); } protected function getRequestEventMock(Request $request) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index 7e336a1d6c..fb18d63fbe 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -35,7 +35,7 @@ class DebugHandlersListenerTest extends TestCase { public function testConfigure() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $userHandler = function () {}; $listener = new DebugHandlersListener($userHandler, $logger); $eHandler = new ErrorHandler(); @@ -67,7 +67,7 @@ class DebugHandlersListenerTest extends TestCase $listener = new DebugHandlersListener(null); $eHandler = new ErrorHandler(); $event = new KernelEvent( - $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), + $this->getMockBuilder(HttpKernelInterface::class)->getMock(), Request::create('/'), HttpKernelInterface::MASTER_REQUEST ); @@ -91,7 +91,7 @@ class DebugHandlersListenerTest extends TestCase { $dispatcher = new EventDispatcher(); $listener = new DebugHandlersListener(null); - $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); + $app = $this->getMockBuilder(Application::class)->getMock(); $app->expects($this->once())->method('getHelperSet')->willReturn(new HelperSet()); $command = new Command(__FUNCTION__); $command->setApplication($app); @@ -121,7 +121,7 @@ class DebugHandlersListenerTest extends TestCase } $xHandler = $eHandler->setExceptionHandler('var_dump'); - $this->assertInstanceOf('Closure', $xHandler); + $this->assertInstanceOf(\Closure::class, $xHandler); $app->expects($this->once()) ->method(method_exists(Application::class, 'renderThrowable') ? 'renderThrowable' : 'renderException'); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php index cdf6874f35..4428e3d1a6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php @@ -99,7 +99,7 @@ class ErrorListenerTest extends TestCase public function provider() { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + if (!class_exists(Request::class)) { return [[null, null]]; } @@ -115,9 +115,9 @@ class ErrorListenerTest extends TestCase public function testSubRequestFormat() { - $listener = new ErrorListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock()); + $listener = new ErrorListener('foo', $this->getMockBuilder(LoggerInterface::class)->getMock()); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); @@ -135,12 +135,12 @@ class ErrorListenerTest extends TestCase public function testCSPHeaderIsRemoved() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); - $listener = new ErrorListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true); + $listener = new ErrorListener('foo', $this->getMockBuilder(LoggerInterface::class)->getMock(), true); $dispatcher->addSubscriber($listener); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php index 28113c14af..91ff62d906 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php @@ -96,7 +96,7 @@ class ExceptionListenerTest extends TestCase public function provider() { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + if (!class_exists(Request::class)) { return [[null, null]]; } @@ -112,9 +112,9 @@ class ExceptionListenerTest extends TestCase public function testSubRequestFormat() { - $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock()); + $listener = new ExceptionListener('foo', $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock()); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); @@ -132,12 +132,12 @@ class ExceptionListenerTest extends TestCase public function testCSPHeaderIsRemoved() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); - $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true); + $listener = new ExceptionListener('foo', $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(), true); $dispatcher->addSubscriber($listener); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php index 5b045a8fc4..e0b857debd 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php @@ -52,7 +52,7 @@ class FragmentListenerTest extends TestCase public function testAccessDeniedWithNonSafeMethods() { - $this->expectException('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class); $request = Request::create('http://example.com/_fragment', 'POST'); $listener = new FragmentListener(new UriSigner('foo')); @@ -63,7 +63,7 @@ class FragmentListenerTest extends TestCase public function testAccessDeniedWithWrongSignature() { - $this->expectException('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class); $request = Request::create('http://example.com/_fragment', 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']); $listener = new FragmentListener(new UriSigner('foo')); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php index 0064429048..0d14e5a987 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleAwareListenerTest.php @@ -110,7 +110,7 @@ class LocaleAwareListenerTest extends TestCase private function createHttpKernel() { - return $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + return $this->getMockBuilder(HttpKernelInterface::class)->getMock(); } private function createRequest($locale) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php index cb502a89ee..705600d70e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php @@ -26,7 +26,7 @@ class LocaleListenerTest extends TestCase protected function setUp(): void { - $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock(); + $this->requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->disableOriginalConstructor()->getMock(); } public function testIsAnEventSubscriber() @@ -70,10 +70,10 @@ class LocaleListenerTest extends TestCase public function testLocaleSetForRoutingContext() { // the request context is updated - $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); + $context = $this->getMockBuilder(\Symfony\Component\Routing\RequestContext::class)->getMock(); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); + $router = $this->getMockBuilder(\Symfony\Component\Routing\Router::class)->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->willReturn($context); $request = Request::create('/'); @@ -86,10 +86,10 @@ class LocaleListenerTest extends TestCase public function testRouterResetWithParentRequestOnKernelFinishRequest() { // the request context is updated - $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); + $context = $this->getMockBuilder(\Symfony\Component\Routing\RequestContext::class)->getMock(); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); + $router = $this->getMockBuilder(\Symfony\Component\Routing\Router::class)->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->willReturn($context); $parentRequest = Request::create('/'); @@ -116,6 +116,6 @@ class LocaleListenerTest extends TestCase private function getEvent(Request $request): RequestEvent { - return new RequestEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); + return new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php index 3aaff12316..4b076ef17d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -30,7 +30,7 @@ class ProfilerListenerTest extends TestCase { $profile = new Profile('token'); - $profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + $profiler = $this->getMockBuilder(\Symfony\Component\HttpKernel\Profiler\Profiler::class) ->disableOriginalConstructor() ->getMock(); @@ -38,17 +38,17 @@ class ProfilerListenerTest extends TestCase ->method('collect') ->willReturn($profile); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); - $masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') + $masterRequest = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class) ->disableOriginalConstructor() ->getMock(); - $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') + $subRequest = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') + $response = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Response::class) ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php index 1aaa64bc89..31cfa38477 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php @@ -32,7 +32,7 @@ class ResponseListenerTest extends TestCase $listener = new ResponseListener('UTF-8'); $this->dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); - $this->kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $this->kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); } protected function tearDown(): void diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php index 2c1e7721b4..59e63deea8 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php @@ -33,7 +33,7 @@ class RouterListenerTest extends TestCase protected function setUp(): void { - $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock(); + $this->requestStack = $this->getMockBuilder(RequestStack::class)->disableOriginalConstructor()->getMock(); } /** @@ -41,7 +41,7 @@ class RouterListenerTest extends TestCase */ public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHttpPort, $expectedHttpsPort) { - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface') + $urlMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\UrlMatcherInterface::class) ->disableOriginalConstructor() ->getMock(); $context = new RequestContext(); @@ -81,7 +81,7 @@ class RouterListenerTest extends TestCase public function testInvalidMatcher() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new RouterListener(new \stdClass(), $this->requestStack); } @@ -91,10 +91,10 @@ class RouterListenerTest extends TestCase $request = Request::create('http://localhost/'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher->expects($this->once()) ->method('matchRequest') - ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) + ->with($this->isInstanceOf(Request::class)) ->willReturn([]); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); @@ -107,10 +107,10 @@ class RouterListenerTest extends TestCase $request = Request::create('http://localhost/', 'post'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher->expects($this->any()) ->method('matchRequest') - ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) + ->with($this->isInstanceOf(Request::class)) ->willReturn([]); $context = new RequestContext(); @@ -133,12 +133,12 @@ class RouterListenerTest extends TestCase */ public function testLoggingParameter($parameter, $log, $parameters) { - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher->expects($this->once()) ->method('matchRequest') ->willReturn($parameter); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger->expects($this->once()) ->method('info') ->with($this->equalTo($log), $this->equalTo($parameters)); @@ -162,7 +162,7 @@ class RouterListenerTest extends TestCase { $requestStack = new RequestStack(); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher->expects($this->never())->method('matchRequest'); $dispatcher = new EventDispatcher(); @@ -184,7 +184,7 @@ class RouterListenerTest extends TestCase { $requestStack = new RequestStack(); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher ->expects($this->once()) ->method('matchRequest') @@ -204,12 +204,12 @@ class RouterListenerTest extends TestCase public function testRequestWithBadHost() { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $request = Request::create('http://bad host %22/'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); $listener->onKernelRequest($event); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php index fc51de252e..e4b8b2d558 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php @@ -26,7 +26,7 @@ class SurrogateListenerTest extends TestCase public function testFilterDoesNothingForSubRequests() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); @@ -40,7 +40,7 @@ class SurrogateListenerTest extends TestCase public function testFilterWhenThereIsSomeEsiIncludes() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); @@ -54,7 +54,7 @@ class SurrogateListenerTest extends TestCase public function testFilterWhenThereIsNoEsiIncludes() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $response = new Response('foo'); $listener = new SurrogateListener(new Esi()); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php index 1d9ea37977..e0a5cc69da 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php @@ -42,7 +42,7 @@ class TestSessionListenerTest extends TestCase protected function setUp(): void { - $this->listener = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener'); + $this->listener = $this->getMockForAbstractClass(\Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener::class); $this->session = $this->getSession(); $this->listener->expects($this->any()) ->method('getSession') @@ -209,7 +209,7 @@ class TestSessionListenerTest extends TestCase private function getSession() { - $mock = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session') + $mock = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class) ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php index e5447079dc..1fe4d1f2fa 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php @@ -31,7 +31,7 @@ class TranslatorListenerTest extends TestCase protected function setUp(): void { $this->translator = $this->getMockBuilder(LocaleAwareInterface::class)->getMock(); - $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $this->requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $this->listener = new TranslatorListener($this->translator, $this->requestStack); } @@ -105,7 +105,7 @@ class TranslatorListenerTest extends TestCase private function createHttpKernel() { - return $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + return $this->getMockBuilder(HttpKernelInterface::class)->getMock(); } private function createRequest($locale) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php index 7cec68143b..96b686d91b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php @@ -28,9 +28,9 @@ class ValidateRequestListenerTest extends TestCase public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps() { - $this->expectException('Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException'); + $this->expectException(\Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException::class); $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $request = new Request(); $request->setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php index df74ade154..c9af77149c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php @@ -67,7 +67,7 @@ class EsiFragmentRendererTest extends TestCase public function testRenderControllerReferenceWithoutSignerThrowsException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); $request = Request::create('/'); @@ -79,7 +79,7 @@ class EsiFragmentRendererTest extends TestCase public function testRenderAltControllerReferenceWithoutSignerThrowsException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); $request = Request::create('/'); @@ -91,7 +91,7 @@ class EsiFragmentRendererTest extends TestCase private function getInlineStrategy($called = false) { - $inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock(); + $inline = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer::class)->disableOriginalConstructor()->getMock(); if ($called) { $inline->expects($this->once())->method('render'); diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php index 15e543a214..fa011c8f29 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php @@ -25,7 +25,7 @@ class FragmentHandlerTest extends TestCase protected function setUp(): void { - $this->requestStack = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') + $this->requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class) ->disableOriginalConstructor() ->getMock() ; @@ -38,14 +38,14 @@ class FragmentHandlerTest extends TestCase public function testRenderWhenRendererDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $handler = new FragmentHandler($this->requestStack); $handler->render('/', 'foo'); } public function testRenderWithUnknownRenderer() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $handler = $this->getHandler($this->returnValue(new Response('foo'))); $handler->render('/', 'bar'); @@ -53,7 +53,7 @@ class FragmentHandlerTest extends TestCase public function testDeliverWithUnsuccessfulResponse() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Error when rendering "http://localhost/" (Status code is 404).'); $handler = $this->getHandler($this->returnValue(new Response('foo', 404))); @@ -69,7 +69,7 @@ class FragmentHandlerTest extends TestCase protected function getHandler($returnValue, $arguments = []) { - $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); + $renderer = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface::class)->getMock(); $renderer ->expects($this->any()) ->method('getName') diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php index cdef37565b..ae1cb15516 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -23,7 +23,7 @@ class HIncludeFragmentRendererTest extends TestCase { public function testRenderExceptionWhenControllerAndNoSigner() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new HIncludeFragmentRenderer(); $strategy->render(new ControllerReference('main_controller', [], []), Request::create('/')); } @@ -86,7 +86,7 @@ class HIncludeFragmentRendererTest extends TestCase */ public function testRenderWithDefaultTextLegacy() { - $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock(); + $engine = $this->getMockBuilder(\Symfony\Component\Templating\EngineInterface::class)->getMock(); $engine->expects($this->once()) ->method('exists') ->with('default') diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php index a064a76c7d..c25297dbe4 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -71,7 +71,7 @@ class InlineFragmentRendererTest extends TestCase public function testRenderExceptionNoIgnoreErrors() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock(); $dispatcher->expects($this->never())->method('dispatch'); @@ -106,7 +106,7 @@ class InlineFragmentRendererTest extends TestCase private function getKernel($returnValue) { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); $kernel ->expects($this->any()) ->method('handle') @@ -118,7 +118,7 @@ class InlineFragmentRendererTest extends TestCase public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() { - $controllerResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); + $controllerResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ControllerResolverInterface::class)->getMock(); $controllerResolver ->expects($this->once()) ->method('getController') @@ -129,7 +129,7 @@ class InlineFragmentRendererTest extends TestCase }) ; - $argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock(); + $argumentResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface::class)->getMock(); $argumentResolver ->expects($this->once()) ->method('getArguments') @@ -258,7 +258,7 @@ class InlineFragmentRendererTest extends TestCase */ private function getKernelExpectingRequest(Request $request, $strict = false) { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); $kernel ->expects($this->once()) ->method('handle') diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php index 151adb0e97..5980284afe 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php @@ -60,7 +60,7 @@ class RoutableFragmentRendererTest extends TestCase */ public function testGenerateFragmentUriWithNonScalar($controller) { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->callGenerateFragmentUriMethod($controller, Request::create('/')); } @@ -74,7 +74,7 @@ class RoutableFragmentRendererTest extends TestCase private function callGenerateFragmentUriMethod(ControllerReference $reference, Request $request, $absolute = false) { - $renderer = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer'); + $renderer = $this->getMockForAbstractClass(\Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer::class); $r = new \ReflectionObject($renderer); $m = $r->getMethod('generateFragmentUri'); $m->setAccessible(true); diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/SsiFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/SsiFragmentRendererTest.php index df30e67727..db203f91de 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/SsiFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/SsiFragmentRendererTest.php @@ -58,7 +58,7 @@ class SsiFragmentRendererTest extends TestCase public function testRenderControllerReferenceWithoutSignerThrowsException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy()); $request = Request::create('/'); @@ -70,7 +70,7 @@ class SsiFragmentRendererTest extends TestCase public function testRenderAltControllerReferenceWithoutSignerThrowsException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy()); $request = Request::create('/'); @@ -82,7 +82,7 @@ class SsiFragmentRendererTest extends TestCase private function getInlineStrategy($called = false) { - $inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock(); + $inline = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer::class)->disableOriginalConstructor()->getMock(); if ($called) { $inline->expects($this->once())->method('render'); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php index cdf729e331..5246721a64 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php @@ -155,7 +155,7 @@ class EsiTest extends TestCase public function testProcessWhenNoSrcInAnEsi() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $esi = new Esi(); $request = Request::create('/'); @@ -193,7 +193,7 @@ class EsiTest extends TestCase public function testHandleWhenResponseIsNot200() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $esi = new Esi(); $response = new Response('foo'); $response->setStatusCode(404); @@ -222,7 +222,7 @@ class EsiTest extends TestCase protected function getCache($request, $response) { - $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); + $cache = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->willReturn($request) diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 6ad64e4791..932f46c6ef 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -25,7 +25,7 @@ class HttpCacheTest extends HttpCacheTestCase { public function testTerminateDelegatesTerminationOnlyForTerminableInterface() { - $storeMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpCache\\StoreInterface') + $storeMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\StoreInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -37,7 +37,7 @@ class HttpCacheTest extends HttpCacheTestCase $this->assertFalse($kernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface'); // implements TerminableInterface - $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Kernel') + $kernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class) ->disableOriginalConstructor() ->setMethods(['terminate', 'registerBundles', 'registerContainerConfiguration']) ->getMock(); @@ -1488,8 +1488,8 @@ class HttpCacheTest extends HttpCacheTestCase public function testUsesOriginalRequestForSurrogate() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $store = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\StoreInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $store = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\StoreInterface::class)->getMock(); $kernel ->expects($this->exactly(2)) diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php index 3d68052cdc..23c7410a28 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php @@ -122,7 +122,7 @@ class SsiTest extends TestCase public function testProcessWhenNoSrcInAnSsi() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $ssi = new Ssi(); $request = Request::create('/'); @@ -160,7 +160,7 @@ class SsiTest extends TestCase public function testHandleWhenResponseIsNot200() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $ssi = new Ssi(); $response = new Response('foo'); $response->setStatusCode(404); @@ -189,7 +189,7 @@ class SsiTest extends TestCase protected function getCache($request, $response) { - $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); + $cache = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->willReturn($request) diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php index fc1ef64663..da1f649127 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php @@ -157,7 +157,7 @@ class StoreTest extends TestCase $response = $this->store->lookup($this->request); $this->assertNotNull($response); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); + $this->assertInstanceOf(Response::class, $response); } public function testDoesNotFindAnEntryWithLookupWhenNoneExists() @@ -206,7 +206,7 @@ class StoreTest extends TestCase $this->storeSimpleEntry(); $this->store->invalidate($this->request); $response = $this->store->lookup($this->request); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); + $this->assertInstanceOf(Response::class, $response); $this->assertFalse($response->isFresh()); } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php index 4d4fe5ae72..eab6c5221c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php @@ -30,10 +30,10 @@ class HttpKernelBrowserTest extends TestCase $client->request('GET', '/'); $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Request', $client->getRequest()); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $client->getResponse()); + $this->assertInstanceOf(\Symfony\Component\BrowserKit\Request::class, $client->getInternalRequest()); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\Request::class, $client->getRequest()); + $this->assertInstanceOf(\Symfony\Component\BrowserKit\Response::class, $client->getInternalResponse()); + $this->assertInstanceOf(Response::class, $client->getResponse()); $client->request('GET', 'http://www.example.com/'); $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); @@ -148,7 +148,7 @@ class HttpKernelBrowserTest extends TestCase $client = new HttpKernelBrowser($kernel); $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') + ->getMockBuilder(UploadedFile::class) ->setConstructorArgs([$source, 'original', 'mime/original', \UPLOAD_ERR_OK, true]) ->setMethods(['getSize', 'getClientSize']) ->getMock() diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 7a5b0b8c60..5c954261b6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -31,7 +31,7 @@ class HttpKernelTest extends TestCase { public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }); $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); @@ -39,7 +39,7 @@ class HttpKernelTest extends TestCase public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }); $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false); @@ -156,7 +156,7 @@ class HttpKernelTest extends TestCase public function testHandleWhenNoControllerIsFound() { - $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $dispatcher = new EventDispatcher(); $kernel = $this->getHttpKernel($dispatcher, false); @@ -303,7 +303,7 @@ class HttpKernelTest extends TestCase { $request = new Request(); - $stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(['push', 'pop'])->getMock(); + $stack = $this->getMockBuilder(RequestStack::class)->setMethods(['push', 'pop'])->getMock(); $stack->expects($this->once())->method('push')->with($this->equalTo($request)); $stack->expects($this->once())->method('pop'); @@ -315,7 +315,7 @@ class HttpKernelTest extends TestCase public function testInconsistentClientIpsOnMasterRequests() { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $request = new Request(); $request->setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); $request->server->set('REMOTE_ADDR', '1.1.1.1'); diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 18974a720b..570e6f0298 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -77,7 +77,7 @@ class KernelTest extends TestCase public function testClassNameValidityGetter() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The environment "test.env" contains invalid characters, it can only contain characters allowed in PHP class names.'); // We check the classname that will be generated by using a $env that // contains invalid characters. @@ -125,7 +125,7 @@ class KernelTest extends TestCase public function testBootSetsTheContainerToTheBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); $bundle->expects($this->once()) ->method('setContainer'); @@ -167,7 +167,7 @@ class KernelTest extends TestCase public function testShutdownCallsShutdownOnAllBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); $bundle->expects($this->once()) ->method('shutdown'); @@ -179,7 +179,7 @@ class KernelTest extends TestCase public function testShutdownGivesNullContainerToAllBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); $bundle->expects($this->exactly(2)) ->method('setContainer') ->withConsecutive( @@ -202,7 +202,7 @@ class KernelTest extends TestCase $catch = true; $request = new Request(); - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') + $httpKernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernel::class) ->disableOriginalConstructor() ->getMock(); $httpKernelMock @@ -224,7 +224,7 @@ class KernelTest extends TestCase $catch = true; $request = new Request(); - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') + $httpKernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernel::class) ->disableOriginalConstructor() ->getMock(); @@ -381,25 +381,25 @@ EOF public function testLocateResourceThrowsExceptionWhenNameIsNotValid() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->getKernel()->locateResource('Foo'); } public function testLocateResourceThrowsExceptionWhenNameIsUnsafe() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->getKernel()->locateResource('@FooBundle/../bar'); } public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->getKernel()->locateResource('@FooBundle/config/routing.xml'); } public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->once()) @@ -501,7 +501,7 @@ EOF public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWithTheSameName() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Trying to register two bundles with the same name "DuplicateName"'); $fooBundle = $this->getBundle(__DIR__.'/Fixtures/FooBundle', null, 'FooBundle', 'DuplicateName'); $barBundle = $this->getBundle(__DIR__.'/Fixtures/BarBundle', null, 'BarBundle', 'DuplicateName'); @@ -547,7 +547,7 @@ EOF $this->assertFalse($httpKernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface'); // implements TerminableInterface - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') + $httpKernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernel::class) ->disableOriginalConstructor() ->setMethods(['terminate']) ->getMock(); @@ -690,7 +690,7 @@ EOF protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null): BundleInterface { $bundle = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface') + ->getMockBuilder(BundleInterface::class) ->setMethods(['getPath', 'getName']) ->disableOriginalConstructor() ; diff --git a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php index 607ab31cb8..fb2b43cc82 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php @@ -109,19 +109,19 @@ class LoggerTest extends TestCase public function testThrowsOnInvalidLevel() { - $this->expectException('Psr\Log\InvalidArgumentException'); + $this->expectException(\Psr\Log\InvalidArgumentException::class); $this->logger->log('invalid level', 'Foo'); } public function testThrowsOnInvalidMinLevel() { - $this->expectException('Psr\Log\InvalidArgumentException'); + $this->expectException(\Psr\Log\InvalidArgumentException::class); new Logger('invalid'); } public function testInvalidOutput() { - $this->expectException('Psr\Log\InvalidArgumentException'); + $this->expectException(\Psr\Log\InvalidArgumentException::class); new Logger(LogLevel::DEBUG, '/'); } diff --git a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php index 70db01e7b7..9b55057818 100644 --- a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php +++ b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php @@ -19,20 +19,20 @@ class CollatorTest extends AbstractCollatorTest { public function testConstructorWithUnsupportedLocale() { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); $this->getCollator('pt_BR'); } public function testCompare() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(MethodNotImplementedException::class); $collator = $this->getCollator('en'); $collator->compare('a', 'b'); } public function testGetAttribute() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(MethodNotImplementedException::class); $collator = $this->getCollator('en'); $collator->getAttribute(Collator::NUMERIC_COLLATION); } @@ -77,14 +77,14 @@ class CollatorTest extends AbstractCollatorTest public function testSetAttribute() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(MethodNotImplementedException::class); $collator = $this->getCollator('en'); $collator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON); } public function testSetStrength() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(MethodNotImplementedException::class); $collator = $this->getCollator('en'); $collator->setStrength(Collator::PRIMARY); } diff --git a/src/Symfony/Component/Intl/Tests/CountriesTest.php b/src/Symfony/Component/Intl/Tests/CountriesTest.php index a6d38c7c8a..995072b0a4 100644 --- a/src/Symfony/Component/Intl/Tests/CountriesTest.php +++ b/src/Symfony/Component/Intl/Tests/CountriesTest.php @@ -592,7 +592,7 @@ class CountriesTest extends ResourceBundleTestCase public function testGetNameWithInvalidCountryCode() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(MissingResourceException::class); Countries::getName('foo'); } diff --git a/src/Symfony/Component/Intl/Tests/CurrenciesTest.php b/src/Symfony/Component/Intl/Tests/CurrenciesTest.php index 3d1f7ea7f4..3edd7daa6b 100644 --- a/src/Symfony/Component/Intl/Tests/CurrenciesTest.php +++ b/src/Symfony/Component/Intl/Tests/CurrenciesTest.php @@ -725,7 +725,7 @@ class CurrenciesTest extends ResourceBundleTestCase */ public function testGetNumericCodeFailsIfNoNumericEquivalent($currency) { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); Currencies::getNumericCode($currency); } @@ -770,13 +770,13 @@ class CurrenciesTest extends ResourceBundleTestCase */ public function testForNumericCodeFailsIfInvalidNumericCode($currency) { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); Currencies::forNumericCode($currency); } public function testGetNameWithInvalidCurrencyCode() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); Currencies::getName('foo'); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php index 3624295353..ec159fb786 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php @@ -64,7 +64,7 @@ class BundleEntryReaderTest extends TestCase protected function setUp(): void { - $this->readerImpl = $this->getMockBuilder('Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface')->getMock(); + $this->readerImpl = $this->getMockBuilder(\Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface::class)->getMock(); $this->reader = new BundleEntryReader($this->readerImpl); } @@ -103,7 +103,7 @@ class BundleEntryReaderTest extends TestCase public function testReadNonExistingEntry() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'root') @@ -127,7 +127,7 @@ class BundleEntryReaderTest extends TestCase public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') @@ -154,7 +154,7 @@ class BundleEntryReaderTest extends TestCase public function testDontFallbackIfLocaleDoesNotExistAndFallbackDisabled() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') @@ -279,7 +279,7 @@ class BundleEntryReaderTest extends TestCase public function testFailIfEntryFoundNeitherInParentNorChild() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); $this->readerImpl ->method('read') ->withConsecutive( 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 2272139616..2f04e68024 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php @@ -66,7 +66,7 @@ class IntlBundleReaderTest extends TestCase // "mo" = "ro_MD" -> "ro" $data = $this->reader->read(__DIR__.'/Fixtures/res', 'mo'); - $this->assertInstanceOf('\ArrayAccess', $data); + $this->assertInstanceOf(\ArrayAccess::class, $data); $this->assertSame('Bam', $data['Baz'], 'data from the aliased locale can be accessed'); $this->assertArrayNotHasKey('Foo', $data); $this->assertNull($data['Foo']); @@ -75,19 +75,19 @@ class IntlBundleReaderTest extends TestCase public function testReadFailsIfNonExistingLocale() { - $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException'); + $this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class); $this->reader->read(__DIR__.'/Fixtures/res', 'foo'); } public function testReadFailsIfNonExistingFallbackLocale() { - $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException'); + $this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class); $this->reader->read(__DIR__.'/Fixtures/res', 'ro_AT'); } public function testReadFailsIfNonExistingDirectory() { - $this->expectException('Symfony\Component\Intl\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class); $this->reader->read(__DIR__.'/foo', 'ro'); } } 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 faf129cd4d..3fdef2b664 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php @@ -40,31 +40,31 @@ class JsonBundleReaderTest extends TestCase public function testReadFailsIfNonExistingLocale() { - $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException'); + $this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class); $this->reader->read(__DIR__.'/Fixtures/json', 'foo'); } public function testReadFailsIfNonExistingDirectory() { - $this->expectException('Symfony\Component\Intl\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class); $this->reader->read(__DIR__.'/foo', 'en'); } public function testReadFailsIfNotAFile() { - $this->expectException('Symfony\Component\Intl\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class); $this->reader->read(__DIR__.'/Fixtures/NotAFile', 'en'); } public function testReadFailsIfInvalidJson() { - $this->expectException('Symfony\Component\Intl\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class); $this->reader->read(__DIR__.'/Fixtures/json', 'en_Invalid'); } public function testReaderDoesNotBreakOutOfGivenPath() { - $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException'); + $this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class); $this->reader->read(__DIR__.'/Fixtures/json', '../invalid_directory/en'); } } 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 0cc1001651..f4e020f075 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php @@ -40,25 +40,25 @@ class PhpBundleReaderTest extends TestCase public function testReadFailsIfNonExistingLocale() { - $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException'); + $this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class); $this->reader->read(__DIR__.'/Fixtures/php', 'foo'); } public function testReadFailsIfNonExistingDirectory() { - $this->expectException('Symfony\Component\Intl\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class); $this->reader->read(__DIR__.'/foo', 'en'); } public function testReadFailsIfNotAFile() { - $this->expectException('Symfony\Component\Intl\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Intl\Exception\RuntimeException::class); $this->reader->read(__DIR__.'/Fixtures/NotAFile', 'en'); } public function testReaderDoesNotBreakOutOfGivenPath() { - $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException'); + $this->expectException(\Symfony\Component\Intl\Exception\ResourceBundleNotFoundException::class); $this->reader->read(__DIR__.'/Fixtures/php', '../invalid_directory/en'); } } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php index aadf0c5f05..2cd798b095 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php @@ -758,7 +758,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest */ public function testGetNumericCodeFailsIfNoNumericEquivalent($currency) { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); $this->dataProvider->getNumericCode($currency); } @@ -803,7 +803,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest */ public function testForNumericCodeFailsIfInvalidNumericCode($currency) { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); $this->dataProvider->forNumericCode($currency); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php index 71cea5d45e..faf2b0bfea 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php @@ -924,7 +924,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest */ public function testGetAlpha3CodeFailsIfNoAlpha3Equivalent($currency) { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); $this->dataProvider->getAlpha3Code($currency); } } diff --git a/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php b/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php index f653503dbf..3709ce17cd 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php @@ -54,7 +54,7 @@ class RingBufferTest extends TestCase public function testReadNonExistingFails() { - $this->expectException('Symfony\Component\Intl\Exception\OutOfBoundsException'); + $this->expectException(\Symfony\Component\Intl\Exception\OutOfBoundsException::class); $this->buffer['foo']; } @@ -72,7 +72,7 @@ class RingBufferTest extends TestCase public function testReadOverwrittenFails() { - $this->expectException('Symfony\Component\Intl\Exception\OutOfBoundsException'); + $this->expectException(\Symfony\Component\Intl\Exception\OutOfBoundsException::class); $this->buffer[0] = 'foo'; $this->buffer['bar'] = 'baz'; $this->buffer[2] = 'bam'; diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 40b0efc227..db61df14b9 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -36,7 +36,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest public function testConstructorWithUnsupportedLocale() { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); $this->getDateFormatter('pt_BR', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); } @@ -66,7 +66,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest try { $formatter->format($localtime); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException', $e); + $this->assertInstanceOf(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class, $e); $this->assertStringEndsWith('Only integer Unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); } @@ -74,7 +74,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest public function testFormatWithUnimplementedChars() { - $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class); $pattern = 'Y'; $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern); $formatter->format(0); @@ -82,7 +82,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest public function testFormatWithNonIntegerTimestamp() { - $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class); $formatter = $this->getDefaultDateFormatter(); $formatter->format([]); } @@ -107,14 +107,14 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest public function testLocaltime() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $formatter = $this->getDefaultDateFormatter(); $formatter->localtime('Wednesday, December 31, 1969 4:00:00 PM PT'); } public function testParseWithNotNullPositionValue() { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException::class); $position = 0; $formatter = $this->getDefaultDateFormatter('y'); $this->assertSame(0, $formatter->parse('1970', $position)); @@ -122,27 +122,27 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest public function testSetCalendar() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $formatter = $this->getDefaultDateFormatter(); $formatter->setCalendar(IntlDateFormatter::GREGORIAN); } public function testSetLenient() { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); $formatter = $this->getDefaultDateFormatter(); $formatter->setLenient(true); } public function testFormatWithGmtTimeZoneAndMinutesOffset() { - $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class); parent::testFormatWithGmtTimeZoneAndMinutesOffset(); } public function testFormatWithNonStandardTimezone() { - $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class); parent::testFormatWithNonStandardTimezone(); } diff --git a/src/Symfony/Component/Intl/Tests/IntlTest.php b/src/Symfony/Component/Intl/Tests/IntlTest.php index 5c91a84ca2..d09e63f699 100644 --- a/src/Symfony/Component/Intl/Tests/IntlTest.php +++ b/src/Symfony/Component/Intl/Tests/IntlTest.php @@ -45,7 +45,7 @@ class IntlTest extends TestCase */ public function testGetCurrencyBundleCreatesTheCurrencyBundle() { - $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\CurrencyBundleInterface', Intl::getCurrencyBundle()); + $this->assertInstanceOf(\Symfony\Component\Intl\ResourceBundle\CurrencyBundleInterface::class, Intl::getCurrencyBundle()); } /** @@ -53,7 +53,7 @@ class IntlTest extends TestCase */ public function testGetLanguageBundleCreatesTheLanguageBundle() { - $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LanguageBundleInterface', Intl::getLanguageBundle()); + $this->assertInstanceOf(\Symfony\Component\Intl\ResourceBundle\LanguageBundleInterface::class, Intl::getLanguageBundle()); } /** @@ -61,7 +61,7 @@ class IntlTest extends TestCase */ public function testGetLocaleBundleCreatesTheLocaleBundle() { - $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface', Intl::getLocaleBundle()); + $this->assertInstanceOf(\Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface::class, Intl::getLocaleBundle()); } /** @@ -69,7 +69,7 @@ class IntlTest extends TestCase */ public function testGetRegionBundleCreatesTheRegionBundle() { - $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\RegionBundleInterface', Intl::getRegionBundle()); + $this->assertInstanceOf(\Symfony\Component\Intl\ResourceBundle\RegionBundleInterface::class, Intl::getRegionBundle()); } public function testGetIcuVersionReadsTheVersionOfInstalledIcuLibrary() diff --git a/src/Symfony/Component/Intl/Tests/LanguagesTest.php b/src/Symfony/Component/Intl/Tests/LanguagesTest.php index 1a44190691..9dfaf72609 100644 --- a/src/Symfony/Component/Intl/Tests/LanguagesTest.php +++ b/src/Symfony/Component/Intl/Tests/LanguagesTest.php @@ -1690,13 +1690,13 @@ class LanguagesTest extends ResourceBundleTestCase */ public function testGetAlpha3CodeFailsIfNoAlpha3Equivalent($language) { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(MissingResourceException::class); Languages::getAlpha3Code($language); } public function testGetNameWithInvalidLanguageCode() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(MissingResourceException::class); Languages::getName('foo'); } @@ -1740,7 +1740,7 @@ class LanguagesTest extends ResourceBundleTestCase */ public function testGetAlpha2CodeFailsIfNoAlpha2Equivalent($language) { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(MissingResourceException::class); Languages::getAlpha2Code($language); } diff --git a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php index a2c3346a8d..cb21146953 100644 --- a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php +++ b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php @@ -17,7 +17,7 @@ class LocaleTest extends AbstractLocaleTest { public function testAcceptFromHttp() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('acceptFromHttp', 'pt-br,en-us;q=0.7,en;q=0.5'); } @@ -34,7 +34,7 @@ class LocaleTest extends AbstractLocaleTest public function testComposeLocale() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $subtags = [ 'language' => 'pt', 'script' => 'Latn', @@ -45,73 +45,73 @@ class LocaleTest extends AbstractLocaleTest public function testFilterMatches() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('filterMatches', 'pt-BR', 'pt-BR'); } public function testGetAllVariants() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getAllVariants', 'pt_BR_Latn'); } public function testGetDisplayLanguage() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getDisplayLanguage', 'pt-Latn-BR', 'en'); } public function testGetDisplayName() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getDisplayName', 'pt-Latn-BR', 'en'); } public function testGetDisplayRegion() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getDisplayRegion', 'pt-Latn-BR', 'en'); } public function testGetDisplayScript() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getDisplayScript', 'pt-Latn-BR', 'en'); } public function testGetDisplayVariant() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getDisplayVariant', 'pt-Latn-BR', 'en'); } public function testGetKeywords() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getKeywords', 'pt-BR@currency=BRL'); } public function testGetPrimaryLanguage() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getPrimaryLanguage', 'pt-Latn-BR'); } public function testGetRegion() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getRegion', 'pt-Latn-BR'); } public function testGetScript() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('getScript', 'pt-Latn-BR'); } public function testLookup() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $langtag = [ 'pt-Latn-BR', 'pt-BR', @@ -121,13 +121,13 @@ class LocaleTest extends AbstractLocaleTest public function testParseLocale() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('parseLocale', 'pt-Latn-BR'); } public function testSetDefault() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $this->call('setDefault', 'pt_BR'); } diff --git a/src/Symfony/Component/Intl/Tests/LocalesTest.php b/src/Symfony/Component/Intl/Tests/LocalesTest.php index ff53e72b52..c351e7ac82 100644 --- a/src/Symfony/Component/Intl/Tests/LocalesTest.php +++ b/src/Symfony/Component/Intl/Tests/LocalesTest.php @@ -86,7 +86,7 @@ class LocalesTest extends ResourceBundleTestCase public function testGetNameWithInvalidLocale() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); Locales::getName('foo'); } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 7de8e11d7a..44a7d27269 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -614,7 +614,7 @@ abstract class AbstractNumberFormatterTest extends TestCase $decimalFormatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $currencyFormatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); - $r = new \ReflectionProperty('Symfony\Component\Intl\NumberFormatter\NumberFormatter', 'enSymbols'); + $r = new \ReflectionProperty(NumberFormatter::class, 'enSymbols'); $r->setAccessible(true); $expected = $r->getValue(); @@ -631,7 +631,7 @@ abstract class AbstractNumberFormatterTest extends TestCase $decimalFormatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $currencyFormatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); - $r = new \ReflectionProperty('Symfony\Component\Intl\NumberFormatter\NumberFormatter', 'enTextAttributes'); + $r = new \ReflectionProperty(NumberFormatter::class, 'enTextAttributes'); $r->setAccessible(true); $expected = $r->getValue(); diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php index 9e1f26d489..f6190db76e 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php @@ -22,32 +22,32 @@ class NumberFormatterTest extends AbstractNumberFormatterTest { public function testConstructorWithUnsupportedLocale() { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); $this->getNumberFormatter('pt_BR'); } public function testConstructorWithUnsupportedStyle() { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); $this->getNumberFormatter('en', NumberFormatter::PATTERN_DECIMAL); } public function testConstructorWithPatternDifferentThanNull() { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException::class); $this->getNumberFormatter('en', NumberFormatter::DECIMAL, ''); } public function testSetAttributeWithUnsupportedAttribute() { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::LENIENT_PARSE, null); } public function testSetAttributeInvalidRoundingMode() { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, -1); } @@ -65,7 +65,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest public function testFormatWithCurrencyStyle() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); parent::testFormatWithCurrencyStyle(); } @@ -74,7 +74,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest */ public function testFormatTypeInt32($formatter, $value, $expected, $message = '') { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); parent::testFormatTypeInt32($formatter, $value, $expected, $message); } @@ -83,7 +83,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest */ public function testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message = '') { - $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class); parent::testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message); } @@ -92,7 +92,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest */ public function testFormatTypeInt64($formatter, $value, $expected) { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); parent::testFormatTypeInt64($formatter, $value, $expected); } @@ -101,7 +101,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest */ public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected) { - $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class); parent::testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected); } @@ -110,7 +110,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest */ public function testFormatTypeDouble($formatter, $value, $expected) { - $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException::class); parent::testFormatTypeDouble($formatter, $value, $expected); } @@ -119,13 +119,13 @@ class NumberFormatterTest extends AbstractNumberFormatterTest */ public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected) { - $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\NotImplementedException::class); parent::testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected); } public function testGetPattern() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->getPattern(); } @@ -138,28 +138,28 @@ class NumberFormatterTest extends AbstractNumberFormatterTest public function testParseCurrency() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->parseCurrency(null, $currency); } public function testSetPattern() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setPattern(null); } public function testSetSymbol() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setSymbol(null, null); } public function testSetTextAttribute() { - $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException'); + $this->expectException(\Symfony\Component\Intl\Exception\MethodNotImplementedException::class); $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); $formatter->setTextAttribute(null, null); } diff --git a/src/Symfony/Component/Intl/Tests/ScriptsTest.php b/src/Symfony/Component/Intl/Tests/ScriptsTest.php index b9c2bf7e62..62981299ad 100644 --- a/src/Symfony/Component/Intl/Tests/ScriptsTest.php +++ b/src/Symfony/Component/Intl/Tests/ScriptsTest.php @@ -280,7 +280,7 @@ class ScriptsTest extends ResourceBundleTestCase public function testGetNameWithInvalidScriptCode() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(\Symfony\Component\Intl\Exception\MissingResourceException::class); Scripts::getName('foo'); } diff --git a/src/Symfony/Component/Intl/Tests/TimezonesTest.php b/src/Symfony/Component/Intl/Tests/TimezonesTest.php index c438d32eaa..f02fabe8e6 100644 --- a/src/Symfony/Component/Intl/Tests/TimezonesTest.php +++ b/src/Symfony/Component/Intl/Tests/TimezonesTest.php @@ -529,13 +529,13 @@ class TimezonesTest extends ResourceBundleTestCase public function testGetNameWithInvalidTimezone() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(MissingResourceException::class); Timezones::getName('foo'); } public function testGetNameWithAliasTimezone() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(MissingResourceException::class); Timezones::getName('US/Pacific'); // alias in icu (not compiled), name unavailable in php } @@ -559,7 +559,7 @@ class TimezonesTest extends ResourceBundleTestCase public function testGetRawOffsetWithUnknownTimezone() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('Unknown or bad timezone (foobar)'); Timezones::getRawOffset('foobar'); } @@ -591,20 +591,20 @@ class TimezonesTest extends ResourceBundleTestCase public function testForCountryCodeWithUnknownCountry() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(MissingResourceException::class); Timezones::forCountryCode('foobar'); } public function testForCountryCodeWithWrongCountryCode() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(MissingResourceException::class); $this->expectExceptionMessage('Country codes must be in uppercase, but "nl" was passed. Try with "NL" country code instead.'); Timezones::forCountryCode('nl'); } public function testGetCountryCodeWithUnknownTimezone() { - $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException'); + $this->expectException(MissingResourceException::class); Timezones::getCountryCode('foobar'); } diff --git a/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php b/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php index 5868174332..21493ae4f0 100644 --- a/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php +++ b/src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php @@ -56,7 +56,7 @@ class GitRepositoryTest extends TestCase $this->assertSame(self::REPO_URL, $git->getUrl()); $this->assertMatchesRegularExpression('#^[0-9a-z]{40}$#', $git->getLastCommitHash()); $this->assertNotEmpty($git->getLastAuthor()); - $this->assertInstanceOf('DateTime', $git->getLastAuthoredDate()); + $this->assertInstanceOf(\DateTime::class, $git->getLastAuthoredDate()); $this->assertStringMatchesFormat('v%s', $git->getLastTag()); $this->assertStringMatchesFormat('v3%s', $git->getLastTag(function ($tag) { return 0 === strpos($tag, 'v3'); })); } diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php index d571c10ce0..ffd938295d 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php @@ -19,7 +19,7 @@ class EntryManagerTest extends TestCase { public function testMove() { - $this->expectException('Symfony\Component\Ldap\Exception\LdapException'); + $this->expectException(\Symfony\Component\Ldap\Exception\LdapException::class); $this->expectExceptionMessage('Entry "$$$$$$" malformed, could not parse RDN.'); $connection = $this->createMock(Connection::class); $connection @@ -33,7 +33,7 @@ class EntryManagerTest extends TestCase public function testGetResources() { - $this->expectException('Symfony\Component\Ldap\Exception\NotBoundException'); + $this->expectException(\Symfony\Component\Ldap\Exception\NotBoundException::class); $this->expectExceptionMessage('Query execution is not possible without binding the connection first.'); $connection = $this->getMockBuilder(Connection::class)->getMock(); $connection diff --git a/src/Symfony/Component/Lock/Tests/LockTest.php b/src/Symfony/Component/Lock/Tests/LockTest.php index acf0a33977..5c218e5ea7 100644 --- a/src/Symfony/Component/Lock/Tests/LockTest.php +++ b/src/Symfony/Component/Lock/Tests/LockTest.php @@ -278,7 +278,7 @@ class LockTest extends TestCase public function testReleaseThrowsExceptionWhenDeletionFail() { - $this->expectException('Symfony\Component\Lock\Exception\LockReleasingException'); + $this->expectException(\Symfony\Component\Lock\Exception\LockReleasingException::class); $key = new Key(uniqid(__METHOD__, true)); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock(); $lock = new Lock($key, $store, 10); @@ -299,7 +299,7 @@ class LockTest extends TestCase public function testReleaseThrowsExceptionIfNotWellDeleted() { - $this->expectException('Symfony\Component\Lock\Exception\LockReleasingException'); + $this->expectException(\Symfony\Component\Lock\Exception\LockReleasingException::class); $key = new Key(uniqid(__METHOD__, true)); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock(); $lock = new Lock($key, $store, 10); @@ -320,7 +320,7 @@ class LockTest extends TestCase public function testReleaseThrowsAndLog() { - $this->expectException('Symfony\Component\Lock\Exception\LockReleasingException'); + $this->expectException(\Symfony\Component\Lock\Exception\LockReleasingException::class); $key = new Key(uniqid(__METHOD__, true)); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock(); $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); diff --git a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php index 98240e8193..7d99826b3c 100644 --- a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php @@ -71,7 +71,7 @@ class CombinedStoreTest extends AbstractStoreTest public function testSaveThrowsExceptionOnFailure() { - $this->expectException('Symfony\Component\Lock\Exception\LockConflictedException'); + $this->expectException(LockConflictedException::class); $key = new Key(uniqid(__METHOD__, true)); $this->store1 @@ -166,7 +166,7 @@ class CombinedStoreTest extends AbstractStoreTest public function testputOffExpirationThrowsExceptionOnFailure() { - $this->expectException('Symfony\Component\Lock\Exception\LockConflictedException'); + $this->expectException(LockConflictedException::class); $key = new Key(uniqid(__METHOD__, true)); $ttl = random_int(1, 10); diff --git a/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php index 1b1b498358..463ddc1b75 100644 --- a/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php @@ -32,7 +32,7 @@ class FlockStoreTest extends AbstractStoreTest public function testConstructWhenRepositoryDoesNotExist() { - $this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Lock\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The directory "/a/b/c/d/e" is not writable.'); if (!getenv('USER') || 'root' === getenv('USER')) { $this->markTestSkipped('This test will fail if run under superuser'); @@ -43,7 +43,7 @@ class FlockStoreTest extends AbstractStoreTest public function testConstructWhenRepositoryIsNotWriteable() { - $this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Lock\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The directory "/" is not writable.'); if (!getenv('USER') || 'root' === getenv('USER')) { $this->markTestSkipped('This test will fail if run under superuser'); diff --git a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php index 56b488af33..caf62353cd 100644 --- a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php @@ -63,7 +63,7 @@ class MemcachedStoreTest extends AbstractStoreTest public function testInvalidTtl() { - $this->expectException('Symfony\Component\Lock\Exception\InvalidTtlException'); + $this->expectException(\Symfony\Component\Lock\Exception\InvalidTtlException::class); $store = $this->getStore(); $store->putOffExpiration(new Key('toto'), 0.1); } diff --git a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php index 800397d153..02cc3461cb 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php @@ -62,14 +62,14 @@ class PdoStoreTest extends AbstractStoreTest public function testInvalidTtl() { - $this->expectException('Symfony\Component\Lock\Exception\InvalidTtlException'); + $this->expectException(\Symfony\Component\Lock\Exception\InvalidTtlException::class); $store = $this->getStore(); $store->putOffExpiration(new Key('toto'), 0.1); } public function testInvalidTtlConstruct() { - $this->expectException('Symfony\Component\Lock\Exception\InvalidTtlException'); + $this->expectException(\Symfony\Component\Lock\Exception\InvalidTtlException::class); return new PdoStore('sqlite:'.self::$dbFile, [], 0.1, 0.1); } diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php index 075cf70344..d5074a3eb2 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisArrayStoreTest.php @@ -21,7 +21,7 @@ class RedisArrayStoreTest extends AbstractRedisStoreTest { public static function setUpBeforeClass(): void { - if (!class_exists('RedisArray')) { + if (!class_exists(\RedisArray::class)) { self::markTestSkipped('The RedisArray class is required.'); } try { diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php index 2704d9822b..a6f2107fbd 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisClusterStoreTest.php @@ -21,7 +21,7 @@ class RedisClusterStoreTest extends AbstractRedisStoreTest { public static function setUpBeforeClass(): void { - if (!class_exists('RedisCluster')) { + if (!class_exists(\RedisCluster::class)) { self::markTestSkipped('The RedisCluster class is required.'); } if (!getenv('REDIS_CLUSTER_HOSTS')) { diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php index f6b15e64c5..cc0b02afcf 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php @@ -40,7 +40,7 @@ class RedisStoreTest extends AbstractRedisStoreTest public function testInvalidTtl() { - $this->expectException('Symfony\Component\Lock\Exception\InvalidTtlException'); + $this->expectException(\Symfony\Component\Lock\Exception\InvalidTtlException::class); new RedisStore($this->getRedisConnection(), -1); } } diff --git a/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/SocketStreamTest.php b/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/SocketStreamTest.php index a67a1629d0..33e939d9b6 100644 --- a/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/SocketStreamTest.php +++ b/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/SocketStreamTest.php @@ -18,7 +18,7 @@ class SocketStreamTest extends TestCase { public function testSocketErrorNoConnection() { - $this->expectException('Symfony\Component\Mailer\Exception\TransportException'); + $this->expectException(\Symfony\Component\Mailer\Exception\TransportException::class); $this->expectExceptionMessageMatches('/Connection refused|unable to connect/'); $s = new SocketStream(); $s->setTimeout(0.1); @@ -28,7 +28,7 @@ class SocketStreamTest extends TestCase public function testSocketErrorBeforeConnectError() { - $this->expectException('Symfony\Component\Mailer\Exception\TransportException'); + $this->expectException(\Symfony\Component\Mailer\Exception\TransportException::class); $this->expectExceptionMessageMatches('/no valid certs found cafile stream|Unable to find the socket transport "ssl"/'); $s = new SocketStream(); $s->setStreamOptions([ diff --git a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php index 1213fc567c..6d1503521b 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php @@ -141,7 +141,7 @@ TXT public function testExceptionOnUnknownBusArgument() { - $this->expectException('Symfony\Component\Console\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class); $this->expectExceptionMessage('Bus "unknown_bus" does not exist. Known buses are "command_bus", "query_bus".'); $command = new DebugCommand(['command_bus' => [], 'query_bus' => []]); diff --git a/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php index edc28f5ea8..2e4d9368b9 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php @@ -71,7 +71,7 @@ class SetupTransportsCommandTest extends TestCase public function testReceiverNameArgumentNotFound() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('The "not_found" transport does not exist.'); // mock a service locator /** @var MockObject|ServiceLocator $serviceLocator */ diff --git a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php index a0956ec0f8..b3c35c7770 100644 --- a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php +++ b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php @@ -155,7 +155,7 @@ class MessengerPassTest extends TestCase public function testProcessTagWithUnknownBus() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler": bus "unknown_bus" specified on the tag "messenger.message_handler" does not exist (known ones are: "command_bus").'); $container = $this->getContainerBuilder($commandBusId = 'command_bus'); @@ -227,7 +227,7 @@ class MessengerPassTest extends TestCase public function testThrowsExceptionIfTheHandlerClassDoesNotExist() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid service "NonExistentHandlerClass": class "NonExistentHandlerClass" does not exist.'); $container = $this->getContainerBuilder(); $container->register('message_bus', MessageBusInterface::class)->addTag('messenger.bus'); @@ -241,7 +241,7 @@ class MessengerPassTest extends TestCase public function testThrowsExceptionIfTheHandlerMethodDoesNotExist() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerMappingWithNonExistentMethod": method "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerMappingWithNonExistentMethod::dummyMethod()" does not exist.'); $container = $this->getContainerBuilder(); $container->register('message_bus', MessageBusInterface::class)->addTag('messenger.bus'); @@ -371,7 +371,7 @@ class MessengerPassTest extends TestCase public function testItThrowsAnExceptionOnUnknownBus() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid configuration returned by method "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerOnUndefinedBus::getHandledMessages()" for message "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage": bus "some_undefined_bus" does not exist.'); $container = $this->getContainerBuilder(); $container @@ -384,7 +384,7 @@ class MessengerPassTest extends TestCase public function testUndefinedMessageClassForHandler() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandler": class or interface "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessage" used as argument type in method "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandler::__invoke()" not found.'); $container = $this->getContainerBuilder(); $container @@ -397,7 +397,7 @@ class MessengerPassTest extends TestCase public function testUndefinedMessageClassForHandlerImplementingMessageHandlerInterface() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaHandlerInterface": class or interface "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessage" used as argument type in method "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaHandlerInterface::__invoke()" not found.'); $container = $this->getContainerBuilder(); $container @@ -410,7 +410,7 @@ class MessengerPassTest extends TestCase public function testUndefinedMessageClassForHandlerImplementingMessageSubscriberInterface() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaSubscriberInterface": class or interface "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessage" returned by method "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaSubscriberInterface::getHandledMessages()" not found.'); $container = $this->getContainerBuilder(); $container @@ -423,7 +423,7 @@ class MessengerPassTest extends TestCase public function testNotInvokableHandler() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\NotInvokableHandler": class "Symfony\Component\Messenger\Tests\DependencyInjection\NotInvokableHandler" must have an "__invoke()" method.'); $container = $this->getContainerBuilder(); $container @@ -436,7 +436,7 @@ class MessengerPassTest extends TestCase public function testMissingArgumentHandler() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentHandler": method "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentHandler::__invoke()" requires at least one argument, first one being the message it handles.'); $container = $this->getContainerBuilder(); $container @@ -449,7 +449,7 @@ class MessengerPassTest extends TestCase public function testMissingArgumentTypeHandler() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentTypeHandler": argument "$message" of method "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentTypeHandler::__invoke()" must have a type-hint corresponding to the message class it handles.'); $container = $this->getContainerBuilder(); $container @@ -462,7 +462,7 @@ class MessengerPassTest extends TestCase public function testBuiltinArgumentTypeHandler() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\BuiltinArgumentTypeHandler": type-hint of argument "$message" in method "Symfony\Component\Messenger\Tests\DependencyInjection\BuiltinArgumentTypeHandler::__invoke()" must be a class , "string" given.'); $container = $this->getContainerBuilder(); $container @@ -475,7 +475,7 @@ class MessengerPassTest extends TestCase public function testNeedsToHandleAtLeastOneMessage() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\HandleNoMessageHandler": method "Symfony\Component\Messenger\Tests\DependencyInjection\HandleNoMessageHandler::getHandledMessages()" must return one or more messages.'); $container = $this->getContainerBuilder(); $container @@ -554,7 +554,7 @@ class MessengerPassTest extends TestCase public function testCannotRegistersAnUndefinedMiddleware() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid middleware: service "not_defined_middleware" not found.'); $container = $this->getContainerBuilder($fooBusId = 'messenger.bus.foo'); $container->setParameter($middlewareParameter = $fooBusId.'.middleware', [ @@ -566,7 +566,7 @@ class MessengerPassTest extends TestCase public function testMiddlewareFactoryDefinitionMustBeAbstract() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Invalid middleware factory "not_an_abstract_definition": a middleware factory must be an abstract definition.'); $container = $this->getContainerBuilder($fooBusId = 'messenger.bus.foo'); $container->register('not_an_abstract_definition', UselessMiddleware::class); diff --git a/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php b/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php index 10247cf761..d2b495de2a 100644 --- a/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php +++ b/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php @@ -14,7 +14,7 @@ class HandleTraitTest extends TestCase { public function testItThrowsOnNoMessageBusInstance() { - $this->expectException('Symfony\Component\Messenger\Exception\LogicException'); + $this->expectException(\Symfony\Component\Messenger\Exception\LogicException::class); $this->expectExceptionMessage('You must provide a "Symfony\Component\Messenger\MessageBusInterface" instance in the "Symfony\Component\Messenger\Tests\TestQueryBus::$messageBus" property, "NULL" given.'); $queryBus = new TestQueryBus(null); $query = new DummyMessage('Hello'); @@ -48,7 +48,7 @@ class HandleTraitTest extends TestCase public function testHandleThrowsOnNoHandledStamp() { - $this->expectException('Symfony\Component\Messenger\Exception\LogicException'); + $this->expectException(\Symfony\Component\Messenger\Exception\LogicException::class); $this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled zero times. Exactly one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()".'); $bus = $this->createMock(MessageBus::class); $queryBus = new TestQueryBus($bus); @@ -61,7 +61,7 @@ class HandleTraitTest extends TestCase public function testHandleThrowsOnMultipleHandledStamps() { - $this->expectException('Symfony\Component\Messenger\Exception\LogicException'); + $this->expectException(\Symfony\Component\Messenger\Exception\LogicException::class); $this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled multiple times. Only one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()", got 2: "FirstDummyHandler::__invoke", "SecondDummyHandler::__invoke".'); $bus = $this->createMock(MessageBus::class); $queryBus = new TestQueryBus($bus); diff --git a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php index 531643bd56..47624777b2 100644 --- a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php +++ b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php @@ -34,7 +34,7 @@ class MessageBusTest extends TestCase public function testItDispatchInvalidMessageType() { - $this->expectException('TypeError'); + $this->expectException(\TypeError::class); $this->expectExceptionMessage('Invalid argument provided to "Symfony\Component\Messenger\MessageBus::dispatch()": expected object, but got "string".'); (new MessageBus())->dispatch('wrong'); } diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php index 400060bc86..3808843de2 100644 --- a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php +++ b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php @@ -115,7 +115,7 @@ class HandleMessageMiddlewareTest extends MiddlewareTestCase public function testThrowsNoHandlerException() { - $this->expectException('Symfony\Component\Messenger\Exception\NoHandlerForMessageException'); + $this->expectException(\Symfony\Component\Messenger\Exception\NoHandlerForMessageException::class); $this->expectExceptionMessage('No handler for message "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage"'); $middleware = new HandleMessageMiddleware(new HandlersLocator([])); diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/LoggingMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/LoggingMiddlewareTest.php index 01ff79e5d6..163dac4819 100644 --- a/src/Symfony/Component/Messenger/Tests/Middleware/LoggingMiddlewareTest.php +++ b/src/Symfony/Component/Messenger/Tests/Middleware/LoggingMiddlewareTest.php @@ -38,7 +38,7 @@ class LoggingMiddlewareTest extends MiddlewareTestCase public function testWarningLogOnException() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Thrown from next middleware.'); $message = new DummyMessage('Hey'); $envelope = new Envelope($message); diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php index 0370d86726..08e4fd5b69 100644 --- a/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php +++ b/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php @@ -66,7 +66,7 @@ class TraceableMiddlewareTest extends MiddlewareTestCase public function testHandleWithException() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Thrown from next middleware.'); $busId = 'command_bus'; diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/ValidationMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/ValidationMiddlewareTest.php index dc279118ec..d4d999fb04 100644 --- a/src/Symfony/Component/Messenger/Tests/Middleware/ValidationMiddlewareTest.php +++ b/src/Symfony/Component/Messenger/Tests/Middleware/ValidationMiddlewareTest.php @@ -54,7 +54,7 @@ class ValidationMiddlewareTest extends MiddlewareTestCase public function testValidationFailedException() { - $this->expectException('Symfony\Component\Messenger\Exception\ValidationFailedException'); + $this->expectException(\Symfony\Component\Messenger\Exception\ValidationFailedException::class); $this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" failed validation.'); $message = new DummyMessage('Hey'); $envelope = new Envelope($message); diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpReceiverTest.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpReceiverTest.php index 244e30f357..8dd8519e4b 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpReceiverTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpReceiverTest.php @@ -47,7 +47,7 @@ class AmqpReceiverTest extends TestCase public function testItThrowsATransportExceptionIfItCannotAcknowledgeMessage() { - $this->expectException('Symfony\Component\Messenger\Exception\TransportException'); + $this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class); $serializer = $this->createMock(SerializerInterface::class); $amqpEnvelope = $this->createAMQPEnvelope(); $connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); @@ -61,7 +61,7 @@ class AmqpReceiverTest extends TestCase public function testItThrowsATransportExceptionIfItCannotRejectMessage() { - $this->expectException('Symfony\Component\Messenger\Exception\TransportException'); + $this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class); $serializer = $this->createMock(SerializerInterface::class); $amqpEnvelope = $this->createAMQPEnvelope(); $connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php index 031394a3e1..4980811dd0 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php @@ -104,7 +104,7 @@ class AmqpSenderTest extends TestCase public function testItThrowsATransportExceptionIfItCannotSendTheMessage() { - $this->expectException('Symfony\Component\Messenger\Exception\TransportException'); + $this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class); $envelope = new Envelope(new DummyMessage('Oy')); $encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class]]; diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php index 6488e5fa54..1fbbb1e753 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php @@ -27,7 +27,7 @@ class ConnectionTest extends TestCase public function testItCannotBeConstructedWithAWrongDsn() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The given AMQP DSN "amqp://:" is invalid.'); Connection::fromDsn('amqp://:'); } @@ -448,7 +448,7 @@ class ConnectionTest extends TestCase public function testObfuscatePasswordInDsn() { - $this->expectException('AMQPException'); + $this->expectException(\AMQPException::class); $this->expectExceptionMessage('Could not connect to the AMQP server. Please verify the provided DSN. ({"host":"localhost","port":5672,"vhost":"/","login":"user","password":"********"})'); $factory = new TestAmqpFactory( $amqpConnection = $this->createMock(\AMQPConnection::class), diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php index 59d8819a75..c2c7cf69a9 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php @@ -92,7 +92,7 @@ class ConnectionTest extends TestCase public function testItThrowsATransportExceptionIfItCannotAcknowledgeMessage() { - $this->expectException('Symfony\Component\Messenger\Exception\TransportException'); + $this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class); $driverConnection = $this->getDBALConnectionMock(); if (class_exists(Exception::class)) { @@ -107,7 +107,7 @@ class ConnectionTest extends TestCase public function testItThrowsATransportExceptionIfItCannotRejectMessage() { - $this->expectException('Symfony\Component\Messenger\Exception\TransportException'); + $this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class); $driverConnection = $this->getDBALConnectionMock(); if (class_exists(Exception::class)) { @@ -256,13 +256,13 @@ class ConnectionTest extends TestCase public function testItThrowsAnExceptionIfAnExtraOptionsInDefined() { - $this->expectException('Symfony\Component\Messenger\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Messenger\Exception\InvalidArgumentException::class); Connection::buildConfiguration('doctrine://default', ['new_option' => 'woops']); } public function testItThrowsAnExceptionIfAnExtraOptionsInDefinedInDSN() { - $this->expectException('Symfony\Component\Messenger\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Messenger\Exception\InvalidArgumentException::class); Connection::buildConfiguration('doctrine://default?new_option=woops'); } diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php index 82387f5c1a..9cad0850e7 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php @@ -60,7 +60,7 @@ class DoctrineReceiverTest extends TestCase public function testItRejectTheMessageIfThereIsAMessageDecodingFailedException() { - $this->expectException('Symfony\Component\Messenger\Exception\MessageDecodingFailedException'); + $this->expectException(MessageDecodingFailedException::class); $serializer = $this->createMock(PhpSerializer::class); $serializer->method('decode')->willThrowException(new MessageDecodingFailedException()); diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineTransportFactoryTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineTransportFactoryTest.php index e124bf94e8..74564531b8 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineTransportFactoryTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineTransportFactoryTest.php @@ -56,7 +56,7 @@ class DoctrineTransportFactoryTest extends TestCase public function testCreateTransportMustThrowAnExceptionIfManagerIsNotFound() { - $this->expectException('Symfony\Component\Messenger\Exception\TransportException'); + $this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class); $this->expectExceptionMessage('Could not find Doctrine connection from Messenger DSN "doctrine://default".'); $registry = $this->createMock(ConnectionRegistry::class); $registry->expects($this->once()) diff --git a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php index af1b97de98..093358c3f8 100644 --- a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php +++ b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php @@ -117,7 +117,7 @@ abstract class AbstractMimeTypeGuesserTest extends TestCase @chmod($path, 0333); if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) { - $this->expectException('\InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->getGuesser()->guessMimeType($path); } else { $this->markTestSkipped('Can not verify chmod operations, change of file permissions failed'); diff --git a/src/Symfony/Component/Mime/Tests/Header/DateHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/DateHeaderTest.php index 4fc92b96ae..7ea43b7156 100644 --- a/src/Symfony/Component/Mime/Tests/Header/DateHeaderTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/DateHeaderTest.php @@ -37,7 +37,7 @@ class DateHeaderTest extends TestCase { $dateTime = new \DateTime(); $header = new DateHeader('Date', $dateTime); - $this->assertInstanceOf('DateTimeImmutable', $header->getDateTime()); + $this->assertInstanceOf(\DateTimeImmutable::class, $header->getDateTime()); $this->assertEquals($dateTime->getTimestamp(), $header->getDateTime()->getTimestamp()); $this->assertEquals($dateTime->getTimezone(), $header->getDateTime()->getTimezone()); } diff --git a/src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php index 7d274ab162..788853497e 100644 --- a/src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php @@ -101,7 +101,7 @@ class IdentificationHeaderTest extends TestCase public function testInvalidIdLeftThrowsException() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('Email "a b c@d" does not comply with addr-spec of RFC 2822.'); new IdentificationHeader('References', 'a b c@d'); } @@ -137,14 +137,14 @@ class IdentificationHeaderTest extends TestCase public function testInvalidIdRightThrowsException() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('Email "a@b c d" does not comply with addr-spec of RFC 2822.'); new IdentificationHeader('References', 'a@b c d'); } public function testMissingAtSignThrowsException() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('Email "abc" does not comply with addr-spec of RFC 2822.'); /* -- RFC 2822, 3.6.4. msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS] diff --git a/src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php index cca27db408..803afc489d 100644 --- a/src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php @@ -60,7 +60,7 @@ class MailboxHeaderTest extends TestCase public function testUtf8CharsInLocalPartThrows() { - $this->expectException('Symfony\Component\Mime\Exception\AddressEncoderException'); + $this->expectException(\Symfony\Component\Mime\Exception\AddressEncoderException::class); $header = new MailboxHeader('Sender', new Address('fabïen@symfony.com')); $header->getBodyAsString(); } diff --git a/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php index 4cace9698b..c842fa1708 100644 --- a/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php @@ -57,7 +57,7 @@ class MailboxListHeaderTest extends TestCase public function testUtf8CharsInLocalPartThrows() { - $this->expectException('Symfony\Component\Mime\Exception\AddressEncoderException'); + $this->expectException(\Symfony\Component\Mime\Exception\AddressEncoderException::class); $header = new MailboxListHeader('From', [new Address('chrïs@swiftmailer.org', 'Chris Corbyn')]); $header->getAddressStrings(); } diff --git a/src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php index a8386f8946..fe006f2d89 100644 --- a/src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php @@ -25,7 +25,7 @@ class PathHeaderTest extends TestCase public function testAddressMustComplyWithRfc2822() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); new PathHeader('Return-Path', new Address('chr is@swiftmailer.org')); } @@ -51,7 +51,7 @@ class PathHeaderTest extends TestCase public function testAddressMustBeEncodable() { - $this->expectException('Symfony\Component\Mime\Exception\AddressEncoderException'); + $this->expectException(\Symfony\Component\Mime\Exception\AddressEncoderException::class); $header = new PathHeader('Return-Path', new Address('chrïs@swiftmailer.org')); $header->getBodyAsString(); } diff --git a/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php b/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php index 433d9a8a26..b18225cc67 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php @@ -38,7 +38,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetDefaultThrowsOnNoConfiguredValue() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoConfigurationException::class); $this->expectExceptionMessage('No default value was set for the "foo" option.'); $resolver = new OptionsResolver(); $resolver->setDefined($option = 'foo'); @@ -49,7 +49,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetDefaultThrowsOnNotDefinedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The option "foo" does not exist.'); $resolver = new OptionsResolver(); @@ -69,7 +69,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetLazyClosuresThrowsOnNoConfiguredValue() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoConfigurationException::class); $this->expectExceptionMessage('No lazy closures were set for the "foo" option.'); $resolver = new OptionsResolver(); $resolver->setDefined($option = 'foo'); @@ -80,7 +80,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetLazyClosuresThrowsOnNotDefinedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The option "foo" does not exist.'); $resolver = new OptionsResolver(); @@ -100,7 +100,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetAllowedTypesThrowsOnNoConfiguredValue() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoConfigurationException::class); $this->expectExceptionMessage('No allowed types were set for the "foo" option.'); $resolver = new OptionsResolver(); $resolver->setDefined($option = 'foo'); @@ -111,7 +111,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetAllowedTypesThrowsOnNotDefinedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The option "foo" does not exist.'); $resolver = new OptionsResolver(); @@ -131,7 +131,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetAllowedValuesThrowsOnNoConfiguredValue() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoConfigurationException::class); $this->expectExceptionMessage('No allowed values were set for the "foo" option.'); $resolver = new OptionsResolver(); $resolver->setDefined($option = 'foo'); @@ -142,7 +142,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetAllowedValuesThrowsOnNotDefinedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The option "foo" does not exist.'); $resolver = new OptionsResolver(); @@ -162,7 +162,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetNormalizerThrowsOnNoConfiguredValue() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoConfigurationException::class); $this->expectExceptionMessage('No normalizer was set for the "foo" option.'); $resolver = new OptionsResolver(); $resolver->setDefined($option = 'foo'); @@ -173,7 +173,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetNormalizerThrowsOnNotDefinedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The option "foo" does not exist.'); $resolver = new OptionsResolver(); @@ -194,7 +194,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetNormalizersThrowsOnNoConfiguredValue() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoConfigurationException::class); $this->expectExceptionMessage('No normalizer was set for the "foo" option.'); $resolver = new OptionsResolver(); $resolver->setDefined('foo'); @@ -205,7 +205,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetNormalizersThrowsOnNotDefinedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The option "foo" does not exist.'); $resolver = new OptionsResolver(); @@ -235,7 +235,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetDeprecationMessageThrowsOnNoConfiguredValue() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoConfigurationException::class); $this->expectExceptionMessage('No deprecation was set for the "foo" option.'); $resolver = new OptionsResolver(); $resolver->setDefined('foo'); @@ -246,7 +246,7 @@ class OptionsResolverIntrospectorTest extends TestCase public function testGetDeprecationMessageThrowsOnNotDefinedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The option "foo" does not exist.'); $resolver = new OptionsResolver(); diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php index 941cee5fd4..4219771d60 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php @@ -31,7 +31,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfNonExistingOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The option "foo" does not exist. Defined options are: "a", "z".'); $this->resolver->setDefault('z', '1'); $this->resolver->setDefault('a', '2'); @@ -41,7 +41,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfMultipleNonExistingOptions() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The options "baz", "foo", "ping" do not exist. Defined options are: "a", "z".'); $this->resolver->setDefault('z', '1'); $this->resolver->setDefault('a', '2'); @@ -51,7 +51,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->resolve([]); }); @@ -77,7 +77,7 @@ class OptionsResolverTest extends TestCase public function testFailIfSetDefaultFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('lazy', function (Options $options) { $options->setDefault('default', 42); }); @@ -219,7 +219,7 @@ class OptionsResolverTest extends TestCase public function testFailIfSetRequiredFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->setRequired('bar'); }); @@ -229,7 +229,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfRequiredOptionMissing() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class); $this->resolver->setRequired('foo'); $this->resolver->resolve(); @@ -343,7 +343,7 @@ class OptionsResolverTest extends TestCase public function testFailIfSetDefinedFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->setDefined('bar'); }); @@ -438,7 +438,7 @@ class OptionsResolverTest extends TestCase public function testFailIfSetDeprecatedFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver ->setDefault('bar', 'baz') ->setDefault('foo', function (Options $options) { @@ -450,13 +450,13 @@ class OptionsResolverTest extends TestCase public function testSetDeprecatedFailsIfUnknownOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->resolver->setDeprecated('foo'); } public function testSetDeprecatedFailsIfInvalidDeprecationMessageType() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid type for deprecation message argument, expected string or \Closure, but got "boolean".'); $this->resolver ->setDefined('foo') @@ -466,7 +466,7 @@ class OptionsResolverTest extends TestCase public function testLazyDeprecationFailsIfInvalidDeprecationMessageType() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid type for deprecation message, expected string but got "boolean", return an empty string to ignore.'); $this->resolver ->setDefined('foo') @@ -479,7 +479,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfCyclicDependencyBetweenDeprecation() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class); $this->expectExceptionMessage('The options "foo", "bar" have a cyclic dependency.'); $this->resolver ->setDefined(['foo', 'bar']) @@ -750,7 +750,7 @@ class OptionsResolverTest extends TestCase public function testSetAllowedTypesFailsIfUnknownOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->resolver->setAllowedTypes('foo', 'string'); } @@ -765,7 +765,7 @@ class OptionsResolverTest extends TestCase public function testFailIfSetAllowedTypesFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->setAllowedTypes('bar', 'string'); }); @@ -777,7 +777,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidTypedArray() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "DateTime".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[]'); @@ -787,7 +787,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsWithNonArray() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value "bar" is expected to be of type "int[]", but is of type "string".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[]'); @@ -797,7 +797,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfTypedArrayContainsInvalidTypes() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "stdClass|array|DateTime".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[]'); @@ -812,7 +812,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsWithCorrectLevelsButWrongScalar() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "double".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[][]'); @@ -832,7 +832,7 @@ class OptionsResolverTest extends TestCase $this->resolver->setDefined('option'); $this->resolver->setAllowedTypes('option', $allowedType); - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage($exceptionMessage); $this->resolver->resolve(['option' => $actualType]); @@ -867,7 +867,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidTypeMultiple() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value 42 is expected to be of type "string" or "bool", but is of type "integer".'); $this->resolver->setDefault('foo', 42); $this->resolver->setAllowedTypes('foo', ['string', 'bool']); @@ -908,7 +908,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfNotInstanceOfClass() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 'bar'); $this->resolver->setAllowedTypes('foo', '\stdClass'); @@ -917,13 +917,13 @@ class OptionsResolverTest extends TestCase public function testAddAllowedTypesFailsIfUnknownOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->resolver->addAllowedTypes('foo', 'string'); } public function testFailIfAddAllowedTypesFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->addAllowedTypes('bar', 'string'); }); @@ -935,7 +935,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidAddedType() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 42); $this->resolver->addAllowedTypes('foo', 'string'); @@ -952,7 +952,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidAddedTypeMultiple() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 42); $this->resolver->addAllowedTypes('foo', ['string', 'bool']); @@ -991,13 +991,13 @@ class OptionsResolverTest extends TestCase public function testSetAllowedValuesFailsIfUnknownOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->resolver->setAllowedValues('foo', 'bar'); } public function testFailIfSetAllowedValuesFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->setAllowedValues('bar', 'baz'); }); @@ -1009,7 +1009,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidValue() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value 42 is invalid. Accepted values are: "bar".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedValues('foo', 'bar'); @@ -1019,7 +1019,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidValueIsNull() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value null is invalid. Accepted values are: "bar".'); $this->resolver->setDefault('foo', null); $this->resolver->setAllowedValues('foo', 'bar'); @@ -1029,7 +1029,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidValueStrict() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 42); $this->resolver->setAllowedValues('foo', '42'); @@ -1054,7 +1054,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidValueMultiple() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value 42 is invalid. Accepted values are: "bar", false, null.'); $this->resolver->setDefault('foo', 42); $this->resolver->setAllowedValues('foo', ['bar', false, null]); @@ -1103,7 +1103,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfAllClosuresReturnFalse() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 42); $this->resolver->setAllowedValues('foo', [ function () { return false; }, @@ -1128,13 +1128,13 @@ class OptionsResolverTest extends TestCase public function testAddAllowedValuesFailsIfUnknownOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->resolver->addAllowedValues('foo', 'bar'); } public function testFailIfAddAllowedValuesFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->addAllowedValues('bar', 'baz'); }); @@ -1146,7 +1146,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidAddedValue() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 42); $this->resolver->addAllowedValues('foo', 'bar'); @@ -1171,7 +1171,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidAddedValueMultiple() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 42); $this->resolver->addAllowedValues('foo', ['bar', 'baz']); @@ -1206,7 +1206,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfAllAddedClosuresReturnFalse() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 42); $this->resolver->setAllowedValues('foo', function () { return false; }); $this->resolver->addAllowedValues('foo', function () { return false; }); @@ -1250,13 +1250,13 @@ class OptionsResolverTest extends TestCase public function testSetNormalizerFailsIfUnknownOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->resolver->setNormalizer('foo', function () {}); } public function testFailIfSetNormalizerFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->setNormalizer('foo', function () {}); }); @@ -1292,7 +1292,7 @@ class OptionsResolverTest extends TestCase public function testValidateTypeBeforeNormalization() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 'bar'); $this->resolver->setAllowedTypes('foo', 'int'); @@ -1306,7 +1306,7 @@ class OptionsResolverTest extends TestCase public function testValidateValueBeforeNormalization() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->resolver->setDefault('foo', 'bar'); $this->resolver->setAllowedValues('foo', 'baz'); @@ -1358,7 +1358,7 @@ class OptionsResolverTest extends TestCase public function testFailIfCyclicDependencyBetweenNormalizers() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class); $this->resolver->setDefault('norm1', 'bar'); $this->resolver->setDefault('norm2', 'baz'); @@ -1375,7 +1375,7 @@ class OptionsResolverTest extends TestCase public function testFailIfCyclicDependencyBetweenNormalizerAndLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class); $this->resolver->setDefault('lazy', function (Options $options) { $options['norm']; }); @@ -1521,13 +1521,13 @@ class OptionsResolverTest extends TestCase public function testAddNormalizerFailsIfUnknownOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->resolver->addNormalizer('foo', function () {}); } public function testFailIfAddNormalizerFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->addNormalizer('foo', function () {}); }); @@ -1559,7 +1559,7 @@ class OptionsResolverTest extends TestCase public function testFailIfSetDefaultsFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->setDefaults(['two' => '2']); }); @@ -1638,7 +1638,7 @@ class OptionsResolverTest extends TestCase public function testFailIfRemoveFromLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->remove('bar'); }); @@ -1712,7 +1712,7 @@ class OptionsResolverTest extends TestCase public function testFailIfClearFromLazyption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', function (Options $options) { $options->clear(); }); @@ -1769,7 +1769,7 @@ class OptionsResolverTest extends TestCase public function testArrayAccessGetFailsOutsideResolve() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('default', 0); $this->resolver['default']; @@ -1777,7 +1777,7 @@ class OptionsResolverTest extends TestCase public function testArrayAccessExistsFailsOutsideResolve() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('default', 0); isset($this->resolver['default']); @@ -1785,13 +1785,13 @@ class OptionsResolverTest extends TestCase public function testArrayAccessSetNotSupported() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver['default'] = 0; } public function testArrayAccessUnsetNotSupported() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('default', 0); unset($this->resolver['default']); @@ -1799,7 +1799,7 @@ class OptionsResolverTest extends TestCase public function testFailIfGetNonExisting() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\NoSuchOptionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoSuchOptionException::class); $this->expectExceptionMessage('The option "undefined" does not exist. Defined options are: "foo", "lazy".'); $this->resolver->setDefault('foo', 'bar'); @@ -1812,7 +1812,7 @@ class OptionsResolverTest extends TestCase public function testFailIfGetDefinedButUnset() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\NoSuchOptionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoSuchOptionException::class); $this->expectExceptionMessage('The optional option "defined" has no value set. You should make sure it is set with "isset" before reading it.'); $this->resolver->setDefined('defined'); @@ -1825,7 +1825,7 @@ class OptionsResolverTest extends TestCase public function testFailIfCyclicDependency() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class); $this->resolver->setDefault('lazy1', function (Options $options) { $options['lazy2']; }); @@ -1858,7 +1858,7 @@ class OptionsResolverTest extends TestCase */ public function testCountFailsOutsideResolve() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\AccessException::class); $this->resolver->setDefault('foo', 0); $this->resolver->setRequired('bar'); $this->resolver->setDefined('bar'); @@ -1915,7 +1915,7 @@ class OptionsResolverTest extends TestCase public function testNestedArraysException() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "integer".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'float[][][][]'); @@ -1933,7 +1933,7 @@ class OptionsResolverTest extends TestCase public function testNestedArrayException1() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean|string|array".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[][]'); @@ -1946,7 +1946,7 @@ class OptionsResolverTest extends TestCase public function testNestedArrayException2() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean|string|array".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[][]'); @@ -1959,7 +1959,7 @@ class OptionsResolverTest extends TestCase public function testNestedArrayException3() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string|integer".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'string[][][]'); @@ -1972,7 +1972,7 @@ class OptionsResolverTest extends TestCase public function testNestedArrayException4() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "integer".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'string[][][]'); @@ -1986,7 +1986,7 @@ class OptionsResolverTest extends TestCase public function testNestedArrayException5() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[]", but one of the elements is of type "array".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'string[]'); @@ -2010,7 +2010,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfUndefinedNestedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->expectExceptionMessage('The option "database[foo]" does not exist. Defined options are: "host", "port".'); $this->resolver->setDefaults([ 'name' => 'default', @@ -2025,7 +2025,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfMissingRequiredNestedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class); $this->expectExceptionMessage('The required option "database[host]" is missing.'); $this->resolver->setDefaults([ 'name' => 'default', @@ -2040,7 +2040,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfInvalidTypeNestedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The option "database[logging]" with value null is expected to be of type "bool", but is of type "NULL".'); $this->resolver->setDefaults([ 'name' => 'default', @@ -2057,7 +2057,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfNotArrayIsGivenForNestedOptions() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The nested option "database" with value null is expected to be of type array, but is of type "NULL".'); $this->resolver->setDefaults([ 'name' => 'default', @@ -2264,7 +2264,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfCyclicDependencyBetweenSameNestedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class); $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) { $resolver->setDefault('replicas', $parent['database']); }); @@ -2273,7 +2273,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfCyclicDependencyBetweenNestedOptionAndParentLazyOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class); $this->resolver->setDefaults([ 'version' => function (Options $options) { return $options['database']['server_version']; @@ -2287,7 +2287,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfCyclicDependencyBetweenNormalizerAndNestedOption() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class); $this->resolver ->setDefault('name', 'default') ->setDefault('database', function (OptionsResolver $resolver, Options $parent) { @@ -2301,7 +2301,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfCyclicDependencyBetweenNestedOptions() { - $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); + $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class); $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) { $resolver->setDefault('host', $parent['replica']['host']); }); diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index f82043009b..4a0812c795 100644 --- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -24,7 +24,7 @@ class ProcessFailedExceptionTest extends TestCase */ public function testProcessFailedExceptionThrowsException() { - $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock(); + $process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful'])->setConstructorArgs([['php']])->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->willReturn(true); @@ -48,7 +48,7 @@ class ProcessFailedExceptionTest extends TestCase $errorOutput = 'FATAL: Unexpected error'; $workingDirectory = getcwd(); - $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock(); + $process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->willReturn(false); @@ -96,7 +96,7 @@ class ProcessFailedExceptionTest extends TestCase $exitText = 'General error'; $workingDirectory = getcwd(); - $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock(); + $process = $this->getMockBuilder(\Symfony\Component\Process\Process::class)->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([[$cmd]])->getMock(); $process->expects($this->once()) ->method('isSuccessful') ->willReturn(false); diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 62bffec88f..4fd0df2018 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -49,7 +49,7 @@ class ProcessTest extends TestCase public function testInvalidCwd() { - $this->expectException('Symfony\Component\Process\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessageMatches('/The provided cwd ".*" does not exist\./'); try { // Check that it works fine if the CWD exists @@ -78,13 +78,13 @@ class ProcessTest extends TestCase public function testNegativeTimeoutFromConstructor() { - $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); $this->getProcess('', null, null, null, -1); } public function testNegativeTimeoutFromSetter() { - $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); $p = $this->getProcess(''); $p->setTimeout(-1); } @@ -272,7 +272,7 @@ class ProcessTest extends TestCase public function testSetInputWhileRunningThrowsAnException() { - $this->expectException('Symfony\Component\Process\Exception\LogicException'); + $this->expectException(LogicException::class); $this->expectExceptionMessage('Input can not be set while the process is running.'); $process = $this->getProcessForCode('sleep(30);'); $process->start(); @@ -292,7 +292,7 @@ class ProcessTest extends TestCase */ public function testInvalidInput($value) { - $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('"Symfony\Component\Process\Process::setInput" only accepts strings, Traversable objects or stream resources.'); $process = $this->getProcess('foo'); $process->setInput($value); @@ -508,7 +508,7 @@ class ProcessTest extends TestCase public function testTTYInWindowsEnvironment() { - $this->expectException('Symfony\Component\Process\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('TTY mode is not supported on Windows platform.'); if ('\\' !== \DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test is for Windows platform only'); @@ -555,7 +555,7 @@ class ProcessTest extends TestCase public function testMustRunThrowsException() { - $this->expectException('Symfony\Component\Process\Exception\ProcessFailedException'); + $this->expectException(\Symfony\Component\Process\Exception\ProcessFailedException::class); $process = $this->getProcess('exit 1'); $process->mustRun(); } @@ -707,7 +707,7 @@ class ProcessTest extends TestCase public function testProcessThrowsExceptionWhenExternallySignaled() { - $this->expectException('Symfony\Component\Process\Exception\ProcessSignaledException'); + $this->expectException(\Symfony\Component\Process\Exception\ProcessSignaledException::class); $this->expectExceptionMessage('The process has been signaled with signal "9".'); if (!\function_exists('posix_kill')) { $this->markTestSkipped('Function posix_kill is required.'); @@ -744,7 +744,7 @@ class ProcessTest extends TestCase public function testRunProcessWithTimeout() { - $this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException'); + $this->expectException(ProcessTimedOutException::class); $this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.'); $process = $this->getProcessForCode('sleep(30);'); $process->setTimeout(0.1); @@ -762,7 +762,7 @@ class ProcessTest extends TestCase public function testIterateOverProcessWithTimeout() { - $this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException'); + $this->expectException(ProcessTimedOutException::class); $this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.'); $process = $this->getProcessForCode('sleep(30);'); $process->setTimeout(0.1); @@ -794,7 +794,7 @@ class ProcessTest extends TestCase public function testCheckTimeoutOnStartedProcess() { - $this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException'); + $this->expectException(ProcessTimedOutException::class); $this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.'); $process = $this->getProcessForCode('sleep(33);'); $process->setTimeout(0.1); @@ -857,7 +857,7 @@ class ProcessTest extends TestCase public function testStartAfterATimeout() { - $this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException'); + $this->expectException(ProcessTimedOutException::class); $this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.'); $process = $this->getProcessForCode('sleep(35);'); $process->setTimeout(0.1); @@ -934,7 +934,7 @@ class ProcessTest extends TestCase public function testSignalProcessNotRunning() { - $this->expectException('Symfony\Component\Process\Exception\LogicException'); + $this->expectException(LogicException::class); $this->expectExceptionMessage('Can not send signal on a non running process.'); $process = $this->getProcess('foo'); $process->signal(1); // SIGHUP @@ -947,7 +947,7 @@ class ProcessTest extends TestCase { $process = $this->getProcess('foo'); - $this->expectException('Symfony\Component\Process\Exception\LogicException'); + $this->expectException(LogicException::class); $this->expectExceptionMessage(sprintf('Process must be started before calling "%s()".', $method)); $process->{$method}(); @@ -969,7 +969,7 @@ class ProcessTest extends TestCase */ public function testMethodsThatNeedATerminatedProcess($method) { - $this->expectException('Symfony\Component\Process\Exception\LogicException'); + $this->expectException(LogicException::class); $this->expectExceptionMessage('Process must be terminated before calling'); $process = $this->getProcessForCode('sleep(37);'); $process->start(); @@ -1024,7 +1024,7 @@ class ProcessTest extends TestCase public function testDisableOutputWhileRunningThrowsException() { - $this->expectException('Symfony\Component\Process\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Disabling output while the process is running is not possible.'); $p = $this->getProcessForCode('sleep(39);'); $p->start(); @@ -1033,7 +1033,7 @@ class ProcessTest extends TestCase public function testEnableOutputWhileRunningThrowsException() { - $this->expectException('Symfony\Component\Process\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Enabling output while the process is running is not possible.'); $p = $this->getProcessForCode('sleep(40);'); $p->disableOutput(); @@ -1053,7 +1053,7 @@ class ProcessTest extends TestCase public function testDisableOutputWhileIdleTimeoutIsSet() { - $this->expectException('Symfony\Component\Process\Exception\LogicException'); + $this->expectException(LogicException::class); $this->expectExceptionMessage('Output can not be disabled while an idle timeout is set.'); $process = $this->getProcess('foo'); $process->setIdleTimeout(1); @@ -1062,7 +1062,7 @@ class ProcessTest extends TestCase public function testSetIdleTimeoutWhileOutputIsDisabled() { - $this->expectException('Symfony\Component\Process\Exception\LogicException'); + $this->expectException(LogicException::class); $this->expectExceptionMessage('timeout can not be set while the output is disabled.'); $process = $this->getProcess('foo'); $process->disableOutput(); @@ -1081,7 +1081,7 @@ class ProcessTest extends TestCase */ public function testGetOutputWhileDisabled($fetchMethod) { - $this->expectException('Symfony\Component\Process\Exception\LogicException'); + $this->expectException(LogicException::class); $this->expectExceptionMessage('Output has been disabled.'); $p = $this->getProcessForCode('sleep(41);'); $p->disableOutput(); @@ -1485,7 +1485,7 @@ class ProcessTest extends TestCase public function testPreparedCommandWithMissingValue() { - $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}"'); $p = Process::fromShellCommandline('echo "${:abc}"'); $p->run(null, ['bcd' => 'BCD']); @@ -1493,7 +1493,7 @@ class ProcessTest extends TestCase public function testPreparedCommandWithNoValues() { - $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Process\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Command line is missing a value for parameter "abc": echo "${:abc}"'); $p = Process::fromShellCommandline('echo "${:abc}"'); $p->run(null, []); diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index f38b9140e7..b442c3ae53 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -892,7 +892,7 @@ class PropertyAccessor implements PropertyAccessorInterface @trigger_error(sprintf('Passing null as "$defaultLifetime" 2nd argument of the "%s()" method is deprecated since Symfony 4.4, pass 0 instead.', __METHOD__), \E_USER_DEPRECATED); } - if (!class_exists('Symfony\Component\Cache\Adapter\ApcuAdapter')) { + if (!class_exists(ApcuAdapter::class)) { throw new \LogicException(sprintf('The Symfony Cache component must be installed to use "%s()".', __METHOD__)); } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php index dc576dfcb6..4a31588e3e 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php @@ -47,7 +47,7 @@ abstract class PropertyAccessorArrayAccessTest extends TestCase public function testGetValueFailsIfNoSuchIndex() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchIndexException::class); $this->propertyAccessor = PropertyAccess::createPropertyAccessorBuilder() ->enableExceptionOnInvalidIndex() ->getPropertyAccessor(); diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php index f6d737b6ad..13c977f418 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php @@ -148,7 +148,7 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces public function testSetValueFailsIfNoAdderNorRemoverFound() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover_[^"]*"./'); $car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock(); $axesBefore = $this->getContainer([1 => 'second', 3 => 'fourth']); @@ -187,7 +187,7 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Symfony\\\\Component\\\\PropertyAccess\\\\Tests\\\\PropertyAccessorCollectionTest_Car[^"]*": The property "axes" in class "Symfony\\\\Component\\\\PropertyAccess\\\\Tests\\\\PropertyAccessorCollectionTest_Car[^"]*" can be defined with the methods "addAxis\(\)", "removeAxis\(\)" but the new value must be an array or an instance of \\\\Traversable, "string" given./'); $car = new PropertyAccessorCollectionTest_Car(); diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index 1d3e3b1465..779bb3b097 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -101,7 +101,7 @@ class PropertyAccessorTest extends TestCase */ public function testGetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path) { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->propertyAccessor->getValue($objectOrArray, $path); } @@ -128,7 +128,7 @@ class PropertyAccessorTest extends TestCase */ public function testGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnabled($objectOrArray, $path) { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException'); + $this->expectException(NoSuchIndexException::class); $this->propertyAccessor = new PropertyAccessor(false, true); $this->propertyAccessor->getValue($objectOrArray, $path); } @@ -138,7 +138,7 @@ class PropertyAccessorTest extends TestCase */ public function testGetValueThrowsExceptionIfUninitializedProperty() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\AccessException::class); $this->expectExceptionMessage('The property "Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedProperty::$uninitialized" is not readable because it is typed "string". You should initialize it or declare a default value instead.'); $this->propertyAccessor->getValue(new UninitializedProperty(), 'uninitialized'); @@ -149,7 +149,7 @@ class PropertyAccessorTest extends TestCase */ public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetter() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\AccessException::class); $this->expectExceptionMessage('The method "Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedPrivateProperty::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?'); $this->propertyAccessor->getValue(new UninitializedPrivateProperty(), 'uninitialized'); @@ -160,7 +160,7 @@ class PropertyAccessorTest extends TestCase */ public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetterOfAnonymousClass() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\AccessException::class); $this->expectExceptionMessage('The method "class@anonymous::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?'); $object = eval('return new class() { @@ -180,7 +180,7 @@ class PropertyAccessorTest extends TestCase */ public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetterOfAnonymousStdClass() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\AccessException::class); $this->expectExceptionMessage('The method "stdClass@anonymous::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?'); $object = eval('return new class() extends \stdClass { @@ -200,7 +200,7 @@ class PropertyAccessorTest extends TestCase */ public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetterOfAnonymousChildClass() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\AccessException::class); $this->expectExceptionMessage('The method "Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedPrivateProperty@anonymous::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?'); $object = eval('return new class() extends \Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedPrivateProperty {};'); @@ -210,7 +210,7 @@ class PropertyAccessorTest extends TestCase public function testGetValueThrowsExceptionIfNotArrayAccess() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException'); + $this->expectException(NoSuchIndexException::class); $this->propertyAccessor->getValue(new \stdClass(), '[index]'); } @@ -259,7 +259,7 @@ class PropertyAccessorTest extends TestCase public function testGetValueDoesNotReadMagicCallByDefault() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->propertyAccessor->getValue(new TestClassMagicCall('Bernhard'), 'magicCallProperty'); } @@ -283,7 +283,7 @@ class PropertyAccessorTest extends TestCase */ public function testGetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path) { - $this->expectException('Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException::class); $this->expectExceptionMessage('PropertyAccessor requires a graph of objects or arrays to operate on'); $this->propertyAccessor->getValue($objectOrArray, $path); } @@ -303,7 +303,7 @@ class PropertyAccessorTest extends TestCase */ public function testSetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path) { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->propertyAccessor->setValue($objectOrArray, $path, 'Updated'); } @@ -330,7 +330,7 @@ class PropertyAccessorTest extends TestCase public function testSetValueThrowsExceptionIfNotArrayAccess() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException'); + $this->expectException(NoSuchIndexException::class); $object = new \stdClass(); $this->propertyAccessor->setValue($object, '[index]', 'Updated'); @@ -347,7 +347,7 @@ class PropertyAccessorTest extends TestCase public function testSetValueThrowsExceptionIfThereAreMissingParameters() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $object = new TestClass('Bernhard'); $this->propertyAccessor->setValue($object, 'publicAccessorWithMoreRequiredParameters', 'Updated'); @@ -355,7 +355,7 @@ class PropertyAccessorTest extends TestCase public function testSetValueDoesNotUpdateMagicCallByDefault() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $author = new TestClassMagicCall('Bernhard'); $this->propertyAccessor->setValue($author, 'magicCallProperty', 'Updated'); @@ -377,7 +377,7 @@ class PropertyAccessorTest extends TestCase */ public function testSetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path) { - $this->expectException('Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException::class); $this->expectExceptionMessage('PropertyAccessor requires a graph of objects or arrays to operate on'); $this->propertyAccessor->setValue($objectOrArray, $path, 'value'); } @@ -613,7 +613,7 @@ class PropertyAccessorTest extends TestCase public function testThrowTypeError() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Expected argument of type "DateTime", "string" given at property path "date"'); $object = new TypeHinted(); @@ -622,7 +622,7 @@ class PropertyAccessorTest extends TestCase public function testThrowTypeErrorWithNullArgument() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Expected argument of type "DateTime", "null" given'); $object = new TypeHinted(); @@ -674,7 +674,7 @@ class PropertyAccessorTest extends TestCase public function testThrowTypeErrorWithInterface() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Expected argument of type "Countable", "string" given'); $object = new TypeHinted(); @@ -694,7 +694,7 @@ class PropertyAccessorTest extends TestCase public function testAnonymousClassReadThrowExceptionOnInvalidPropertyPath() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $obj = $this->generateAnonymousClass('bar'); $this->propertyAccessor->getValue($obj, 'invalid_property'); @@ -754,7 +754,7 @@ class PropertyAccessorTest extends TestCase public function testThrowTypeErrorInsideSetterCall() { - $this->expectException('TypeError'); + $this->expectException(\TypeError::class); $object = new TestClassTypeErrorInsideCall(); $this->propertyAccessor->setValue($object, 'property', 'foo'); @@ -762,7 +762,7 @@ class PropertyAccessorTest extends TestCase public function testDoNotDiscardReturnTypeError() { - $this->expectException('TypeError'); + $this->expectException(\TypeError::class); $object = new ReturnTyped(); $this->propertyAccessor->setValue($object, 'foos', [new \DateTime()]); @@ -770,7 +770,7 @@ class PropertyAccessorTest extends TestCase public function testDoNotDiscardReturnTypeErrorWhenWriterMethodIsMisconfigured() { - $this->expectException('TypeError'); + $this->expectException(\TypeError::class); $object = new ReturnTyped(); $this->propertyAccessor->setValue($object, 'name', 'foo'); @@ -820,7 +820,7 @@ class PropertyAccessorTest extends TestCase public function testAdderWithoutRemover() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->expectExceptionMessageMatches('/.*The add method "addFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidMethods" was found, but the corresponding remove method "removeFoo" was not found\./'); $object = new TestAdderRemoverInvalidMethods(); $this->propertyAccessor->setValue($object, 'foos', [1, 2]); @@ -828,7 +828,7 @@ class PropertyAccessorTest extends TestCase public function testRemoverWithoutAdder() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->expectExceptionMessageMatches('/.*The remove method "removeBar" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidMethods" was found, but the corresponding add method "addBar" was not found\./'); $object = new TestAdderRemoverInvalidMethods(); $this->propertyAccessor->setValue($object, 'bars', [1, 2]); @@ -836,7 +836,7 @@ class PropertyAccessorTest extends TestCase public function testAdderAndRemoveNeedsTheExactParametersDefined() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->expectExceptionMessageMatches('/.*The method "addFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 0 arguments, but should accept only 1\. The method "removeFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 2 arguments, but should accept only 1\./'); $object = new TestAdderRemoverInvalidArgumentLength(); $this->propertyAccessor->setValue($object, 'foo', [1, 2]); @@ -844,7 +844,7 @@ class PropertyAccessorTest extends TestCase public function testSetterNeedsTheExactParametersDefined() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->expectExceptionMessageMatches('/.*The method "setBar" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 2 arguments, but should accept only 1\./'); $object = new TestAdderRemoverInvalidArgumentLength(); $this->propertyAccessor->setValue($object, 'bar', [1, 2]); @@ -852,7 +852,7 @@ class PropertyAccessorTest extends TestCase public function testSetterNeedsPublicAccess() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class); $this->expectExceptionMessageMatches('/.*The method "setFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestClassSetValue" was found but does not have public access./'); $object = new TestClassSetValue(0); $this->propertyAccessor->setValue($object, 'foo', 1); diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php index b121a48087..e26ed62e7e 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php @@ -118,13 +118,13 @@ class PropertyPathBuilderTest extends TestCase public function testReplaceByIndexDoesNotAllowInvalidOffsets() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $this->builder->replaceByIndex(6, 'new1'); } public function testReplaceByIndexDoesNotAllowNegativeOffsets() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $this->builder->replaceByIndex(-1, 'new1'); } @@ -148,13 +148,13 @@ class PropertyPathBuilderTest extends TestCase public function testReplaceByPropertyDoesNotAllowInvalidOffsets() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $this->builder->replaceByProperty(6, 'new1'); } public function testReplaceByPropertyDoesNotAllowNegativeOffsets() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $this->builder->replaceByProperty(-1, 'new1'); } @@ -190,7 +190,7 @@ class PropertyPathBuilderTest extends TestCase */ public function testReplaceDoesNotAllowInvalidOffsets($offset) { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $this->builder->replace($offset, 1, new PropertyPath('new1[new2].new3')); } @@ -264,13 +264,13 @@ class PropertyPathBuilderTest extends TestCase public function testRemoveDoesNotAllowInvalidOffsets() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $this->builder->remove(6); } public function testRemoveDoesNotAllowNegativeOffsets() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $this->builder->remove(-1); } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php index 4fe450e3f2..6b08d2b65d 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php @@ -25,13 +25,13 @@ class PropertyPathTest extends TestCase public function testDotIsRequiredBeforeProperty() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException::class); new PropertyPath('[index]property'); } public function testDotCannotBePresentAtTheBeginning() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException::class); new PropertyPath('.property'); } @@ -53,25 +53,25 @@ class PropertyPathTest extends TestCase */ public function testUnexpectedCharacters($path) { - $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException::class); new PropertyPath($path); } public function testPathCannotBeEmpty() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException::class); new PropertyPath(''); } public function testPathCannotBeNull() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException::class); new PropertyPath(null); } public function testPathCannotBeFalse() { - $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException::class); new PropertyPath(false); } @@ -120,7 +120,7 @@ class PropertyPathTest extends TestCase public function testGetElementDoesNotAcceptInvalidIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $propertyPath = new PropertyPath('grandpa.parent[child]'); $propertyPath->getElement(3); @@ -128,7 +128,7 @@ class PropertyPathTest extends TestCase public function testGetElementDoesNotAcceptNegativeIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $propertyPath = new PropertyPath('grandpa.parent[child]'); $propertyPath->getElement(-1); @@ -144,7 +144,7 @@ class PropertyPathTest extends TestCase public function testIsPropertyDoesNotAcceptInvalidIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $propertyPath = new PropertyPath('grandpa.parent[child]'); $propertyPath->isProperty(3); @@ -152,7 +152,7 @@ class PropertyPathTest extends TestCase public function testIsPropertyDoesNotAcceptNegativeIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $propertyPath = new PropertyPath('grandpa.parent[child]'); $propertyPath->isProperty(-1); @@ -168,7 +168,7 @@ class PropertyPathTest extends TestCase public function testIsIndexDoesNotAcceptInvalidIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $propertyPath = new PropertyPath('grandpa.parent[child]'); $propertyPath->isIndex(3); @@ -176,7 +176,7 @@ class PropertyPathTest extends TestCase public function testIsIndexDoesNotAcceptNegativeIndices() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $propertyPath = new PropertyPath('grandpa.parent[child]'); $propertyPath->isIndex(-1); diff --git a/src/Symfony/Component/PropertyInfo/Tests/AbstractPropertyInfoExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/AbstractPropertyInfoExtractorTest.php index c8bd5b9b86..66041a309c 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/AbstractPropertyInfoExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/AbstractPropertyInfoExtractorTest.php @@ -36,10 +36,10 @@ class AbstractPropertyInfoExtractorTest extends TestCase public function testInstanceOf() { - $this->assertInstanceOf('Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface', $this->propertyInfo); - $this->assertInstanceOf('Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface', $this->propertyInfo); - $this->assertInstanceOf('Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface', $this->propertyInfo); - $this->assertInstanceOf('Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface', $this->propertyInfo); + $this->assertInstanceOf(\Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface::class, $this->propertyInfo); + $this->assertInstanceOf(\Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface::class, $this->propertyInfo); + $this->assertInstanceOf(\Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface::class, $this->propertyInfo); + $this->assertInstanceOf(\Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface::class, $this->propertyInfo); $this->assertInstanceOf(PropertyInitializableExtractorInterface::class, $this->propertyInfo); } diff --git a/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php b/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php index 30382bec8d..7127fc15b3 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php @@ -29,11 +29,11 @@ class TypeTest extends TestCase $this->assertTrue($type->isCollection()); $collectionKeyType = $type->getCollectionKeyType(); - $this->assertInstanceOf('Symfony\Component\PropertyInfo\Type', $collectionKeyType); + $this->assertInstanceOf(Type::class, $collectionKeyType); $this->assertEquals(Type::BUILTIN_TYPE_INT, $collectionKeyType->getBuiltinType()); $collectionValueType = $type->getCollectionValueType(); - $this->assertInstanceOf('Symfony\Component\PropertyInfo\Type', $collectionValueType); + $this->assertInstanceOf(Type::class, $collectionValueType); $this->assertEquals(Type::BUILTIN_TYPE_STRING, $collectionValueType->getBuiltinType()); } @@ -45,7 +45,7 @@ class TypeTest extends TestCase public function testInvalidType() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('"foo" is not a valid PHP type.'); new Type('foo'); } diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php index 402ac51351..50b9666abf 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php @@ -446,7 +446,7 @@ EOF; private function getExpressionLanguage(): ExpressionLanguage { if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + if (!class_exists(ExpressionLanguage::class)) { throw new \LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } $this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders); diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index 328b0e907a..bab0a58172 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -262,7 +262,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface protected function getExpressionLanguage() { if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + if (!class_exists(ExpressionLanguage::class)) { throw new \LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } $this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders); @@ -276,7 +276,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface */ protected function createRequest(string $pathinfo): ?Request { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + if (!class_exists(Request::class)) { return null; } diff --git a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php index 2c193a8a09..a482378bde 100644 --- a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php @@ -18,13 +18,13 @@ class RouteTest extends TestCase { public function testInvalidRouteParameter() { - $this->expectException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); new Route(['foo' => 'bar']); } public function testTryingToSetLocalesDirectly() { - $this->expectException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); new Route(['locales' => ['nl' => 'bar']]); } diff --git a/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php b/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php index 299e6bd5c6..ee71ce98a1 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php @@ -118,7 +118,7 @@ class CompiledUrlGeneratorDumperTest extends TestCase public function testDumpWithRouteNotFoundLocalizedRoutes() { - $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException'); + $this->expectException(\Symfony\Component\Routing\Exception\RouteNotFoundException::class); $this->expectExceptionMessage('Unable to generate a URL for the named route "test" as such route does not exist.'); $this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test')->setRequirement('_locale', 'en')); @@ -178,7 +178,7 @@ class CompiledUrlGeneratorDumperTest extends TestCase public function testDumpWithoutRoutes() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump()); $projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php')); @@ -188,7 +188,7 @@ class CompiledUrlGeneratorDumperTest extends TestCase public function testGenerateNonExistingRoute() { - $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException'); + $this->expectException(\Symfony\Component\Routing\Exception\RouteNotFoundException::class); $this->routeCollection->add('Test', new Route('/test')); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump()); diff --git a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php index 28a6782a2e..f25d638792 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php @@ -124,7 +124,7 @@ class PhpGeneratorDumperTest extends TestCase public function testDumpWithRouteNotFoundLocalizedRoutes() { - $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException'); + $this->expectException(\Symfony\Component\Routing\Exception\RouteNotFoundException::class); $this->expectExceptionMessage('Unable to generate a URL for the named route "test" as such route does not exist.'); $this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test')->setRequirement('_locale', 'en')); @@ -193,7 +193,7 @@ class PhpGeneratorDumperTest extends TestCase public function testDumpWithoutRoutes() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(['class' => 'WithoutRoutesUrlGenerator'])); include $this->testTmpFilepath; @@ -204,7 +204,7 @@ class PhpGeneratorDumperTest extends TestCase public function testGenerateNonExistingRoute() { - $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException'); + $this->expectException(\Symfony\Component\Routing\Exception\RouteNotFoundException::class); $this->routeCollection->add('Test', new Route('/test')); file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(['class' => 'NonExistingRoutesUrlGenerator'])); diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index cc5d894cfa..6246b90e6a 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -78,7 +78,7 @@ class UrlGeneratorTest extends TestCase public function testRelativeUrlWithNullParameterButNotOptional() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/testing/{foo}/bar', ['foo' => null])); // This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params. // Generating path "/testing//bar" would be wrong as matching this route would fail. @@ -264,14 +264,14 @@ class UrlGeneratorTest extends TestCase public function testGenerateWithoutRoutes() { - $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException'); + $this->expectException(\Symfony\Component\Routing\Exception\RouteNotFoundException::class); $routes = $this->getRoutes('foo', new Route('/testing/{foo}')); $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL); } public function testGenerateWithInvalidLocale() { - $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException'); + $this->expectException(\Symfony\Component\Routing\Exception\RouteNotFoundException::class); $routes = new RouteCollection(); $route = new Route(''); @@ -293,21 +293,21 @@ class UrlGeneratorTest extends TestCase public function testGenerateForRouteWithoutMandatoryParameter() { - $this->expectException('Symfony\Component\Routing\Exception\MissingMandatoryParametersException'); + $this->expectException(\Symfony\Component\Routing\Exception\MissingMandatoryParametersException::class); $routes = $this->getRoutes('test', new Route('/testing/{foo}')); $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL); } public function testGenerateForRouteWithInvalidOptionalParameter() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+'])); $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL); } public function testGenerateForRouteWithInvalidParameter() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => '1|2'])); $this->getGenerator($routes)->generate('test', ['foo' => '0'], UrlGeneratorInterface::ABSOLUTE_URL); } @@ -323,7 +323,7 @@ class UrlGeneratorTest extends TestCase public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger() { $routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+'])); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger->expects($this->once()) ->method('error'); $generator = $this->getGenerator($routes, [], $logger); @@ -341,21 +341,21 @@ class UrlGeneratorTest extends TestCase public function testGenerateForRouteWithInvalidMandatoryParameter() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => 'd+'])); $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL); } public function testGenerateForRouteWithInvalidUtf8Parameter() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => '\pL+'], ['utf8' => true])); $this->getGenerator($routes)->generate('test', ['foo' => 'abc123'], UrlGeneratorInterface::ABSOLUTE_URL); } public function testRequiredParamAndEmptyPassed() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/{slug}', [], ['slug' => '.+'])); $this->getGenerator($routes)->generate('test', ['slug' => '']); } @@ -476,7 +476,7 @@ class UrlGeneratorTest extends TestCase // The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything // and following optional variables like _format could never match. - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $generator->generate('test', ['x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml']); } @@ -517,7 +517,7 @@ class UrlGeneratorTest extends TestCase public function testImportantVariableWithNoDefault() { - $this->expectException('Symfony\Component\Routing\Exception\MissingMandatoryParametersException'); + $this->expectException(\Symfony\Component\Routing\Exception\MissingMandatoryParametersException::class); $routes = $this->getRoutes('test', new Route('/{page}.{!_format}')); $generator = $this->getGenerator($routes); @@ -526,14 +526,14 @@ class UrlGeneratorTest extends TestCase public function testDefaultRequirementOfVariableDisallowsSlash() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/{page}.{_format}')); $this->getGenerator($routes)->generate('test', ['page' => 'index', '_format' => 'sl/ash']); } public function testDefaultRequirementOfVariableDisallowsNextSeparator() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/{page}.{_format}')); $this->getGenerator($routes)->generate('test', ['page' => 'do.t', '_format' => 'html']); } @@ -561,21 +561,21 @@ class UrlGeneratorTest extends TestCase public function testUrlWithInvalidParameterInHost() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/', [], ['foo' => 'bar'], [], '{foo}.example.com')); $this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH); } public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/', ['foo' => 'bar'], ['foo' => 'bar'], [], '{foo}.example.com')); $this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH); } public function testUrlWithInvalidParameterEqualsDefaultValueInHost() { - $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException'); + $this->expectException(\Symfony\Component\Routing\Exception\InvalidParameterException::class); $routes = $this->getRoutes('test', new Route('/', ['foo' => 'baz'], ['foo' => 'bar'], [], '{foo}.example.com')); $this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH); } diff --git a/src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php index 0ce4a47ec1..8b26c209d3 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php @@ -17,7 +17,7 @@ abstract class AbstractAnnotationLoaderTest extends TestCase { public function getReader() { - return $this->getMockBuilder('Doctrine\Common\Annotations\Reader') + return $this->getMockBuilder(\Doctrine\Common\Annotations\Reader::class) ->disableOriginalConstructor() ->getMock() ; @@ -25,7 +25,7 @@ abstract class AbstractAnnotationLoaderTest extends TestCase public function getClassLoader($reader) { - return $this->getMockBuilder('Symfony\Component\Routing\Loader\AnnotationClassLoader') + return $this->getMockBuilder(\Symfony\Component\Routing\Loader\AnnotationClassLoader::class) ->setConstructorArgs([$reader]) ->getMockForAbstractClass() ; diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php index 47f7921737..ff2dd53909 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php @@ -44,7 +44,7 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest public function testLoadFileWithoutStartTag() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Did you forgot to add the "loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/NoStartTagClass.php'); } diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php index 24c261e78b..59994370b5 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php @@ -45,7 +45,7 @@ class ObjectLoaderTest extends TestCase */ public function testExceptionWithoutSyntax(string $resourceString) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $loader = new TestObjectLoader(); $loader->load($resourceString); } @@ -72,7 +72,7 @@ class ObjectLoaderTest extends TestCase public function testExceptionOnBadMethod() { - $this->expectException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); $loader = new TestObjectLoader(); $loader->loaderMap = ['my_service' => new \stdClass()]; $loader->load('my_service::method'); @@ -80,8 +80,8 @@ class ObjectLoaderTest extends TestCase public function testExceptionOnMethodNotReturningCollection() { - $this->expectException('LogicException'); - $service = $this->getMockBuilder('stdClass') + $this->expectException(\LogicException::class); + $service = $this->getMockBuilder(\stdClass::class) ->setMethods(['loadRoutes']) ->getMock(); $service->expects($this->once()) diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php index 76f7d6501d..cca978fb75 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php @@ -73,7 +73,7 @@ class ObjectRouteLoaderTest extends TestCase */ public function testExceptionWithoutSyntax(string $resourceString) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $loader = new TestObjectRouteLoader(); $loader->load($resourceString); } @@ -100,7 +100,7 @@ class ObjectRouteLoaderTest extends TestCase public function testExceptionOnBadMethod() { - $this->expectException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); $loader = new TestObjectRouteLoader(); $loader->loaderMap = ['my_service' => new \stdClass()]; $loader->load('my_service::method'); @@ -108,8 +108,8 @@ class ObjectRouteLoaderTest extends TestCase public function testExceptionOnMethodNotReturningCollection() { - $this->expectException('LogicException'); - $service = $this->getMockBuilder('stdClass') + $this->expectException(\LogicException::class); + $service = $this->getMockBuilder(\stdClass::class) ->setMethods(['loadRoutes']) ->getMock(); $service->expects($this->once()) diff --git a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php index b84d5ff354..e48114abd2 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php @@ -22,7 +22,7 @@ class PhpFileLoaderTest extends TestCase { public function testSupports() { - $loader = new PhpFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock()); + $loader = new PhpFileLoader($this->getMockBuilder(FileLocator::class)->getMock()); $this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable'); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index 383cda0176..1a8e4bb5df 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -23,7 +23,7 @@ class XmlFileLoaderTest extends TestCase { public function testSupports() { - $loader = new XmlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock()); + $loader = new XmlFileLoader($this->getMockBuilder(FileLocator::class)->getMock()); $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); @@ -38,7 +38,7 @@ class XmlFileLoaderTest extends TestCase $routeCollection = $loader->load('validpattern.xml'); $route = $routeCollection->get('blog_show'); - $this->assertInstanceOf('Symfony\Component\Routing\Route', $route); + $this->assertInstanceOf(Route::class, $route); $this->assertSame('/blog/{slug}', $route->getPath()); $this->assertSame('{locale}.example.com', $route->getHost()); $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); @@ -211,7 +211,7 @@ class XmlFileLoaderTest extends TestCase */ public function testLoadThrowsExceptionWithInvalidFile($filePath) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures'])); $loader->load($filePath); } @@ -221,7 +221,7 @@ class XmlFileLoaderTest extends TestCase */ public function testLoadThrowsExceptionWithInvalidFileEvenWithoutSchemaValidation($filePath) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $loader = new CustomXmlFileLoader(new FileLocator([__DIR__.'/../Fixtures'])); $loader->load($filePath); } @@ -233,7 +233,7 @@ class XmlFileLoaderTest extends TestCase public function testDocTypeIsNotAllowed() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Document types are not allowed.'); $loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures'])); $loader->load('withdoctype.xml'); @@ -441,7 +441,7 @@ class XmlFileLoaderTest extends TestCase public function testOverrideControllerInDefaults() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for "app_blog"/'); $loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller'])); $loader->load('override_defaults.xml'); @@ -473,7 +473,7 @@ class XmlFileLoaderTest extends TestCase public function testImportWithOverriddenController() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for the "import" tag/'); $loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller'])); $loader->load('import_override_defaults.xml'); diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php index e5571b0b7a..7030265cf7 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php @@ -22,7 +22,7 @@ class YamlFileLoaderTest extends TestCase { public function testSupports() { - $loader = new YamlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock()); + $loader = new YamlFileLoader($this->getMockBuilder(FileLocator::class)->getMock()); $this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable'); $this->assertTrue($loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable'); @@ -47,7 +47,7 @@ class YamlFileLoaderTest extends TestCase */ public function testLoadThrowsExceptionWithInvalidFile($filePath) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures'])); $loader->load($filePath); } @@ -71,7 +71,7 @@ class YamlFileLoaderTest extends TestCase $routeCollection = $loader->load('special_route_name.yml'); $route = $routeCollection->get('#$péß^a|'); - $this->assertInstanceOf('Symfony\Component\Routing\Route', $route); + $this->assertInstanceOf(Route::class, $route); $this->assertSame('/true', $route->getPath()); } @@ -81,7 +81,7 @@ class YamlFileLoaderTest extends TestCase $routeCollection = $loader->load('validpattern.yml'); $route = $routeCollection->get('blog_show'); - $this->assertInstanceOf('Symfony\Component\Routing\Route', $route); + $this->assertInstanceOf(Route::class, $route); $this->assertSame('/blog/{slug}', $route->getPath()); $this->assertSame('{locale}.example.com', $route->getHost()); $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); @@ -143,7 +143,7 @@ class YamlFileLoaderTest extends TestCase public function testOverrideControllerInDefaults() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "app_blog"/'); $loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller'])); $loader->load('override_defaults.yml'); @@ -175,7 +175,7 @@ class YamlFileLoaderTest extends TestCase public function testImportWithOverriddenController() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "_static"/'); $loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller'])); $loader->load('import_override_defaults.yml'); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php index f0c046e0b3..fd43439b25 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php @@ -492,7 +492,7 @@ class CompiledUrlMatcherDumperTest extends TestCase public function testGenerateDumperMatcherWithObject() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Symfony\Component\Routing\Route cannot contain objects'); $routeCollection = new RouteCollection(); $routeCollection->add('_', new Route('/', [new \stdClass()])); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index 5665ebef37..59654c4c54 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -494,7 +494,7 @@ class PhpMatcherDumperTest extends TestCase public function testGenerateDumperMatcherWithObject() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Symfony\Component\Routing\Route cannot contain objects'); $routeCollection = new RouteCollection(); $routeCollection->add('_', new Route('/', [new \stdClass()])); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php index 1461b4b911..83dfe2d62d 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php @@ -39,7 +39,7 @@ class RedirectableUrlMatcherTest extends UrlMatcherTest public function testRedirectWhenNoSlashForNonSafeMethod() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(\Symfony\Component\Routing\Exception\ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('foo', new Route('/foo/')); @@ -209,6 +209,6 @@ class RedirectableUrlMatcherTest extends UrlMatcherTest protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null) { - return $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', [$routes, $context ?: new RequestContext()]); + return $this->getMockForAbstractClass(\Symfony\Component\Routing\Matcher\RedirectableUrlMatcher::class, [$routes, $context ?: new RequestContext()]); } } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index c6846ae8b5..3adb4a9d58 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -198,7 +198,7 @@ class UrlMatcherTest extends TestCase public function testShortPathDoesNotMatchImportantVariable() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $collection = new RouteCollection(); $collection->add('index', new Route('/index.{!_format}', ['_format' => 'xml'])); @@ -208,7 +208,7 @@ class UrlMatcherTest extends TestCase public function testTrailingEncodedNewlineIsNotOverlooked() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $collection = new RouteCollection(); $collection->add('foo', new Route('/foo')); @@ -249,7 +249,7 @@ class UrlMatcherTest extends TestCase $matcher = $this->getUrlMatcher($collection); $this->assertEquals(['_route' => 'foo'], $matcher->match('/foo1')); - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $this->assertEquals([], $matcher->match('/foo')); } @@ -318,7 +318,7 @@ class UrlMatcherTest extends TestCase // z and _format are optional. $this->assertEquals(['w' => 'wwwww', 'x' => 'x', 'y' => 'y', 'z' => 'default-z', '_format' => 'html', '_route' => 'test'], $matcher->match('/wwwwwxy')); - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $matcher->match('/wxy.html'); } @@ -333,7 +333,7 @@ class UrlMatcherTest extends TestCase // Usually the character in front of an optional parameter can be left out, e.g. with pattern '/get/{what}' just '/get' would match. // But here the 't' in 'get' is not a separating character, so it makes no sense to match without it. - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $matcher->match('/ge'); } @@ -357,7 +357,7 @@ class UrlMatcherTest extends TestCase public function testDefaultRequirementOfVariableDisallowsSlash() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('test', new Route('/{page}.{_format}')); $matcher = $this->getUrlMatcher($coll); @@ -367,7 +367,7 @@ class UrlMatcherTest extends TestCase public function testDefaultRequirementOfVariableDisallowsNextSeparator() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('test', new Route('/{page}.{_format}', [], ['_format' => 'html|xml'])); $matcher = $this->getUrlMatcher($coll); @@ -377,7 +377,7 @@ class UrlMatcherTest extends TestCase public function testMissingTrailingSlash() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('foo', new Route('/foo/')); @@ -387,7 +387,7 @@ class UrlMatcherTest extends TestCase public function testExtraTrailingSlash() { - $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->getExpectedException() ?: $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('foo', new Route('/foo')); @@ -397,7 +397,7 @@ class UrlMatcherTest extends TestCase public function testMissingTrailingSlashForNonSafeMethod() { - $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->getExpectedException() ?: $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('foo', new Route('/foo/')); @@ -409,7 +409,7 @@ class UrlMatcherTest extends TestCase public function testExtraTrailingSlashForNonSafeMethod() { - $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->getExpectedException() ?: $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('foo', new Route('/foo')); @@ -421,7 +421,7 @@ class UrlMatcherTest extends TestCase public function testSchemeRequirement() { - $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->getExpectedException() ?: $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('foo', new Route('/foo', [], [], [], '', ['https'])); $matcher = $this->getUrlMatcher($coll); @@ -430,7 +430,7 @@ class UrlMatcherTest extends TestCase public function testSchemeRequirementForNonSafeMethod() { - $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->getExpectedException() ?: $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('foo', new Route('/foo', [], [], [], '', ['https'])); @@ -451,7 +451,7 @@ class UrlMatcherTest extends TestCase public function testCondition() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $route = new Route('/foo'); $route->setCondition('context.getMethod() == "POST"'); @@ -658,7 +658,7 @@ class UrlMatcherTest extends TestCase public function testWithOutHostHostDoesNotMatch() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('foo', new Route('/foo/{foo}', [], [], [], '{locale}.example.com')); @@ -668,7 +668,7 @@ class UrlMatcherTest extends TestCase public function testPathIsCaseSensitive() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $coll = new RouteCollection(); $coll->add('foo', new Route('/locale', [], ['locale' => 'EN|FR|DE'])); @@ -687,7 +687,7 @@ class UrlMatcherTest extends TestCase public function testNoConfiguration() { - $this->expectException('Symfony\Component\Routing\Exception\NoConfigurationException'); + $this->expectException(\Symfony\Component\Routing\Exception\NoConfigurationException::class); $coll = new RouteCollection(); $matcher = $this->getUrlMatcher($coll); @@ -720,7 +720,7 @@ class UrlMatcherTest extends TestCase public function testSchemeAndMethodMismatch() { - $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); + $this->expectException(ResourceNotFoundException::class); $this->expectExceptionMessage('No routes found for "/".'); $coll = new RouteCollection(); $coll->add('foo', new Route('/', [], [], [], null, ['https'], ['POST'])); diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php index 395f4ab97a..f995d94d1d 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php @@ -23,8 +23,8 @@ class RouteCollectionBuilderTest extends TestCase { public function testImport() { - $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); + $resolvedLoader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); + $resolver = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderResolverInterface::class)->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('admin_routing.yml', 'yaml') @@ -41,7 +41,7 @@ class RouteCollectionBuilderTest extends TestCase ->with('admin_routing.yml', 'yaml') ->willReturn($expectedCollection); - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $loader->expects($this->any()) ->method('getResolver') ->willReturn($resolver); @@ -51,7 +51,7 @@ class RouteCollectionBuilderTest extends TestCase $importedRoutes = $routes->import('admin_routing.yml', '/', 'yaml'); // we should get back a RouteCollectionBuilder - $this->assertInstanceOf('Symfony\Component\Routing\RouteCollectionBuilder', $importedRoutes); + $this->assertInstanceOf(RouteCollectionBuilder::class, $importedRoutes); // get the collection back so we can look at it $addedCollection = $importedRoutes->build(); @@ -77,7 +77,7 @@ class RouteCollectionBuilderTest extends TestCase public function testImportWithoutLoaderThrowsException() { - $this->expectException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); $collectionBuilder = new RouteCollectionBuilder(); $collectionBuilder->import('routing.yml'); } @@ -88,7 +88,7 @@ class RouteCollectionBuilderTest extends TestCase $addedRoute = $collectionBuilder->add('/checkout', 'AppBundle:Order:checkout'); $addedRoute2 = $collectionBuilder->add('/blogs', 'AppBundle:Blog:list', 'blog_list'); - $this->assertInstanceOf('Symfony\Component\Routing\Route', $addedRoute); + $this->assertInstanceOf(Route::class, $addedRoute); $this->assertEquals('AppBundle:Order:checkout', $addedRoute->getDefault('_controller')); $finalCollection = $collectionBuilder->build(); @@ -101,7 +101,7 @@ class RouteCollectionBuilderTest extends TestCase $importedCollection->add('imported_route1', new Route('/imported/foo1')); $importedCollection->add('imported_route2', new Route('/imported/foo2')); - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); // make this loader able to do the import - keeps mocking simple $loader->expects($this->any()) ->method('supports') @@ -264,7 +264,7 @@ class RouteCollectionBuilderTest extends TestCase public function testFlushSetsPrefixedWithMultipleLevels() { - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $routes = new RouteCollectionBuilder($loader); $routes->add('homepage', 'MainController::homepageAction', 'homepage'); @@ -342,7 +342,7 @@ class RouteCollectionBuilderTest extends TestCase $secondCollection = new RouteCollection(); $secondCollection->add('b', new Route('/b')); - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $loader->expects($this->any()) ->method('supports') ->willReturn(true); diff --git a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php index 3cfcfc05c6..875c2f908a 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -22,7 +22,7 @@ class RouteCompilerTest extends TestCase */ public function testCompile($name, $arguments, $prefix, $regex, $variables, $tokens) { - $r = new \ReflectionClass('Symfony\\Component\\Routing\\Route'); + $r = new \ReflectionClass(Route::class); $route = $r->newInstanceArgs($arguments); $compiled = $route->compile(); @@ -188,8 +188,8 @@ class RouteCompilerTest extends TestCase */ public function testCompileImplicitUtf8Data($name, $arguments, $prefix, $regex, $variables, $tokens, $deprecationType) { - $this->expectException('LogicException'); - $r = new \ReflectionClass('Symfony\\Component\\Routing\\Route'); + $this->expectException(\LogicException::class); + $r = new \ReflectionClass(Route::class); $route = $r->newInstanceArgs($arguments); $compiled = $route->compile(); @@ -244,7 +244,7 @@ class RouteCompilerTest extends TestCase public function testRouteWithSameVariableTwice() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $route = new Route('/{name}/{name}'); $route->compile(); @@ -252,7 +252,7 @@ class RouteCompilerTest extends TestCase public function testRouteCharsetMismatch() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $route = new Route("/\xE9/{bar}", [], ['bar' => '.'], ['utf8' => true]); $route->compile(); @@ -260,7 +260,7 @@ class RouteCompilerTest extends TestCase public function testRequirementCharsetMismatch() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $route = new Route('/foo/{bar}', [], ['bar' => "\xE9"], ['utf8' => true]); $route->compile(); @@ -268,7 +268,7 @@ class RouteCompilerTest extends TestCase public function testRouteWithFragmentAsPathParameter() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $route = new Route('/{_fragment}'); $route->compile(); @@ -279,7 +279,7 @@ class RouteCompilerTest extends TestCase */ public function testRouteWithVariableNameStartingWithADigit($name) { - $this->expectException('DomainException'); + $this->expectException(\DomainException::class); $route = new Route('/{'.$name.'}'); $route->compile(); } @@ -298,7 +298,7 @@ class RouteCompilerTest extends TestCase */ public function testCompileWithHost($name, $arguments, $prefix, $regex, $variables, $pathVariables, $tokens, $hostRegex, $hostVariables, $hostTokens) { - $r = new \ReflectionClass('Symfony\\Component\\Routing\\Route'); + $r = new \ReflectionClass(Route::class); $route = $r->newInstanceArgs($arguments); $compiled = $route->compile(); @@ -366,7 +366,7 @@ class RouteCompilerTest extends TestCase public function testRouteWithTooLongVariableName() { - $this->expectException('DomainException'); + $this->expectException(\DomainException::class); $route = new Route(sprintf('/{%s}', str_repeat('a', RouteCompiler::VARIABLE_MAXIMUM_LENGTH + 1))); $route->compile(); } diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php index 33341ea491..a630afefca 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -129,7 +129,7 @@ class RouteTest extends TestCase */ public function testSetInvalidRequirement($req) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $route = new Route('/{foo}'); $route->setRequirement('foo', $req); } @@ -188,7 +188,7 @@ class RouteTest extends TestCase public function testCompile() { $route = new Route('/{foo}'); - $this->assertInstanceOf('Symfony\Component\Routing\CompiledRoute', $compiled = $route->compile(), '->compile() returns a compiled route'); + $this->assertInstanceOf(\Symfony\Component\Routing\CompiledRoute::class, $compiled = $route->compile(), '->compile() returns a compiled route'); $this->assertSame($compiled, $route->compile(), '->compile() only compiled the route once if unchanged'); $route->setRequirement('foo', '.*'); $this->assertNotSame($compiled, $route->compile(), '->compile() recompiles if the route was modified'); diff --git a/src/Symfony/Component/Routing/Tests/RouterTest.php b/src/Symfony/Component/Routing/Tests/RouterTest.php index 0d7c4bee45..9c8dda7ac1 100644 --- a/src/Symfony/Component/Routing/Tests/RouterTest.php +++ b/src/Symfony/Component/Routing/Tests/RouterTest.php @@ -26,7 +26,7 @@ class RouterTest extends TestCase protected function setUp(): void { - $this->loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); + $this->loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock(); $this->router = new Router($this->loader, 'routing.yml'); $this->cacheDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('router_', true); @@ -59,7 +59,7 @@ class RouterTest extends TestCase public function testSetOptionsWithUnsupportedOptions() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The Router does not support the following options: "option_foo", "option_bar"'); $this->router->setOptions([ 'cache_dir' => './cache', @@ -78,14 +78,14 @@ class RouterTest extends TestCase public function testSetOptionWithUnsupportedOption() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The Router does not support the "option_foo" option'); $this->router->setOption('option_foo', true); } public function testGetOptionWithUnsupportedOption() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The Router does not support the "option_foo" option'); $this->router->getOption('option_foo', true); } @@ -111,7 +111,7 @@ class RouterTest extends TestCase ->method('load')->with('routing.yml', null) ->willReturn(new RouteCollection()); - $this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher()); + $this->assertInstanceOf(\Symfony\Component\Routing\Matcher\UrlMatcher::class, $this->router->getMatcher()); } public function testGeneratorIsCreatedIfCacheIsNotConfigured() @@ -122,12 +122,12 @@ class RouterTest extends TestCase ->method('load')->with('routing.yml', null) ->willReturn(new RouteCollection()); - $this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator()); + $this->assertInstanceOf(\Symfony\Component\Routing\Generator\UrlGenerator::class, $this->router->getGenerator()); } public function testMatchRequestWithUrlMatcherInterface() { - $matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); + $matcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\UrlMatcherInterface::class)->getMock(); $matcher->expects($this->once())->method('match'); $p = new \ReflectionProperty($this->router, 'matcher'); @@ -139,7 +139,7 @@ class RouterTest extends TestCase public function testMatchRequestWithRequestMatcherInterface() { - $matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $matcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $matcher->expects($this->once())->method('matchRequest'); $p = new \ReflectionProperty($this->router, 'matcher'); @@ -161,7 +161,7 @@ class RouterTest extends TestCase $generator = $router->getGenerator(); - $this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGeneratorInterface', $generator); + $this->assertInstanceOf(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class, $generator); $p = new \ReflectionProperty($generator, 'defaultLocale'); $p->setAccessible(true); @@ -181,7 +181,7 @@ class RouterTest extends TestCase $generator = $router->getGenerator(); - $this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGeneratorInterface', $generator); + $this->assertInstanceOf(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class, $generator); $p = new \ReflectionProperty($generator, 'defaultLocale'); $p->setAccessible(true); @@ -205,7 +205,7 @@ class RouterTest extends TestCase $generator = $router->getGenerator(); - $this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGeneratorInterface', $generator); + $this->assertInstanceOf(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class, $generator); $p = new \ReflectionProperty($generator, 'defaultLocale'); $p->setAccessible(true); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php index e454852ddf..e7f13b8e6d 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php @@ -26,13 +26,13 @@ class AuthenticationProviderManagerTest extends TestCase { public function testAuthenticateWithoutProviders() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new AuthenticationProviderManager([]); } public function testAuthenticateWithProvidersWithIncorrectInterface() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); (new AuthenticationProviderManager([ new \stdClass(), ]))->authenticate($this->getMockBuilder(TokenInterface::class)->getMock()); @@ -45,7 +45,7 @@ class AuthenticationProviderManagerTest extends TestCase ]); try { - $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $manager->authenticate($token = $this->getMockBuilder(TokenInterface::class)->getMock()); $this->fail(); } catch (ProviderNotFoundException $e) { $this->assertSame($token, $e->getToken()); @@ -54,7 +54,7 @@ class AuthenticationProviderManagerTest extends TestCase public function testAuthenticateWhenProviderReturnsAccountStatusException() { - $secondAuthenticationProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock(); + $secondAuthenticationProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock(); $manager = new AuthenticationProviderManager([ $this->getAuthenticationProvider(true, null, 'Symfony\Component\Security\Core\Exception\AccountStatusException'), @@ -65,7 +65,7 @@ class AuthenticationProviderManagerTest extends TestCase $secondAuthenticationProvider->expects($this->never())->method('supports'); try { - $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $manager->authenticate($token = $this->getMockBuilder(TokenInterface::class)->getMock()); $this->fail(); } catch (AccountStatusException $e) { $this->assertSame($token, $e->getToken()); @@ -79,7 +79,7 @@ class AuthenticationProviderManagerTest extends TestCase ]); try { - $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $manager->authenticate($token = $this->getMockBuilder(TokenInterface::class)->getMock()); $this->fail(); } catch (AuthenticationException $e) { $this->assertSame($token, $e->getToken()); @@ -90,26 +90,26 @@ class AuthenticationProviderManagerTest extends TestCase { $manager = new AuthenticationProviderManager([ $this->getAuthenticationProvider(true, null, 'Symfony\Component\Security\Core\Exception\AuthenticationException'), - $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()), + $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder(TokenInterface::class)->getMock()), ]); - $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $token = $manager->authenticate($this->getMockBuilder(TokenInterface::class)->getMock()); $this->assertSame($expected, $token); } public function testAuthenticateReturnsTokenOfTheFirstMatchingProvider() { - $second = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock(); + $second = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock(); $second ->expects($this->never()) ->method('supports') ; $manager = new AuthenticationProviderManager([ - $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()), + $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder(TokenInterface::class)->getMock()), $second, ]); - $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $token = $manager->authenticate($this->getMockBuilder(TokenInterface::class)->getMock()); $this->assertSame($expected, $token); } @@ -119,25 +119,25 @@ class AuthenticationProviderManagerTest extends TestCase $this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')), ]); - $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $token = $manager->authenticate($this->getMockBuilder(TokenInterface::class)->getMock()); $this->assertEquals('', $token->getCredentials()); $manager = new AuthenticationProviderManager([ $this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')), ], false); - $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $token = $manager->authenticate($this->getMockBuilder(TokenInterface::class)->getMock()); $this->assertEquals('bar', $token->getCredentials()); } public function testAuthenticateDispatchesAuthenticationFailureEvent() { $token = new UsernamePasswordToken('foo', 'bar', 'key'); - $provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock(); + $provider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock(); $provider->expects($this->once())->method('supports')->willReturn(true); $provider->expects($this->once())->method('authenticate')->willThrowException($exception = new AuthenticationException()); - $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); $dispatcher ->expects($this->once()) ->method('dispatch') @@ -158,11 +158,11 @@ class AuthenticationProviderManagerTest extends TestCase { $token = new UsernamePasswordToken('foo', 'bar', 'key'); - $provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock(); + $provider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock(); $provider->expects($this->once())->method('supports')->willReturn(true); $provider->expects($this->once())->method('authenticate')->willReturn($token); - $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); $dispatcher ->expects($this->once()) ->method('dispatch') @@ -176,7 +176,7 @@ class AuthenticationProviderManagerTest extends TestCase protected function getAuthenticationProvider($supports, $token = null, $exception = null) { - $provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock(); + $provider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock(); $provider->expects($this->once()) ->method('supports') ->willReturn($supports) diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php index 51790688e7..ca352da31f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php @@ -124,17 +124,17 @@ class AuthenticationTrustResolverTest extends TestCase protected function getToken() { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + return $this->getMockBuilder(TokenInterface::class)->getMock(); } protected function getAnonymousToken() { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(['', ''])->getMock(); + return $this->getMockBuilder(AnonymousToken::class)->setConstructorArgs(['', ''])->getMock(); } protected function getRememberMeToken() { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(RememberMeToken::class)->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock(); } protected function getResolver() diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php index 85ed848a79..e0fe4a8a11 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php @@ -21,21 +21,21 @@ class AnonymousAuthenticationProviderTest extends TestCase $provider = $this->getProvider('foo'); $this->assertTrue($provider->supports($this->getSupportedToken('foo'))); - $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); + $this->assertFalse($provider->supports($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock())); } public function testAuthenticateWhenTokenIsNotSupported() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class); $this->expectExceptionMessage('The token is not supported by this authentication provider.'); $provider = $this->getProvider('foo'); - $provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $provider->authenticate($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); } public function testAuthenticateWhenSecretIsNotValid() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $provider = $this->getProvider('foo'); $provider->authenticate($this->getSupportedToken('bar')); @@ -51,7 +51,7 @@ class AnonymousAuthenticationProviderTest extends TestCase protected function getSupportedToken($secret) { - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(['getSecret'])->disableOriginalConstructor()->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\AnonymousToken::class)->setMethods(['getSecret'])->disableOriginalConstructor()->getMock(); $token->expects($this->any()) ->method('getSecret') ->willReturn($secret) diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php index 827de3073e..37f690d0b5 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php @@ -24,7 +24,7 @@ class DaoAuthenticationProviderTest extends TestCase { public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationServiceException::class); $provider = $this->getProvider('fabien'); $method = new \ReflectionMethod($provider, 'retrieveUser'); $method->setAccessible(true); @@ -34,14 +34,14 @@ class DaoAuthenticationProviderTest extends TestCase public function testRetrieveUserWhenUsernameIsNotFound() { - $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); - $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); + $this->expectException(UsernameNotFoundException::class); + $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') ->willThrowException(new UsernameNotFoundException()) ; - $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); + $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(), 'key', $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock()); $method = new \ReflectionMethod($provider, 'retrieveUser'); $method->setAccessible(true); @@ -50,14 +50,14 @@ class DaoAuthenticationProviderTest extends TestCase public function testRetrieveUserWhenAnExceptionOccurs() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException'); - $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationServiceException::class); + $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') ->willThrowException(new \RuntimeException()) ; - $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); + $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(), 'key', $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock()); $method = new \ReflectionMethod($provider, 'retrieveUser'); $method->setAccessible(true); @@ -66,19 +66,19 @@ class DaoAuthenticationProviderTest extends TestCase public function testRetrieveUserReturnsUserFromTokenOnReauthentication() { - $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); + $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); $userProvider->expects($this->never()) ->method('loadUserByUsername') ; - $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getUser') ->willReturn($user) ; - $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); + $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(), 'key', $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock()); $reflection = new \ReflectionMethod($provider, 'retrieveUser'); $reflection->setAccessible(true); $result = $reflection->invoke($provider, null, $token); @@ -88,15 +88,15 @@ class DaoAuthenticationProviderTest extends TestCase public function testRetrieveUser() { - $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); - $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); + $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') ->willReturn($user) ; - $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); + $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(), 'key', $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock()); $method = new \ReflectionMethod($provider, 'retrieveUser'); $method->setAccessible(true); @@ -105,8 +105,8 @@ class DaoAuthenticationProviderTest extends TestCase public function testCheckAuthenticationWhenCredentialsAreEmpty() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); - $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); + $encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock(); $encoder ->expects($this->never()) ->method('isPasswordValid') @@ -125,14 +125,14 @@ class DaoAuthenticationProviderTest extends TestCase $method->invoke( $provider, - $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(), $token ); } public function testCheckAuthenticationWhenCredentialsAre0() { - $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); + $encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock(); $encoder ->expects($this->once()) ->method('isPasswordValid') @@ -159,8 +159,8 @@ class DaoAuthenticationProviderTest extends TestCase public function testCheckAuthenticationWhenCredentialsAreNotValid() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); - $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); + $encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock(); $encoder->expects($this->once()) ->method('isPasswordValid') ->willReturn(false) @@ -181,8 +181,8 @@ class DaoAuthenticationProviderTest extends TestCase public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); - $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user->expects($this->once()) ->method('getPassword') ->willReturn('foo') @@ -193,7 +193,7 @@ class DaoAuthenticationProviderTest extends TestCase ->method('getUser') ->willReturn($user); - $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); + $dbUser = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $dbUser->expects($this->once()) ->method('getPassword') ->willReturn('newFoo') @@ -207,7 +207,7 @@ class DaoAuthenticationProviderTest extends TestCase public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithoutOriginalCredentials() { - $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user->expects($this->once()) ->method('getPassword') ->willReturn('foo') @@ -218,7 +218,7 @@ class DaoAuthenticationProviderTest extends TestCase ->method('getUser') ->willReturn($user); - $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); + $dbUser = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $dbUser->expects($this->once()) ->method('getPassword') ->willReturn('foo') @@ -232,7 +232,7 @@ class DaoAuthenticationProviderTest extends TestCase public function testCheckAuthentication() { - $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); + $encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock(); $encoder->expects($this->once()) ->method('isPasswordValid') ->willReturn(true) @@ -291,7 +291,7 @@ class DaoAuthenticationProviderTest extends TestCase protected function getSupportedToken() { - $mock = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken')->setMethods(['getCredentials', 'getUser', 'getProviderKey'])->disableOriginalConstructor()->getMock(); + $mock = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::class)->setMethods(['getCredentials', 'getUser', 'getProviderKey'])->disableOriginalConstructor()->getMock(); $mock ->expects($this->any()) ->method('getProviderKey') @@ -312,14 +312,14 @@ class DaoAuthenticationProviderTest extends TestCase } if (null === $userChecker) { - $userChecker = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); } if (null === $passwordEncoder) { $passwordEncoder = new PlaintextPasswordEncoder(); } - $encoderFactory = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock(); + $encoderFactory = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock(); $encoderFactory ->expects($this->any()) ->method('getEncoder') diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php index 065a04a263..e3f0d72134 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php @@ -30,11 +30,11 @@ class LdapBindAuthenticationProviderTest extends TestCase { public function testEmptyPasswordShouldThrowAnException() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $this->expectExceptionMessage('The presented password must not be empty.'); - $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'checkAuthentication'); @@ -45,11 +45,11 @@ class LdapBindAuthenticationProviderTest extends TestCase public function testNullPasswordShouldThrowAnException() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $this->expectExceptionMessage('The presented password must not be empty.'); - $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); - $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapInterface')->getMock(); - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); + $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); + $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock(); $provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap); $reflection = new \ReflectionMethod($provider, 'checkAuthentication'); @@ -60,7 +60,7 @@ class LdapBindAuthenticationProviderTest extends TestCase public function testBindFailureShouldThrowAnException() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $this->expectExceptionMessage('The presented password is invalid.'); $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); @@ -182,7 +182,7 @@ class LdapBindAuthenticationProviderTest extends TestCase public function testEmptyQueryResultShouldThrowAnException() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $this->expectExceptionMessage('The presented username is invalid.'); $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock(); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php index a11f3be2a0..0438a9dfea 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php @@ -22,9 +22,9 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase $provider = $this->getProvider(); $this->assertTrue($provider->supports($this->getSupportedToken())); - $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); + $this->assertFalse($provider->supports($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock())); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken') + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken::class) ->disableOriginalConstructor() ->getMock() ; @@ -38,23 +38,23 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase public function testAuthenticateWhenTokenIsNotSupported() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class); $this->expectExceptionMessage('The token is not supported by this authentication provider.'); $provider = $this->getProvider(); - $provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $provider->authenticate($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); } public function testAuthenticateWhenNoUserIsSet() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $provider = $this->getProvider(); $provider->authenticate($this->getSupportedToken('')); } public function testAuthenticate() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -63,7 +63,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase $provider = $this->getProvider($user); $token = $provider->authenticate($this->getSupportedToken('fabien', 'pass')); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken', $token); + $this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken::class, $token); $this->assertEquals('pass', $token->getCredentials()); $this->assertEquals('key', $token->getProviderKey()); $this->assertEquals([], $token->getRoleNames()); @@ -73,10 +73,10 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase public function testAuthenticateWhenUserCheckerThrowsException() { - $this->expectException('Symfony\Component\Security\Core\Exception\LockedException'); - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $this->expectException(LockedException::class); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); $userChecker->expects($this->once()) ->method('checkPostAuth') ->willThrowException(new LockedException()) @@ -89,7 +89,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase protected function getSupportedToken($user = false, $credentials = false) { - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')->setMethods(['getUser', 'getCredentials', 'getProviderKey'])->disableOriginalConstructor()->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken::class)->setMethods(['getUser', 'getCredentials', 'getProviderKey'])->disableOriginalConstructor()->getMock(); if (false !== $user) { $token->expects($this->once()) ->method('getUser') @@ -116,7 +116,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase protected function getProvider($user = null, $userChecker = null) { - $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $userProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); if (null !== $user) { $userProvider->expects($this->once()) ->method('loadUserByUsername') @@ -125,7 +125,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase } if (null === $userChecker) { - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); } return new PreAuthenticatedAuthenticationProvider($userProvider, $userChecker, 'key'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php index 3875522c4a..7832a87a14 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php @@ -24,23 +24,23 @@ class RememberMeAuthenticationProviderTest extends TestCase $provider = $this->getProvider(); $this->assertTrue($provider->supports($this->getSupportedToken())); - $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); - $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->disableOriginalConstructor()->getMock())); + $this->assertFalse($provider->supports($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock())); + $this->assertFalse($provider->supports($this->getMockBuilder(RememberMeToken::class)->disableOriginalConstructor()->getMock())); } public function testAuthenticateWhenTokenIsNotSupported() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class); $this->expectExceptionMessage('The token is not supported by this authentication provider.'); $provider = $this->getProvider(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $provider->authenticate($token); } public function testAuthenticateWhenSecretsDoNotMatch() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $provider = $this->getProvider(null, 'secret1'); $token = $this->getSupportedToken(null, 'secret2'); @@ -49,7 +49,7 @@ class RememberMeAuthenticationProviderTest extends TestCase public function testAuthenticateThrowsOnNonUserInterfaceInstance() { - $this->expectException('Symfony\Component\Security\Core\Exception\LogicException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\LogicException::class); $this->expectExceptionMessage('Method "Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::getUser()" must return a "Symfony\Component\Security\Core\User\UserInterface" instance, "string" returned.'); $provider = $this->getProvider(); @@ -60,8 +60,8 @@ class RememberMeAuthenticationProviderTest extends TestCase public function testAuthenticateWhenPreChecksFails() { - $this->expectException('Symfony\Component\Security\Core\Exception\DisabledException'); - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $this->expectException(DisabledException::class); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); $userChecker->expects($this->once()) ->method('checkPreAuth') ->willThrowException(new DisabledException()); @@ -73,7 +73,7 @@ class RememberMeAuthenticationProviderTest extends TestCase public function testAuthenticate() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user->expects($this->exactly(2)) ->method('getRoles') ->willReturn(['ROLE_FOO']); @@ -83,7 +83,7 @@ class RememberMeAuthenticationProviderTest extends TestCase $token = $this->getSupportedToken($user); $authToken = $provider->authenticate($token); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', $authToken); + $this->assertInstanceOf(RememberMeToken::class, $authToken); $this->assertSame($user, $authToken->getUser()); $this->assertEquals(['ROLE_FOO'], $authToken->getRoleNames()); $this->assertEquals('', $authToken->getCredentials()); @@ -92,14 +92,14 @@ class RememberMeAuthenticationProviderTest extends TestCase protected function getSupportedToken($user = null, $secret = 'test') { if (null === $user) { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user ->expects($this->any()) ->method('getRoles') ->willReturn([]); } - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['getProviderKey'])->setConstructorArgs([$user, 'foo', $secret])->getMock(); + $token = $this->getMockBuilder(RememberMeToken::class)->setMethods(['getProviderKey'])->setConstructorArgs([$user, 'foo', $secret])->getMock(); $token ->expects($this->once()) ->method('getProviderKey') @@ -111,7 +111,7 @@ class RememberMeAuthenticationProviderTest extends TestCase protected function getProvider($userChecker = null, $key = 'test') { if (null === $userChecker) { - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); } return new RememberMeAuthenticationProvider($userChecker, $key, 'foo'); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php index e167cf2026..f712bbcd1e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php @@ -24,20 +24,20 @@ class SimpleAuthenticationProviderTest extends TestCase { public function testAuthenticateWhenPreChecksFails() { - $this->expectException('Symfony\Component\Security\Core\Exception\DisabledException'); - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $this->expectException(DisabledException::class); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token->expects($this->any()) ->method('getUser') ->willReturn($user); - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); $userChecker->expects($this->once()) ->method('checkPreAuth') ->willThrowException(new DisabledException()); - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $authenticator = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface::class)->getMock(); $authenticator->expects($this->once()) ->method('authenticateToken') ->willReturn($token); @@ -49,20 +49,20 @@ class SimpleAuthenticationProviderTest extends TestCase public function testAuthenticateWhenPostChecksFails() { - $this->expectException('Symfony\Component\Security\Core\Exception\LockedException'); - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $this->expectException(LockedException::class); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token->expects($this->any()) ->method('getUser') ->willReturn($user); - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); $userChecker->expects($this->once()) ->method('checkPostAuth') ->willThrowException(new LockedException()); - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $authenticator = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface::class)->getMock(); $authenticator->expects($this->once()) ->method('authenticateToken') ->willReturn($token); @@ -74,11 +74,11 @@ class SimpleAuthenticationProviderTest extends TestCase public function testAuthenticateSkipsUserChecksForNonUserInterfaceObjects() { - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token->expects($this->any()) ->method('getUser') ->willReturn('string-user'); - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $authenticator = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface::class)->getMock(); $authenticator->expects($this->once()) ->method('authenticateToken') ->willReturn($token); @@ -89,13 +89,13 @@ class SimpleAuthenticationProviderTest extends TestCase protected function getProvider($simpleAuthenticator = null, $userProvider = null, $userChecker = null, $key = 'test') { if (null === $userChecker) { - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); } if (null === $simpleAuthenticator) { - $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $simpleAuthenticator = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface::class)->getMock(); } if (null === $userProvider) { - $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $userProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); } return new SimpleAuthenticationProvider($simpleAuthenticator, $userProvider, $key, $userChecker); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php index 8ec92d5014..19d6a61a25 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php @@ -26,21 +26,21 @@ class UserAuthenticationProviderTest extends TestCase $provider = $this->getProvider(); $this->assertTrue($provider->supports($this->getSupportedToken())); - $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); + $this->assertFalse($provider->supports($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock())); } public function testAuthenticateWhenTokenIsNotSupported() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class); $this->expectExceptionMessage('The token is not supported by this authentication provider.'); $provider = $this->getProvider(); - $provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $provider->authenticate($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); } public function testAuthenticateWhenUsernameIsNotFound() { - $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); + $this->expectException(UsernameNotFoundException::class); $provider = $this->getProvider(false, false); $provider->expects($this->once()) ->method('retrieveUser') @@ -52,7 +52,7 @@ class UserAuthenticationProviderTest extends TestCase public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(BadCredentialsException::class); $provider = $this->getProvider(false, true); $provider->expects($this->once()) ->method('retrieveUser') @@ -64,7 +64,7 @@ class UserAuthenticationProviderTest extends TestCase public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationServiceException::class); $provider = $this->getProvider(false, true); $provider->expects($this->once()) ->method('retrieveUser') @@ -76,8 +76,8 @@ class UserAuthenticationProviderTest extends TestCase public function testAuthenticateWhenPreChecksFails() { - $this->expectException('Symfony\Component\Security\Core\Exception\CredentialsExpiredException'); - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $this->expectException(CredentialsExpiredException::class); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); $userChecker->expects($this->once()) ->method('checkPreAuth') ->willThrowException(new CredentialsExpiredException()) @@ -86,7 +86,7 @@ class UserAuthenticationProviderTest extends TestCase $provider = $this->getProvider($userChecker); $provider->expects($this->once()) ->method('retrieveUser') - ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock()) ; $provider->authenticate($this->getSupportedToken()); @@ -94,8 +94,8 @@ class UserAuthenticationProviderTest extends TestCase public function testAuthenticateWhenPostChecksFails() { - $this->expectException('Symfony\Component\Security\Core\Exception\AccountExpiredException'); - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $this->expectException(AccountExpiredException::class); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); $userChecker->expects($this->once()) ->method('checkPostAuth') ->willThrowException(new AccountExpiredException()) @@ -104,7 +104,7 @@ class UserAuthenticationProviderTest extends TestCase $provider = $this->getProvider($userChecker); $provider->expects($this->once()) ->method('retrieveUser') - ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock()) ; $provider->authenticate($this->getSupportedToken()); @@ -112,12 +112,12 @@ class UserAuthenticationProviderTest extends TestCase public function testAuthenticateWhenPostCheckAuthenticationFails() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(BadCredentialsException::class); $this->expectExceptionMessage('Bad credentials'); $provider = $this->getProvider(); $provider->expects($this->once()) ->method('retrieveUser') - ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock()) ; $provider->expects($this->once()) ->method('checkAuthentication') @@ -129,12 +129,12 @@ class UserAuthenticationProviderTest extends TestCase public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(BadCredentialsException::class); $this->expectExceptionMessage('Foo'); $provider = $this->getProvider(false, false); $provider->expects($this->once()) ->method('retrieveUser') - ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock()) ; $provider->expects($this->once()) ->method('checkAuthentication') @@ -146,7 +146,7 @@ class UserAuthenticationProviderTest extends TestCase public function testAuthenticate() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user->expects($this->once()) ->method('getRoles') ->willReturn(['ROLE_FOO']) @@ -171,7 +171,7 @@ class UserAuthenticationProviderTest extends TestCase $authToken = $provider->authenticate($token); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $authToken); + $this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::class, $authToken); $this->assertSame($user, $authToken->getUser()); $this->assertEquals(['ROLE_FOO'], $authToken->getRoleNames()); $this->assertEquals('foo', $authToken->getCredentials()); @@ -183,7 +183,7 @@ class UserAuthenticationProviderTest extends TestCase */ public function testAuthenticateWithPreservingRoleSwitchUserRole() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user->expects($this->once()) ->method('getRoles') ->willReturn(['ROLE_FOO']) @@ -201,7 +201,7 @@ class UserAuthenticationProviderTest extends TestCase ->willReturn('foo') ; - $switchUserRole = new SwitchUserRole('foo', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $switchUserRole = new SwitchUserRole('foo', $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); $token->expects($this->once()) ->method('getRoles') ->willReturn([$switchUserRole]) @@ -209,7 +209,7 @@ class UserAuthenticationProviderTest extends TestCase $authToken = $provider->authenticate($token); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $authToken); + $this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::class, $authToken); $this->assertSame($user, $authToken->getUser()); $this->assertContains('ROLE_FOO', $authToken->getRoleNames()); $this->assertContains($switchUserRole, $authToken->getRoles()); @@ -219,7 +219,7 @@ class UserAuthenticationProviderTest extends TestCase public function testAuthenticatePreservesOriginalToken() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user->expects($this->once()) ->method('getRoles') ->willReturn(['ROLE_FOO']) @@ -231,8 +231,8 @@ class UserAuthenticationProviderTest extends TestCase ->willReturn($user) ; - $originalToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $token = new SwitchUserToken($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(), 'foo', 'key', [], $originalToken); + $originalToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); + $token = new SwitchUserToken($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(), 'foo', 'key', [], $originalToken); $token->setAttributes(['foo' => 'bar']); $authToken = $provider->authenticate($token); @@ -247,7 +247,7 @@ class UserAuthenticationProviderTest extends TestCase protected function getSupportedToken() { - $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken')->setMethods(['getCredentials', 'getProviderKey', 'getRoles'])->disableOriginalConstructor()->getMock(); + $mock = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::class)->setMethods(['getCredentials', 'getProviderKey', 'getRoles'])->disableOriginalConstructor()->getMock(); $mock ->expects($this->any()) ->method('getProviderKey') @@ -262,9 +262,9 @@ class UserAuthenticationProviderTest extends TestCase protected function getProvider($userChecker = false, $hide = true) { if (false === $userChecker) { - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); } - return $this->getMockForAbstractClass('Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider', [$userChecker, 'key', $hide]); + return $this->getMockForAbstractClass(\Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider::class, [$userChecker, 'key', $hide]); } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/InMemoryTokenProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/InMemoryTokenProviderTest.php index f5c7b98a28..ce686aac1f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/InMemoryTokenProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/InMemoryTokenProviderTest.php @@ -29,7 +29,7 @@ class InMemoryTokenProviderTest extends TestCase public function testLoadTokenBySeriesThrowsNotFoundException() { - $this->expectException('Symfony\Component\Security\Core\Exception\TokenNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\TokenNotFoundException::class); $provider = new InMemoryTokenProvider(); $provider->loadTokenBySeries('foo'); } @@ -49,7 +49,7 @@ class InMemoryTokenProviderTest extends TestCase public function testDeleteToken() { - $this->expectException('Symfony\Component\Security\Core\Exception\TokenNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\TokenNotFoundException::class); $provider = new InMemoryTokenProvider(); $token = new PersistentToken('foo', 'foo', 'foo', 'foo', new \DateTime()); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php index 3916d20337..b409aef6af 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php @@ -28,7 +28,7 @@ class AbstractTokenTest extends TestCase $token->setUser(new TestUser('fabien')); $this->assertEquals('fabien', $token->getUsername()); - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(UserInterface::class)->getMock(); $user->expects($this->once())->method('getUsername')->willReturn('fabien'); $token->setUser($user); $this->assertEquals('fabien', $token->getUsername()); @@ -38,7 +38,7 @@ class AbstractTokenTest extends TestCase { $token = new ConcreteToken(['ROLE_FOO']); - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(UserInterface::class)->getMock(); $user->expects($this->once())->method('eraseCredentials'); $token->setUser($user); @@ -151,7 +151,7 @@ class AbstractTokenTest extends TestCase public function getUsers() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(UserInterface::class)->getMock(); return [ [$user], @@ -178,7 +178,7 @@ class AbstractTokenTest extends TestCase public function getUserChanges() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(UserInterface::class)->getMock(); return [ ['foo', 'bar'], @@ -212,8 +212,8 @@ class AbstractTokenTest extends TestCase public function getUserChangesAdvancedUser() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $advancedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $user = $this->getMockBuilder(UserInterface::class)->getMock(); + $advancedUser = $this->getMockBuilder(\Symfony\Component\Security\Core\User\AdvancedUserInterface::class)->getMock(); return [ ['foo', 'bar'], diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php index 1fd962bbc8..ba634e5c79 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php @@ -30,7 +30,7 @@ class RememberMeTokenTest extends TestCase public function testConstructorSecretCannotBeEmptyString() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new RememberMeToken( $this->getUser(), '', @@ -40,7 +40,7 @@ class RememberMeTokenTest extends TestCase protected function getUser($roles = ['ROLE_FOO']) { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user ->expects($this->any()) ->method('getRoles') diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/UsernamePasswordTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/UsernamePasswordTokenTest.php index 53adc50835..03cbed7ca7 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/UsernamePasswordTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/UsernamePasswordTokenTest.php @@ -29,7 +29,7 @@ class UsernamePasswordTokenTest extends TestCase public function testSetAuthenticatedToTrue() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $token = new UsernamePasswordToken('foo', 'bar', 'key'); $token->setAuthenticated(true); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php index 48b452cb90..40b978085c 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php @@ -19,7 +19,7 @@ class AccessDecisionManagerTest extends TestCase { public function testSetUnsupportedStrategy() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new AccessDecisionManager([$this->getVoter(VoterInterface::ACCESS_GRANTED)], 'fooBar'); } @@ -28,7 +28,7 @@ class AccessDecisionManagerTest extends TestCase */ public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions, $expected) { - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $manager = new AccessDecisionManager($voters, $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions); $this->assertSame($expected, $manager->decide($token, ['ROLE_FOO'])); @@ -46,7 +46,7 @@ class AccessDecisionManagerTest extends TestCase public function getStrategiesWith2RolesTests() { - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); return [ [$token, 'affirmative', $this->getVoter(VoterInterface::ACCESS_DENIED), false], @@ -64,7 +64,7 @@ class AccessDecisionManagerTest extends TestCase protected function getVoterFor2Roles($token, $vote1, $vote2) { - $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock(); + $voter = $this->getMockBuilder(VoterInterface::class)->getMock(); $voter->expects($this->any()) ->method('vote') ->willReturnMap([ @@ -129,7 +129,7 @@ class AccessDecisionManagerTest extends TestCase protected function getVoter($vote) { - $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock(); + $voter = $this->getMockBuilder(VoterInterface::class)->getMock(); $voter->expects($this->any()) ->method('vote') ->willReturn($vote); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php index a6949bb301..25286065fd 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php @@ -25,8 +25,8 @@ class AuthorizationCheckerTest extends TestCase protected function setUp(): void { - $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); - $this->accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); + $this->authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); + $this->accessDecisionManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface::class)->getMock(); $this->tokenStorage = new TokenStorage(); $this->authorizationChecker = new AuthorizationChecker( @@ -69,7 +69,7 @@ class AuthorizationCheckerTest extends TestCase public function testVoteWithoutAuthenticationToken() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException::class); $this->authorizationChecker->isGranted('ROLE_FOO'); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php index 547c180657..7e78a398fe 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php @@ -55,11 +55,11 @@ class AuthenticatedVoterTest extends TestCase protected function getToken($authenticated) { if ('fully' === $authenticated) { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); } elseif ('remembered' === $authenticated) { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::class)->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock(); } else { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(['', ''])->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\AnonymousToken::class)->setConstructorArgs(['', ''])->getMock(); } } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php index b5bb2fe7c2..c979f6b039 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php @@ -59,7 +59,7 @@ class ExpressionVoterTest extends TestCase foreach ($roles as $i => $role) { $roles[$i] = new Role($role); } - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); if ($tokenExpectsGetRoles) { $token->expects($this->once()) @@ -85,7 +85,7 @@ class ExpressionVoterTest extends TestCase protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = true) { - $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\ExpressionLanguage')->getMock(); + $mock = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\ExpressionLanguage::class)->getMock(); if ($expressionLanguageExpectsEvaluate) { $mock->expects($this->once()) @@ -98,7 +98,7 @@ class ExpressionVoterTest extends TestCase protected function createTrustResolver() { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface::class)->getMock(); } protected function createAuthorizationChecker() @@ -108,7 +108,7 @@ class ExpressionVoterTest extends TestCase protected function createExpression() { - return $this->getMockBuilder('Symfony\Component\ExpressionLanguage\Expression') + return $this->getMockBuilder(\Symfony\Component\ExpressionLanguage\Expression::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php index 7f417b2dfa..90057ca0d5 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php @@ -80,7 +80,7 @@ class RoleVoterTest extends TestCase foreach ($roles as $i => $role) { $roles[$i] = new Role($role); } - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token->expects($this->once()) ->method('getRoles') ->willReturn($roles); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php index 63d4fb8b83..42ae1c63fb 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php @@ -22,7 +22,7 @@ class VoterTest extends TestCase protected function setUp(): void { - $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $this->token = $this->getMockBuilder(TokenInterface::class)->getMock(); } public function getTests() diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/Argon2iPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/Argon2iPasswordEncoderTest.php index a66932cc44..04ff8f9057 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/Argon2iPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/Argon2iPasswordEncoderTest.php @@ -48,7 +48,7 @@ class Argon2iPasswordEncoderTest extends TestCase public function testEncodePasswordLength() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $encoder = new Argon2iPasswordEncoder(); $encoder->encodePassword(str_repeat('a', 4097), 'salt'); } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php index d0372a86eb..9c4ed18c8a 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php @@ -26,13 +26,13 @@ class BCryptPasswordEncoderTest extends TestCase public function testCostBelowRange() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new BCryptPasswordEncoder(3); } public function testCostAboveRange() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new BCryptPasswordEncoder(32); } @@ -41,7 +41,7 @@ class BCryptPasswordEncoderTest extends TestCase */ public function testCostInRange($cost) { - $this->assertInstanceOf('Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder', new BCryptPasswordEncoder($cost)); + $this->assertInstanceOf(BCryptPasswordEncoder::class, new BCryptPasswordEncoder($cost)); } public function validRangeData() @@ -69,7 +69,7 @@ class BCryptPasswordEncoderTest extends TestCase public function testEncodePasswordLength() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $encoder = new BCryptPasswordEncoder(self::VALID_COST); $encoder->encodePassword(str_repeat('a', 73), 'salt'); diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php index 22d1881d65..bd45d66975 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php @@ -48,7 +48,7 @@ class BasePasswordEncoderTest extends TestCase public function testMergePasswordAndSaltWithException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->invokeMergePasswordAndSalt('password', '{foo}'); } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php index eb2dc498b4..3df2f21120 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php @@ -30,7 +30,7 @@ class EncoderFactoryTest extends TestCase 'arguments' => ['sha512', true, 5], ]]); - $encoder = $factory->getEncoder($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()); + $encoder = $factory->getEncoder($this->getMockBuilder(UserInterface::class)->getMock()); $expectedEncoder = new MessageDigestPasswordEncoder('sha512', true, 5); $this->assertEquals($expectedEncoder->encodePassword('foo', 'moo'), $encoder->encodePassword('foo', 'moo')); @@ -42,7 +42,7 @@ class EncoderFactoryTest extends TestCase 'Symfony\Component\Security\Core\User\UserInterface' => new MessageDigestPasswordEncoder('sha1'), ]); - $encoder = $factory->getEncoder($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()); + $encoder = $factory->getEncoder($this->getMockBuilder(UserInterface::class)->getMock()); $expectedEncoder = new MessageDigestPasswordEncoder('sha1'); $this->assertEquals($expectedEncoder->encodePassword('foo', ''), $encoder->encodePassword('foo', '')); @@ -112,7 +112,7 @@ class EncoderFactoryTest extends TestCase public function testGetInvalidNamedEncoderForEncoderAware() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $factory = new EncoderFactory([ 'Symfony\Component\Security\Core\Tests\Encoder\EncAwareUser' => new MessageDigestPasswordEncoder('sha1'), 'encoder_name' => new MessageDigestPasswordEncoder('sha256'), diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php index d1061c4211..0e2942b185 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php @@ -37,14 +37,14 @@ class MessageDigestPasswordEncoderTest extends TestCase public function testEncodePasswordAlgorithmDoesNotExist() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $encoder = new MessageDigestPasswordEncoder('foobar'); $encoder->encodePassword('password', ''); } public function testEncodePasswordLength() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $encoder = new MessageDigestPasswordEncoder(); $encoder->encodePassword(str_repeat('a', 5000), 'salt'); diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php index 7ee256f040..c67bf8668b 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php @@ -21,13 +21,13 @@ class NativePasswordEncoderTest extends TestCase { public function testCostBelowRange() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new NativePasswordEncoder(null, null, 3); } public function testCostAboveRange() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new NativePasswordEncoder(null, null, 32); } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php index 37a1f2d3cf..82ed24e3f5 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php @@ -37,14 +37,14 @@ class Pbkdf2PasswordEncoderTest extends TestCase public function testEncodePasswordAlgorithmDoesNotExist() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $encoder = new Pbkdf2PasswordEncoder('foobar'); $encoder->encodePassword('password', ''); } public function testEncodePasswordLength() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $encoder = new Pbkdf2PasswordEncoder('foobar'); $encoder->encodePassword(str_repeat('a', 5000), 'salt'); diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php index 3f6efccd49..40c038b65a 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php @@ -40,7 +40,7 @@ class PlaintextPasswordEncoderTest extends TestCase public function testEncodePasswordLength() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $encoder = new PlaintextPasswordEncoder(); $encoder->encodePassword(str_repeat('a', 5000), 'salt'); diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php index 2c4527fef7..b2c5bd186b 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php @@ -49,7 +49,7 @@ class SodiumPasswordEncoderTest extends TestCase public function testEncodePasswordLength() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $encoder = new SodiumPasswordEncoder(); $encoder->encodePassword(str_repeat('a', 4097), 'salt'); } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php index fb98c0bda2..2c0a265f3f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php @@ -21,18 +21,18 @@ class UserPasswordEncoderTest extends TestCase { public function testEncodePassword() { - $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $userMock = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $userMock->expects($this->any()) ->method('getSalt') ->willReturn('userSalt'); - $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); + $mockEncoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock(); $mockEncoder->expects($this->any()) ->method('encodePassword') ->with($this->equalTo('plainPassword'), $this->equalTo('userSalt')) ->willReturn('encodedPassword'); - $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); + $mockEncoderFactory = $this->getMockBuilder(EncoderFactoryInterface::class)->getMock(); $mockEncoderFactory->expects($this->any()) ->method('getEncoder') ->with($this->equalTo($userMock)) @@ -46,7 +46,7 @@ class UserPasswordEncoderTest extends TestCase public function testIsPasswordValid() { - $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $userMock = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $userMock->expects($this->any()) ->method('getSalt') ->willReturn('userSalt'); @@ -54,13 +54,13 @@ class UserPasswordEncoderTest extends TestCase ->method('getPassword') ->willReturn('encodedPassword'); - $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); + $mockEncoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock(); $mockEncoder->expects($this->any()) ->method('isPasswordValid') ->with($this->equalTo('encodedPassword'), $this->equalTo('plainPassword'), $this->equalTo('userSalt')) ->willReturn(true); - $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); + $mockEncoderFactory = $this->getMockBuilder(EncoderFactoryInterface::class)->getMock(); $mockEncoderFactory->expects($this->any()) ->method('getEncoder') ->with($this->equalTo($userMock)) diff --git a/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php b/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php index 88f6a18abf..3d7ad26dea 100644 --- a/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php @@ -21,14 +21,14 @@ class SwitchUserRoleTest extends TestCase { public function testGetSource() { - $role = new SwitchUserRole('FOO', $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $role = new SwitchUserRole('FOO', $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); $this->assertSame($token, $role->getSource()); } public function testGetRole() { - $role = new SwitchUserRole('FOO', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $role = new SwitchUserRole('FOO', $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); $this->assertEquals('FOO', $role->getRole()); } diff --git a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php index aaf3e5291c..29440ce159 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php @@ -44,7 +44,7 @@ class ChainUserProviderTest extends TestCase public function testLoadUserByUsernameThrowsUsernameNotFoundException() { - $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); + $this->expectException(UsernameNotFoundException::class); $provider1 = $this->getProvider(); $provider1 ->expects($this->once()) @@ -138,7 +138,7 @@ class ChainUserProviderTest extends TestCase public function testRefreshUserThrowsUnsupportedUserException() { - $this->expectException('Symfony\Component\Security\Core\Exception\UnsupportedUserException'); + $this->expectException(UnsupportedUserException::class); $provider1 = $this->getProvider(); $provider1 ->expects($this->once()) @@ -269,11 +269,11 @@ class ChainUserProviderTest extends TestCase protected function getAccount() { - return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); } protected function getProvider() { - return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); } } diff --git a/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php index bec7307234..ad2b038287 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php @@ -62,7 +62,7 @@ class InMemoryUserProviderTest extends TestCase public function testCreateUserAlreadyExist() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $provider = new InMemoryUserProvider(); $provider->createUser(new User('fabien', 'foo')); $provider->createUser(new User('fabien', 'foo')); @@ -70,7 +70,7 @@ class InMemoryUserProviderTest extends TestCase public function testLoadUserByUsernameDoesNotExist() { - $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class); $provider = new InMemoryUserProvider(); $provider->loadUserByUsername('fabien'); } diff --git a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php index 90f74584b6..f4d609e299 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php @@ -27,7 +27,7 @@ class LdapUserProviderTest extends TestCase { public function testLoadUserByUsernameFailsIfCantConnectToLdap() { - $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class); $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) @@ -41,7 +41,7 @@ class LdapUserProviderTest extends TestCase public function testLoadUserByUsernameFailsIfNoLdapEntries() { - $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class); $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query @@ -72,7 +72,7 @@ class LdapUserProviderTest extends TestCase public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry() { - $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class); $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query @@ -103,7 +103,7 @@ class LdapUserProviderTest extends TestCase public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry() { - $this->expectException('Symfony\Component\Security\Core\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\InvalidArgumentException::class); $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query @@ -186,7 +186,7 @@ class LdapUserProviderTest extends TestCase public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute() { - $this->expectException('Symfony\Component\Security\Core\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\InvalidArgumentException::class); $result = $this->getMockBuilder(CollectionInterface::class)->getMock(); $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php index 427aacb9d0..a618034ea8 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php @@ -21,7 +21,7 @@ class UserCheckerTest extends TestCase { $checker = new UserChecker(); - $this->assertNull($checker->checkPostAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())); + $this->assertNull($checker->checkPostAuth($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock())); } public function testCheckPostAuthPass() @@ -38,7 +38,7 @@ class UserCheckerTest extends TestCase { $checker = new UserChecker(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\AdvancedUserInterface::class)->getMock(); $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(true); $this->assertNull($checker->checkPostAuth($account)); @@ -46,7 +46,7 @@ class UserCheckerTest extends TestCase public function testCheckPostAuthCredentialsExpired() { - $this->expectException('Symfony\Component\Security\Core\Exception\CredentialsExpiredException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\CredentialsExpiredException::class); $checker = new UserChecker(); $checker->checkPostAuth(new User('John', 'password', [], true, true, false, true)); } @@ -57,10 +57,10 @@ class UserCheckerTest extends TestCase */ public function testCheckPostAuthCredentialsExpiredAdvancedUser() { - $this->expectException('Symfony\Component\Security\Core\Exception\CredentialsExpiredException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\CredentialsExpiredException::class); $checker = new UserChecker(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\AdvancedUserInterface::class)->getMock(); $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(false); $checker->checkPostAuth($account); @@ -74,7 +74,7 @@ class UserCheckerTest extends TestCase { $checker = new UserChecker(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\AdvancedUserInterface::class)->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); $account->expects($this->once())->method('isEnabled')->willReturn(true); $account->expects($this->once())->method('isAccountNonExpired')->willReturn(true); @@ -84,7 +84,7 @@ class UserCheckerTest extends TestCase public function testCheckPreAuthAccountLocked() { - $this->expectException('Symfony\Component\Security\Core\Exception\LockedException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\LockedException::class); $checker = new UserChecker(); $checker->checkPreAuth(new User('John', 'password', [], true, true, false, false)); } @@ -95,10 +95,10 @@ class UserCheckerTest extends TestCase */ public function testCheckPreAuthAccountLockedAdvancedUser() { - $this->expectException('Symfony\Component\Security\Core\Exception\LockedException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\LockedException::class); $checker = new UserChecker(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\AdvancedUserInterface::class)->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->willReturn(false); $checker->checkPreAuth($account); @@ -106,7 +106,7 @@ class UserCheckerTest extends TestCase public function testCheckPreAuthDisabled() { - $this->expectException('Symfony\Component\Security\Core\Exception\DisabledException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\DisabledException::class); $checker = new UserChecker(); $checker->checkPreAuth(new User('John', 'password', [], false, true, false, true)); } @@ -117,10 +117,10 @@ class UserCheckerTest extends TestCase */ public function testCheckPreAuthDisabledAdvancedUser() { - $this->expectException('Symfony\Component\Security\Core\Exception\DisabledException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\DisabledException::class); $checker = new UserChecker(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\AdvancedUserInterface::class)->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); $account->expects($this->once())->method('isEnabled')->willReturn(false); @@ -129,7 +129,7 @@ class UserCheckerTest extends TestCase public function testCheckPreAuthAccountExpired() { - $this->expectException('Symfony\Component\Security\Core\Exception\AccountExpiredException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AccountExpiredException::class); $checker = new UserChecker(); $checker->checkPreAuth(new User('John', 'password', [], true, false, true, true)); } @@ -140,10 +140,10 @@ class UserCheckerTest extends TestCase */ public function testCheckPreAuthAccountExpiredAdvancedUser() { - $this->expectException('Symfony\Component\Security\Core\Exception\AccountExpiredException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AccountExpiredException::class); $checker = new UserChecker(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\AdvancedUserInterface::class)->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); $account->expects($this->once())->method('isEnabled')->willReturn(true); $account->expects($this->once())->method('isAccountNonExpired')->willReturn(false); diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserTest.php index 7468e95244..240e6ab4e9 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/UserTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/UserTest.php @@ -20,7 +20,7 @@ class UserTest extends TestCase { public function testConstructorException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new User('', 'superpass'); } diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php index 4e11c47f8c..62989ebb69 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php @@ -114,8 +114,8 @@ abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase public function testUserIsNotValid() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); - $user = $this->getMockBuilder('Foo\Bar\User')->getMock(); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); + $user = $this->getMockBuilder(\Foo\Bar\User::class)->getMock(); $this->tokenStorage = $this->createTokenStorage($user); $this->validator = $this->createValidator(); @@ -126,7 +126,7 @@ abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase protected function createUser() { - $mock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $mock = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $mock ->expects($this->any()) @@ -145,12 +145,12 @@ abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase protected function createPasswordEncoder($isPasswordValid = true) { - return $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); + return $this->getMockBuilder(PasswordEncoderInterface::class)->getMock(); } protected function createEncoderFactory($encoder = null) { - $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); + $mock = $this->getMockBuilder(EncoderFactoryInterface::class)->getMock(); $mock ->expects($this->any()) @@ -165,7 +165,7 @@ abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase { $token = $this->createAuthenticationToken($user); - $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $mock = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); $mock ->expects($this->any()) ->method('getToken') @@ -177,7 +177,7 @@ abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase protected function createAuthenticationToken($user = null) { - $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $mock = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $mock ->expects($this->any()) ->method('getUser') diff --git a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php index bf1026fc39..772bcf1715 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php @@ -42,7 +42,7 @@ class CsrfTokenManagerTest extends TestCase $token = $manager->getToken('token_id'); - $this->assertInstanceOf('Symfony\Component\Security\Csrf\CsrfToken', $token); + $this->assertInstanceOf(CsrfToken::class, $token); $this->assertSame('token_id', $token->getId()); $this->assertSame('TOKEN', $token->getValue()); } @@ -64,7 +64,7 @@ class CsrfTokenManagerTest extends TestCase $token = $manager->getToken('token_id'); - $this->assertInstanceOf('Symfony\Component\Security\Csrf\CsrfToken', $token); + $this->assertInstanceOf(CsrfToken::class, $token); $this->assertSame('token_id', $token->getId()); $this->assertSame('TOKEN', $token->getValue()); } @@ -87,7 +87,7 @@ class CsrfTokenManagerTest extends TestCase $token = $manager->refreshToken('token_id'); - $this->assertInstanceOf('Symfony\Component\Security\Csrf\CsrfToken', $token); + $this->assertInstanceOf(CsrfToken::class, $token); $this->assertSame('token_id', $token->getId()); $this->assertSame('TOKEN', $token->getValue()); } @@ -159,8 +159,8 @@ class CsrfTokenManagerTest extends TestCase public function testNamespaced() { - $generator = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface')->getMock(); - $storage = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface')->getMock(); + $generator = $this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface::class)->getMock(); + $storage = $this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface::class)->getMock(); $requestStack = new RequestStack(); $requestStack->push(new Request([], [], [], [], [], ['HTTPS' => 'on'])); @@ -205,8 +205,8 @@ class CsrfTokenManagerTest extends TestCase private function getGeneratorAndStorage(): array { return [ - $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface')->getMock(), - $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface::class)->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface::class)->getMock(), ]; } diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php index 5acbedc6e9..fadb87e6ab 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php @@ -88,7 +88,7 @@ class NativeSessionTokenStorageTest extends TestCase public function testGetNonExistingToken() { - $this->expectException('Symfony\Component\Security\Csrf\Exception\TokenNotFoundException'); + $this->expectException(\Symfony\Component\Security\Csrf\Exception\TokenNotFoundException::class); $this->storage->getToken('token_id'); } diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php index af5b0ebc8b..deccfaa53b 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php @@ -88,13 +88,13 @@ class SessionTokenStorageTest extends TestCase public function testGetNonExistingTokenFromClosedSession() { - $this->expectException('Symfony\Component\Security\Csrf\Exception\TokenNotFoundException'); + $this->expectException(\Symfony\Component\Security\Csrf\Exception\TokenNotFoundException::class); $this->storage->getToken('token_id'); } public function testGetNonExistingTokenFromActiveSession() { - $this->expectException('Symfony\Component\Security\Csrf\Exception\TokenNotFoundException'); + $this->expectException(\Symfony\Component\Security\Csrf\Exception\TokenNotFoundException::class); $this->session->start(); $this->storage->getToken('token_id'); } diff --git a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php index 2b7f25f791..bab0d70b82 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php @@ -36,7 +36,7 @@ class FormLoginAuthenticatorTest extends TestCase { $failureResponse = $this->authenticator->onAuthenticationFailure($this->requestWithoutSession, new AuthenticationException()); - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse); $this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl()); } @@ -48,7 +48,7 @@ class FormLoginAuthenticatorTest extends TestCase $failureResponse = $this->authenticator->onAuthenticationFailure($this->requestWithSession, new AuthenticationException()); - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse); $this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl()); } @@ -63,7 +63,7 @@ class FormLoginAuthenticatorTest extends TestCase { $failureResponse = $this->authenticator->start($this->requestWithoutSession, new AuthenticationException()); - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse); $this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl()); } @@ -71,7 +71,7 @@ class FormLoginAuthenticatorTest extends TestCase { $failureResponse = $this->authenticator->start($this->requestWithSession, new AuthenticationException()); - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $failureResponse); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $failureResponse); $this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl()); } @@ -80,7 +80,7 @@ class FormLoginAuthenticatorTest extends TestCase $this->requestWithoutSession = new Request([], [], [], [], [], []); $this->requestWithSession = new Request([], [], [], [], [], []); - $session = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface') + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class) ->disableOriginalConstructor() ->getMock(); $this->requestWithSession->setSession($session); diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php index c5e1c92b89..7167ba3dc4 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -234,7 +234,7 @@ class GuardAuthenticationListenerTest extends TestCase public function testReturnNullFromGetCredentials() { - $this->expectException('UnexpectedValueException'); + $this->expectException(\UnexpectedValueException::class); $authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); $providerKey = 'my_firewall4'; @@ -262,17 +262,17 @@ class GuardAuthenticationListenerTest extends TestCase protected function setUp(): void { - $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager') + $this->authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager::class) ->disableOriginalConstructor() ->getMock(); - $this->guardAuthenticatorHandler = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorHandler') + $this->guardAuthenticatorHandler = $this->getMockBuilder(\Symfony\Component\Security\Guard\GuardAuthenticatorHandler::class) ->disableOriginalConstructor() ->getMock(); $this->request = new Request([], [], [], [], [], []); - $this->event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\RequestEvent') + $this->event = $this->getMockBuilder(\Symfony\Component\HttpKernel\Event\RequestEvent::class) ->disableOriginalConstructor() ->setMethods(['getRequest']) ->getMock(); @@ -281,8 +281,8 @@ class GuardAuthenticationListenerTest extends TestCase ->method('getRequest') ->willReturn($this->request); - $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock(); + $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $this->rememberMeServices = $this->getMockBuilder(\Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface::class)->getMock(); } protected function tearDown(): void diff --git a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php index 5a6c3c26d0..e115891bba 100644 --- a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php @@ -193,7 +193,7 @@ class GuardAuthenticatorHandlerTest extends TestCase private function configurePreviousSession() { - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock(); $session->expects($this->any()) ->method('getName') ->willReturn('test_session_name'); diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php index e00fb12dfb..5ecf12e4c6 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php @@ -125,7 +125,7 @@ class GuardAuthenticationProviderTest extends TestCase */ public function testCheckCredentialsReturningNonTrueFailsAuthentication() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(BadCredentialsException::class); $providerKey = 'my_uncool_firewall'; $authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); @@ -140,7 +140,7 @@ class GuardAuthenticationProviderTest extends TestCase ->method('getCredentials') ->willReturn('non-null-value'); - $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock(); $authenticator->expects($this->once()) ->method('getUser') ->willReturn($mockedUser); @@ -156,12 +156,12 @@ class GuardAuthenticationProviderTest extends TestCase public function testGuardWithNoLongerAuthenticatedTriggersLogout() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationExpiredException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationExpiredException::class); $providerKey = 'my_firewall_abc'; // create a token and mark it as NOT authenticated anymore // this mimics what would happen if a user "changed" between request - $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock(); $token = new PostAuthenticationGuardToken($mockedUser, $providerKey, ['ROLE_USER']); $token->setAuthenticated(false); @@ -175,7 +175,7 @@ class GuardAuthenticationProviderTest extends TestCase $authenticatorB = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); $authenticators = [$authenticatorA, $authenticatorB]; - $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock(); $provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker); $token = new PreAuthenticationGuardToken($mockedUser, 'first_firewall_1'); @@ -189,12 +189,12 @@ class GuardAuthenticationProviderTest extends TestCase public function testAuthenticateFailsOnNonOriginatingToken() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class); $this->expectExceptionMessageMatches('/second_firewall_0/'); $authenticatorA = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); $authenticators = [$authenticatorA]; - $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock(); $provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker); $token = new PreAuthenticationGuardToken($mockedUser, 'second_firewall_0'); @@ -203,9 +203,9 @@ class GuardAuthenticationProviderTest extends TestCase protected function setUp(): void { - $this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); - $this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); - $this->preAuthenticationToken = $this->getMockBuilder('Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken') + $this->userProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); + $this->userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); + $this->preAuthenticationToken = $this->getMockBuilder(PreAuthenticationGuardToken::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php index 1f5356ba9e..865554b25a 100644 --- a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php +++ b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php @@ -18,7 +18,7 @@ class AccessMapTest extends TestCase { public function testReturnsFirstMatchedPattern() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); $requestMatcher1 = $this->getRequestMatcher($request, false); $requestMatcher2 = $this->getRequestMatcher($request, true); @@ -31,7 +31,7 @@ class AccessMapTest extends TestCase public function testReturnsEmptyPatternIfNoneMatched() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); $requestMatcher = $this->getRequestMatcher($request, false); $map = new AccessMap(); @@ -42,7 +42,7 @@ class AccessMapTest extends TestCase private function getRequestMatcher($request, $matches) { - $requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestMatcherInterface::class)->getMock(); $requestMatcher->expects($this->once()) ->method('matches')->with($request) ->willReturn($matches); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php index 8fe7ce0c86..b24769aa75 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php @@ -29,14 +29,14 @@ class DefaultAuthenticationFailureHandlerTest extends TestCase protected function setUp(): void { - $this->httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); - $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $this->httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $this->httpUtils = $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)->getMock(); + $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); - $this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); - $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $this->session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock(); + $this->request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); $this->request->expects($this->any())->method('getSession')->willReturn($this->session); - $this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(['getMessage'])->getMock(); + $this->exception = $this->getMockBuilder(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)->setMethods(['getMessage'])->getMock(); } public function testForward() @@ -183,8 +183,8 @@ class DefaultAuthenticationFailureHandlerTest extends TestCase private function getRequest() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $request->attributes = $this->getMockBuilder('Symfony\Component\HttpFoundation\ParameterBag')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); + $request->attributes = $this->getMockBuilder(\Symfony\Component\HttpFoundation\ParameterBag::class)->getMock(); return $request; } diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php index 8f0ba0728c..b327257909 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php @@ -23,10 +23,10 @@ class DefaultAuthenticationSuccessHandlerTest extends TestCase */ public function testRequestRedirections(Request $request, $options, $redirectedUrl) { - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); + $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock(); $urlGenerator->expects($this->any())->method('generate')->willReturn('http://localhost/login'); $httpUtils = new HttpUtils($urlGenerator); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $handler = new DefaultAuthenticationSuccessHandler($httpUtils, $options); if ($request->hasSession()) { $handler->setProviderKey('admin'); @@ -36,7 +36,7 @@ class DefaultAuthenticationSuccessHandlerTest extends TestCase public function getRequestRedirections() { - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock(); $session->expects($this->once())->method('get')->with('_security.admin.target_path')->willReturn('/admin/dashboard'); $session->expects($this->once())->method('remove')->with('_security.admin.target_path'); $requestWithSession = Request::create('/'); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php index fa4c07e0b8..3e7d45b000 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php @@ -38,11 +38,11 @@ class SimpleAuthenticationHandlerTest extends TestCase protected function setUp(): void { - $this->successHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(); - $this->failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); + $this->successHandler = $this->getMockBuilder(AuthenticationSuccessHandlerInterface::class)->getMock(); + $this->failureHandler = $this->getMockBuilder(AuthenticationFailureHandlerInterface::class)->getMock(); - $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $this->request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); + $this->token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); // No methods are invoked on the exception; we just assert on its class $this->authenticationException = new AuthenticationException(); @@ -51,7 +51,7 @@ class SimpleAuthenticationHandlerTest extends TestCase public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler() { - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $authenticator = $this->getMockBuilder(SimpleAuthenticatorInterface::class)->getMock(); $this->successHandler->expects($this->once()) ->method('onAuthenticationSuccess') @@ -69,7 +69,7 @@ class SimpleAuthenticationHandlerTest extends TestCase $this->successHandler->expects($this->never()) ->method('onAuthenticationSuccess'); - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface'); + $authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface::class); $authenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) @@ -83,12 +83,12 @@ class SimpleAuthenticationHandlerTest extends TestCase public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsReturned() { - $this->expectException('UnexpectedValueException'); + $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage('onAuthenticationSuccess()" method must return null to use the default success handler, or a Response object'); $this->successHandler->expects($this->never()) ->method('onAuthenticationSuccess'); - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface'); + $authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface::class); $authenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) @@ -105,7 +105,7 @@ class SimpleAuthenticationHandlerTest extends TestCase ->with($this->request, $this->token) ->willReturn($this->response); - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface'); + $authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestSuccessHandlerInterface::class); $authenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) @@ -119,7 +119,7 @@ class SimpleAuthenticationHandlerTest extends TestCase public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNotAFailureHandler() { - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $authenticator = $this->getMockBuilder(SimpleAuthenticatorInterface::class)->getMock(); $this->failureHandler->expects($this->once()) ->method('onAuthenticationFailure') @@ -137,7 +137,7 @@ class SimpleAuthenticationHandlerTest extends TestCase $this->failureHandler->expects($this->never()) ->method('onAuthenticationFailure'); - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface'); + $authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface::class); $authenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) @@ -151,12 +151,12 @@ class SimpleAuthenticationHandlerTest extends TestCase public function testOnAuthenticationFailureThrowsAnExceptionIfNonResponseIsReturned() { - $this->expectException('UnexpectedValueException'); + $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage('onAuthenticationFailure()" method must return null to use the default failure handler, or a Response object'); $this->failureHandler->expects($this->never()) ->method('onAuthenticationFailure'); - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface'); + $authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface::class); $authenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) @@ -173,7 +173,7 @@ class SimpleAuthenticationHandlerTest extends TestCase ->with($this->request, $this->authenticationException) ->willReturn($this->response); - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface'); + $authenticator = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Tests\Authentication\TestFailureHandlerInterface::class); $authenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php index 711d4e2f1f..7c7f3a1f8b 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php @@ -19,7 +19,7 @@ class BasicAuthenticationEntryPointTest extends TestCase { public function testStart() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); $authException = new AuthenticationException('The exception message'); @@ -32,7 +32,7 @@ class BasicAuthenticationEntryPointTest extends TestCase public function testStartWithoutAuthException() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); $entryPoint = new BasicAuthenticationEntryPoint('TheRealmName'); diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php index 05c5930ec8..432c8dd7a3 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php @@ -21,11 +21,11 @@ class FormAuthenticationEntryPointTest extends TestCase { public function testStart() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock(); $response = new RedirectResponse('/the/login/path'); - $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); + $httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $httpUtils = $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)->getMock(); $httpUtils ->expects($this->once()) ->method('createRedirectResponse') @@ -40,11 +40,11 @@ class FormAuthenticationEntryPointTest extends TestCase public function testStartWithUseForward() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $subRequest = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock(); $response = new Response('', 200); - $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); + $httpUtils = $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)->getMock(); $httpUtils ->expects($this->once()) ->method('createRequest') @@ -52,7 +52,7 @@ class FormAuthenticationEntryPointTest extends TestCase ->willReturn($subRequest) ; - $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $httpKernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $httpKernel ->expects($this->once()) ->method('handle') diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php index 05c85f23b7..643240918c 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php @@ -25,13 +25,13 @@ class RetryAuthenticationEntryPointTest extends TestCase $entryPoint = new RetryAuthenticationEntryPoint($httpPort, $httpsPort); $response = $entryPoint->start($request); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response); $this->assertEquals($expectedUrl, $response->headers->get('Location')); } public function dataForStart() { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + if (!class_exists(Request::class)) { return [[]]; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php index 51235bc2e3..22b528edc7 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php @@ -26,9 +26,9 @@ class AbstractPreAuthenticatedListenerTest extends TestCase $request = new Request([], [], [], [], [], []); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -40,15 +40,15 @@ class AbstractPreAuthenticatedListenerTest extends TestCase ->with($this->equalTo($token)) ; - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') - ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) + ->with($this->isInstanceOf(PreAuthenticatedToken::class)) ->willReturn($token) ; - $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [ + $listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [ $tokenStorage, $authenticationManager, 'TheProviderKey', @@ -74,7 +74,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase $request = new Request([], [], [], [], [], []); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -86,15 +86,15 @@ class AbstractPreAuthenticatedListenerTest extends TestCase ; $exception = new AuthenticationException('Authentication failed.'); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') - ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) + ->with($this->isInstanceOf(PreAuthenticatedToken::class)) ->willThrowException($exception) ; - $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [ + $listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [ $tokenStorage, $authenticationManager, 'TheProviderKey', @@ -122,7 +122,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase $request = new Request([], [], [], [], [], []); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -134,15 +134,15 @@ class AbstractPreAuthenticatedListenerTest extends TestCase ; $exception = new AuthenticationException('Authentication failed.'); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') - ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) + ->with($this->isInstanceOf(PreAuthenticatedToken::class)) ->willThrowException($exception) ; - $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [ + $listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [ $tokenStorage, $authenticationManager, 'TheProviderKey', @@ -170,20 +170,20 @@ class AbstractPreAuthenticatedListenerTest extends TestCase $token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', ['ROLE_FOO']); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') ->willReturn($token) ; - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $authenticationManager ->expects($this->never()) ->method('authenticate') ; - $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [ + $listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [ $tokenStorage, $authenticationManager, 'TheProviderKey', @@ -211,7 +211,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase $token = new PreAuthenticatedToken('AnotherUser', 'TheCredentials', 'TheProviderKey', ['ROLE_FOO']); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -224,15 +224,15 @@ class AbstractPreAuthenticatedListenerTest extends TestCase ; $exception = new AuthenticationException('Authentication failed.'); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') - ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) + ->with($this->isInstanceOf(PreAuthenticatedToken::class)) ->willThrowException($exception) ; - $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [ + $listener = $this->getMockForAbstractClass(\Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener::class, [ $tokenStorage, $authenticationManager, 'TheProviderKey', diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php index 75798d055a..71731c5797 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php @@ -27,10 +27,10 @@ class AccessListenerTest extends TestCase { public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() { - $this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class); $request = new Request(); - $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); + $accessMap = $this->getMockBuilder(AccessMapInterface::class)->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -38,21 +38,21 @@ class AccessListenerTest extends TestCase ->willReturn([['foo' => 'bar'], null]) ; - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token ->expects($this->any()) ->method('isAuthenticated') ->willReturn(true) ; - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') ->willReturn($token) ; - $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); + $accessDecisionManager = $this->getMockBuilder(AccessDecisionManagerInterface::class)->getMock(); $accessDecisionManager ->expects($this->once()) ->method('decide') @@ -64,7 +64,7 @@ class AccessListenerTest extends TestCase $tokenStorage, $accessDecisionManager, $accessMap, - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock() + $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock() ); $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); @@ -74,7 +74,7 @@ class AccessListenerTest extends TestCase { $request = new Request(); - $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); + $accessMap = $this->getMockBuilder(AccessMapInterface::class)->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -82,21 +82,21 @@ class AccessListenerTest extends TestCase ->willReturn([['foo' => 'bar'], null]) ; - $notAuthenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $notAuthenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $notAuthenticatedToken ->expects($this->any()) ->method('isAuthenticated') ->willReturn(false) ; - $authenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $authenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $authenticatedToken ->expects($this->any()) ->method('isAuthenticated') ->willReturn(true) ; - $authManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authManager = $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock(); $authManager ->expects($this->once()) ->method('authenticate') @@ -104,7 +104,7 @@ class AccessListenerTest extends TestCase ->willReturn($authenticatedToken) ; - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -116,7 +116,7 @@ class AccessListenerTest extends TestCase ->with($this->equalTo($authenticatedToken)) ; - $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); + $accessDecisionManager = $this->getMockBuilder(AccessDecisionManagerInterface::class)->getMock(); $accessDecisionManager ->expects($this->once()) ->method('decide') @@ -138,7 +138,7 @@ class AccessListenerTest extends TestCase { $request = new Request(); - $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); + $accessMap = $this->getMockBuilder(AccessMapInterface::class)->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -146,13 +146,13 @@ class AccessListenerTest extends TestCase ->willReturn([null, null]) ; - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token ->expects($this->never()) ->method('isAuthenticated') ; - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -161,9 +161,9 @@ class AccessListenerTest extends TestCase $listener = new AccessListener( $tokenStorage, - $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(), + $this->getMockBuilder(AccessDecisionManagerInterface::class)->getMock(), $accessMap, - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock() + $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock() ); $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); @@ -201,8 +201,8 @@ class AccessListenerTest extends TestCase public function testHandleWhenTheSecurityTokenStorageHasNoToken() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException'); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException::class); + $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -221,9 +221,9 @@ class AccessListenerTest extends TestCase $listener = new AccessListener( $tokenStorage, - $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(), + $this->getMockBuilder(AccessDecisionManagerInterface::class)->getMock(), $accessMap, - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock() + $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock() ); $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST)); @@ -233,7 +233,7 @@ class AccessListenerTest extends TestCase { $request = new Request(); - $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); + $accessMap = $this->getMockBuilder(AccessMapInterface::class)->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -241,7 +241,7 @@ class AccessListenerTest extends TestCase ->willReturn([['foo' => 'bar', 'bar' => 'baz'], null]) ; - $authenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $authenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $authenticatedToken ->expects($this->any()) ->method('isAuthenticated') @@ -251,7 +251,7 @@ class AccessListenerTest extends TestCase $tokenStorage = new TokenStorage(); $tokenStorage->setToken($authenticatedToken); - $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); + $accessDecisionManager = $this->getMockBuilder(AccessDecisionManagerInterface::class)->getMock(); $accessDecisionManager ->expects($this->once()) ->method('decide') diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php index e6f9f42217..5940ad2e6e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php @@ -22,18 +22,18 @@ class AnonymousAuthenticationListenerTest extends TestCase { public function testHandleWithTokenStorageHavingAToken() { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') - ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()) ; $tokenStorage ->expects($this->never()) ->method('setToken') ; - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $authenticationManager ->expects($this->never()) ->method('authenticate') @@ -45,7 +45,7 @@ class AnonymousAuthenticationListenerTest extends TestCase public function testHandleWithTokenStorageHavingNoToken() { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -54,7 +54,7 @@ class AnonymousAuthenticationListenerTest extends TestCase $anonymousToken = new AnonymousToken('TheSecret', 'anon.', []); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -76,14 +76,14 @@ class AnonymousAuthenticationListenerTest extends TestCase public function testHandledEventIsLogged() { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger->expects($this->once()) ->method('info') ->with('Populated the TokenStorage with an anonymous Token.') ; - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', $logger, $authenticationManager); $listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MASTER_REQUEST)); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php index f052792001..337a116b9e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php @@ -29,9 +29,9 @@ class BasicAuthenticationListenerTest extends TestCase 'PHP_AUTH_PW' => 'ThePassword', ]); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -43,11 +43,11 @@ class BasicAuthenticationListenerTest extends TestCase ->with($this->equalTo($token)) ; - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') - ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken')) + ->with($this->isInstanceOf(UsernamePasswordToken::class)) ->willReturn($token) ; @@ -55,7 +55,7 @@ class BasicAuthenticationListenerTest extends TestCase $tokenStorage, $authenticationManager, 'TheProviderKey', - $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() + $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock() ); $event = $this->getMockBuilder(RequestEvent::class)->disableOriginalConstructor()->getMock(); @@ -75,7 +75,7 @@ class BasicAuthenticationListenerTest extends TestCase 'PHP_AUTH_PW' => 'ThePassword', ]); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -88,17 +88,17 @@ class BasicAuthenticationListenerTest extends TestCase $response = new Response(); - $authenticationEntryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); + $authenticationEntryPoint = $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock(); $authenticationEntryPoint ->expects($this->any()) ->method('start') - ->with($this->equalTo($request), $this->isInstanceOf('Symfony\Component\Security\Core\Exception\AuthenticationException')) + ->with($this->equalTo($request), $this->isInstanceOf(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)) ->willReturn($response) ; $listener = new BasicAuthenticationListener( $tokenStorage, - new AuthenticationProviderManager([$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock()]), + new AuthenticationProviderManager([$this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock()]), 'TheProviderKey', $authenticationEntryPoint ); @@ -122,7 +122,7 @@ class BasicAuthenticationListenerTest extends TestCase { $request = new Request(); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->never()) ->method('getToken') @@ -130,9 +130,9 @@ class BasicAuthenticationListenerTest extends TestCase $listener = new BasicAuthenticationListener( $tokenStorage, - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(), 'TheProviderKey', - $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() + $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock() ); $event = $this->getMockBuilder(RequestEvent::class)->disableOriginalConstructor()->getMock(); @@ -151,14 +151,14 @@ class BasicAuthenticationListenerTest extends TestCase $token = new UsernamePasswordToken('TheUsername', 'ThePassword', 'TheProviderKey', ['ROLE_FOO']); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') ->willReturn($token) ; - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $authenticationManager ->expects($this->never()) ->method('authenticate') @@ -168,7 +168,7 @@ class BasicAuthenticationListenerTest extends TestCase $tokenStorage, $authenticationManager, 'TheProviderKey', - $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() + $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock() ); $event = $this->getMockBuilder(RequestEvent::class)->disableOriginalConstructor()->getMock(); @@ -183,13 +183,13 @@ class BasicAuthenticationListenerTest extends TestCase public function testItRequiresProviderKey() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('$providerKey must not be empty'); new BasicAuthenticationListener( - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(), '', - $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() + $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock() ); } @@ -202,7 +202,7 @@ class BasicAuthenticationListenerTest extends TestCase $token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', ['ROLE_FOO']); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -215,17 +215,17 @@ class BasicAuthenticationListenerTest extends TestCase $response = new Response(); - $authenticationEntryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); + $authenticationEntryPoint = $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock(); $authenticationEntryPoint ->expects($this->any()) ->method('start') - ->with($this->equalTo($request), $this->isInstanceOf('Symfony\Component\Security\Core\Exception\AuthenticationException')) + ->with($this->equalTo($request), $this->isInstanceOf(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)) ->willReturn($response) ; $listener = new BasicAuthenticationListener( $tokenStorage, - new AuthenticationProviderManager([$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock()]), + new AuthenticationProviderManager([$this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock()]), 'TheProviderKey', $authenticationEntryPoint ); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php index 54b7fa606f..7a1170fc66 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php @@ -20,14 +20,14 @@ class ChannelListenerTest extends TestCase { public function testHandleWithNotSecuredRequestAndHttpChannel() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') ->willReturn(false) ; - $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); + $accessMap = $this->getMockBuilder(\Symfony\Component\Security\Http\AccessMapInterface::class)->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -35,7 +35,7 @@ class ChannelListenerTest extends TestCase ->willReturn([[], 'http']) ; - $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); + $entryPoint = $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock(); $entryPoint ->expects($this->never()) ->method('start') @@ -58,14 +58,14 @@ class ChannelListenerTest extends TestCase public function testHandleWithSecuredRequestAndHttpsChannel() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') ->willReturn(true) ; - $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); + $accessMap = $this->getMockBuilder(\Symfony\Component\Security\Http\AccessMapInterface::class)->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -73,7 +73,7 @@ class ChannelListenerTest extends TestCase ->willReturn([[], 'https']) ; - $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); + $entryPoint = $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock(); $entryPoint ->expects($this->never()) ->method('start') @@ -96,7 +96,7 @@ class ChannelListenerTest extends TestCase public function testHandleWithNotSecuredRequestAndHttpsChannel() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') @@ -105,7 +105,7 @@ class ChannelListenerTest extends TestCase $response = new Response(); - $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); + $accessMap = $this->getMockBuilder(\Symfony\Component\Security\Http\AccessMapInterface::class)->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -113,7 +113,7 @@ class ChannelListenerTest extends TestCase ->willReturn([[], 'https']) ; - $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); + $entryPoint = $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock(); $entryPoint ->expects($this->once()) ->method('start') @@ -139,7 +139,7 @@ class ChannelListenerTest extends TestCase public function testHandleWithSecuredRequestAndHttpChannel() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') @@ -148,7 +148,7 @@ class ChannelListenerTest extends TestCase $response = new Response(); - $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); + $accessMap = $this->getMockBuilder(\Symfony\Component\Security\Http\AccessMapInterface::class)->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -156,7 +156,7 @@ class ChannelListenerTest extends TestCase ->willReturn([[], 'http']) ; - $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); + $entryPoint = $this->getMockBuilder(\Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface::class)->getMock(); $entryPoint ->expects($this->once()) ->method('start') diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index 7e89c0b1b3..b90ed57a28 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -43,7 +43,7 @@ class ContextListenerTest extends TestCase { public function testItRequiresContextKey() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('$contextKey must not be empty'); new ContextListener( $this->getMockBuilder(TokenStorageInterface::class)->getMock(), @@ -54,7 +54,7 @@ class ContextListenerTest extends TestCase public function testUserProvidersNeedToImplementAnInterface() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('User provider "stdClass" must implement "Symfony\Component\Security\Core\User\UserProviderInterface'); $this->handleEventWithPreviousSession([new \stdClass()]); } @@ -67,7 +67,7 @@ class ContextListenerTest extends TestCase ); $token = unserialize($session->get('_security_session')); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $token); + $this->assertInstanceOf(UsernamePasswordToken::class, $token); $this->assertEquals('test1', $token->getUsername()); } @@ -79,7 +79,7 @@ class ContextListenerTest extends TestCase ); $token = unserialize($session->get('_security_session')); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $token); + $this->assertInstanceOf(UsernamePasswordToken::class, $token); $this->assertEquals('test1', $token->getUsername()); } @@ -149,8 +149,8 @@ class ContextListenerTest extends TestCase $event = $this->getMockBuilder(RequestEvent::class) ->disableOriginalConstructor() ->getMock(); - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); + $request = $this->getMockBuilder(Request::class)->getMock(); + $session = $this->getMockBuilder(SessionInterface::class)->getMock(); $event->expects($this->any()) ->method('getRequest') @@ -199,7 +199,7 @@ class ContextListenerTest extends TestCase ->willReturn(true); $event->expects($this->any()) ->method('getRequest') - ->willReturn($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock()); + ->willReturn($this->getMockBuilder(Request::class)->getMock()); $dispatcher->expects($this->once()) ->method('addListener') @@ -216,7 +216,7 @@ class ContextListenerTest extends TestCase $listener = new ContextListener($tokenStorage, [], 'key123', null, $dispatcher); - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(Request::class)->getMock(); $request->expects($this->any()) ->method('hasSession') ->willReturn(true); @@ -235,7 +235,7 @@ class ContextListenerTest extends TestCase public function testHandleRemovesTokenIfNoPreviousSessionWasFound() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(Request::class)->getMock(); $request->expects($this->any())->method('hasPreviousSession')->willReturn(false); $event = $this->getMockBuilder(RequestEvent::class) @@ -305,7 +305,7 @@ class ContextListenerTest extends TestCase public function testRuntimeExceptionIsThrownIfNoSupportingUserProviderWasRegistered() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->handleEventWithPreviousSession([new NotSupportingUserProvider(false), new NotSupportingUserProvider(true)]); } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index 7328394b48..aa2d657d04 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -77,13 +77,13 @@ class ExceptionListenerTest extends TestCase { $event = $this->createEvent(new AuthenticationException()); - $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); + $entryPoint = $this->getMockBuilder(AuthenticationEntryPointInterface::class)->getMock(); $entryPoint->expects($this->once())->method('start')->willReturn('NOT A RESPONSE'); $listener = $this->createExceptionListener(null, null, null, $entryPoint); $listener->onKernelException($event); // the exception has been replaced by our LogicException - $this->assertInstanceOf('LogicException', $event->getThrowable()); + $this->assertInstanceOf(\LogicException::class, $event->getThrowable()); $this->assertStringEndsWith('start()" method must return a Response object ("string" returned).', $event->getThrowable()->getMessage()); } @@ -106,12 +106,12 @@ class ExceptionListenerTest extends TestCase */ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandlerAndWithErrorPage(\Exception $exception, \Exception $eventException = null) { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturn(new Response('Unauthorized', 401)); $event = $this->createEvent($exception, $kernel); - $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); + $httpUtils = $this->getMockBuilder(HttpUtils::class)->getMock(); $httpUtils->expects($this->once())->method('createRequest')->willReturn(Request::create('/error')); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), $httpUtils, null, '/error'); @@ -131,7 +131,7 @@ class ExceptionListenerTest extends TestCase { $event = $this->createEvent($exception); - $accessDeniedHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface')->getMock(); + $accessDeniedHandler = $this->getMockBuilder(AccessDeniedHandlerInterface::class)->getMock(); $accessDeniedHandler->expects($this->once())->method('handle')->willReturn(new Response('error')); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), null, null, null, $accessDeniedHandler); @@ -148,8 +148,8 @@ class ExceptionListenerTest extends TestCase { $event = $this->createEvent($exception); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $tokenStorage->expects($this->once())->method('getToken')->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); + $tokenStorage->expects($this->once())->method('getToken')->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); $listener = $this->createExceptionListener($tokenStorage, $this->createTrustResolver(false), null, $this->createEntryPoint()); $listener->onKernelException($event); @@ -182,7 +182,7 @@ class ExceptionListenerTest extends TestCase private function createEntryPoint(Response $response = null) { - $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); + $entryPoint = $this->getMockBuilder(AuthenticationEntryPointInterface::class)->getMock(); $entryPoint->expects($this->once())->method('start')->willReturn($response ?: new Response('OK')); return $entryPoint; @@ -190,7 +190,7 @@ class ExceptionListenerTest extends TestCase private function createTrustResolver($fullFledged) { - $trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(); + $trustResolver = $this->getMockBuilder(AuthenticationTrustResolverInterface::class)->getMock(); $trustResolver->expects($this->once())->method('isFullFledged')->willReturn($fullFledged); return $trustResolver; @@ -199,7 +199,7 @@ class ExceptionListenerTest extends TestCase private function createEvent(\Exception $exception, $kernel = null) { if (null === $kernel) { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); } return new ExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $exception); @@ -208,9 +208,9 @@ class ExceptionListenerTest extends TestCase private function createExceptionListener(TokenStorageInterface $tokenStorage = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null) { return new ExceptionListener( - $tokenStorage ?: $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), - $trustResolver ?: $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(), - $httpUtils ?: $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(), + $tokenStorage ?: $this->getMockBuilder(TokenStorageInterface::class)->getMock(), + $trustResolver ?: $this->getMockBuilder(AuthenticationTrustResolverInterface::class)->getMock(), + $httpUtils ?: $this->getMockBuilder(HttpUtils::class)->getMock(), 'key', $authenticationEntryPoint, $errorPage, diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php index ea13d1f2cf..1b81fc053c 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php @@ -125,7 +125,7 @@ class LogoutListenerTest extends TestCase public function testSuccessHandlerReturnsNonResponse() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $successHandler = $this->getSuccessHandler(); [$listener, , $httpUtils, $options] = $this->getListener($successHandler); @@ -147,7 +147,7 @@ class LogoutListenerTest extends TestCase public function testCsrfValidationFails() { - $this->expectException('Symfony\Component\Security\Core\Exception\LogoutException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\LogoutException::class); $tokenManager = $this->getTokenManager(); [$listener, , $httpUtils, $options] = $this->getListener(null, $tokenManager); @@ -170,12 +170,12 @@ class LogoutListenerTest extends TestCase private function getTokenManager() { - return $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock(); } private function getTokenStorage() { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); } private function getGetResponseEvent() @@ -193,12 +193,12 @@ class LogoutListenerTest extends TestCase private function getHandler() { - return $this->getMockBuilder('Symfony\Component\Security\Http\Logout\LogoutHandlerInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Http\Logout\LogoutHandlerInterface::class)->getMock(); } private function getHttpUtils() { - return $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils') + return $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class) ->disableOriginalConstructor() ->getMock(); } @@ -223,11 +223,11 @@ class LogoutListenerTest extends TestCase private function getSuccessHandler() { - return $this->getMockBuilder('Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface::class)->getMock(); } private function getToken() { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index cf46161032..8367a233d2 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -32,7 +32,7 @@ class RememberMeListenerTest extends TestCase $tokenStorage ->expects($this->any()) ->method('getToken') - ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()) ; $tokenStorage @@ -79,7 +79,7 @@ class RememberMeListenerTest extends TestCase $service ->expects($this->once()) ->method('autoLogin') - ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()) ; $service @@ -101,7 +101,7 @@ class RememberMeListenerTest extends TestCase public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException'); + $this->expectException(AuthenticationException::class); $this->expectExceptionMessage('Authentication failed.'); [$listener, $tokenStorage, $service, $manager] = $this->getListener(false, false); @@ -114,7 +114,7 @@ class RememberMeListenerTest extends TestCase $service ->expects($this->once()) ->method('autoLogin') - ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()) ; $service @@ -176,7 +176,7 @@ class RememberMeListenerTest extends TestCase ->willReturn(null) ; - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -210,7 +210,7 @@ class RememberMeListenerTest extends TestCase ->willReturn(null) ; - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -260,7 +260,7 @@ class RememberMeListenerTest extends TestCase ->willReturn(null) ; - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -308,7 +308,7 @@ class RememberMeListenerTest extends TestCase ->willReturn(null) ; - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -333,7 +333,7 @@ class RememberMeListenerTest extends TestCase ->expects($this->once()) ->method('dispatch') ->with( - $this->isInstanceOf('Symfony\Component\Security\Http\Event\InteractiveLoginEvent'), + $this->isInstanceOf(\Symfony\Component\Security\Http\Event\InteractiveLoginEvent::class), SecurityEvents::INTERACTIVE_LOGIN ) ; @@ -379,22 +379,22 @@ class RememberMeListenerTest extends TestCase protected function getLogger() { - return $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + return $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); } protected function getManager() { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); } protected function getService() { - return $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface::class)->getMock(); } protected function getTokenStorage() { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); } protected function getDispatcher() diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php index fd29297a57..888d672547 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php @@ -25,9 +25,9 @@ class RemoteUserAuthenticationListenerTest extends TestCase $request = new Request([], [], [], [], [], $serverVars); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, @@ -44,12 +44,12 @@ class RemoteUserAuthenticationListenerTest extends TestCase public function testGetPreAuthenticatedDataNoUser() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $request = new Request([], [], [], [], [], []); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, @@ -70,9 +70,9 @@ class RemoteUserAuthenticationListenerTest extends TestCase $request = new Request([], [], [], [], [], [ 'TheUserKey' => 'TheUser', ]); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php index 5cc45932a8..82265c292a 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php @@ -47,7 +47,7 @@ class SimplePreAuthenticationListenerTest extends TestCase ->willReturn($this->token) ; - $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); + $simpleAuthenticator = $this->getMockBuilder(\Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface::class)->getMock(); $simpleAuthenticator ->expects($this->once()) ->method('createToken') @@ -84,7 +84,7 @@ class SimplePreAuthenticationListenerTest extends TestCase ->with($this->equalTo(null)) ; - $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); + $simpleAuthenticator = $this->getMockBuilder(\Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface::class)->getMock(); $simpleAuthenticator ->expects($this->once()) ->method('createToken') @@ -99,12 +99,12 @@ class SimplePreAuthenticationListenerTest extends TestCase protected function setUp(): void { - $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager') + $this->authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager::class) ->disableOriginalConstructor() ->getMock() ; - $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock(); $this->request = new Request([], [], [], [], [], []); @@ -115,9 +115,9 @@ class SimplePreAuthenticationListenerTest extends TestCase ->willReturn($this->request) ; - $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $this->tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); + $this->token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); } protected function tearDown(): void diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php index c188727bb0..45d6a77bb4 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -43,16 +43,16 @@ class SwitchUserListenerTest extends TestCase protected function setUp(): void { $this->tokenStorage = new TokenStorage(); - $this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); - $this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); - $this->accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); + $this->userProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); + $this->userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(); + $this->accessDecisionManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface::class)->getMock(); $this->request = new Request(); $this->event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $this->request, HttpKernelInterface::MASTER_REQUEST); } public function testProviderKeyIsRequired() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('$providerKey must not be empty'); new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, '', $this->accessDecisionManager); } @@ -68,7 +68,7 @@ class SwitchUserListenerTest extends TestCase public function testExitUserThrowsAuthenticationExceptionIfNoCurrentToken() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException::class); $this->tokenStorage->setToken(null); $this->request->query->set('_switch_user', '_exit'); $listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager); @@ -77,7 +77,7 @@ class SwitchUserListenerTest extends TestCase public function testExitUserThrowsAuthenticationExceptionIfOriginalTokenCannotBeFound() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException::class); $token = new UsernamePasswordToken('username', '', 'key', ['ROLE_FOO']); $this->tokenStorage->setToken($token); @@ -99,7 +99,7 @@ class SwitchUserListenerTest extends TestCase $this->assertSame([], $this->request->query->all()); $this->assertSame('', $this->request->server->get('QUERY_STRING')); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $this->event->getResponse()); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $this->event->getResponse()); $this->assertSame($this->request->getUri(), $this->event->getResponse()->getTargetUrl()); $this->assertSame($originalToken, $this->tokenStorage->getToken()); } @@ -122,8 +122,8 @@ class SwitchUserListenerTest extends TestCase public function testExitUserDispatchesEventWithRefreshedUser() { - $originalUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $refreshedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $originalUser = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); + $refreshedUser = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $this ->userProvider ->expects($this->any()) @@ -173,7 +173,7 @@ class SwitchUserListenerTest extends TestCase public function testSwitchUserIsDisallowed() { - $this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class); $token = new UsernamePasswordToken('username', '', 'key', ['ROLE_FOO']); $user = new User('username', 'password', []); @@ -195,7 +195,7 @@ class SwitchUserListenerTest extends TestCase public function testSwitchUserTurnsAuthenticationExceptionTo403() { - $this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class); $token = new UsernamePasswordToken('username', '', 'key', ['ROLE_ALLOWED_TO_SWITCH']); $this->tokenStorage->setToken($token); @@ -237,7 +237,7 @@ class SwitchUserListenerTest extends TestCase $this->assertSame([], $this->request->query->all()); $this->assertSame('', $this->request->server->get('QUERY_STRING')); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $this->tokenStorage->getToken()); + $this->assertInstanceOf(UsernamePasswordToken::class, $this->tokenStorage->getToken()); } public function testSwitchUserAlreadySwitched() @@ -297,7 +297,7 @@ class SwitchUserListenerTest extends TestCase $this->assertSame([], $this->request->query->all()); $this->assertSame('', $this->request->server->get('QUERY_STRING')); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $this->tokenStorage->getToken()); + $this->assertInstanceOf(UsernamePasswordToken::class, $this->tokenStorage->getToken()); } public function testSwitchUserKeepsOtherQueryStringParameters() @@ -327,7 +327,7 @@ class SwitchUserListenerTest extends TestCase $listener($this->event); $this->assertSame('page=3§ion=2', $this->request->server->get('QUERY_STRING')); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $this->tokenStorage->getToken()); + $this->assertInstanceOf(UsernamePasswordToken::class, $this->tokenStorage->getToken()); } public function testSwitchUserWithReplacedToken() @@ -374,7 +374,7 @@ class SwitchUserListenerTest extends TestCase public function testSwitchUserThrowsAuthenticationExceptionIfNoCurrentToken() { - $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException::class); $this->tokenStorage->setToken(null); $this->request->query->set('_switch_user', 'username'); $listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager); @@ -403,7 +403,7 @@ class SwitchUserListenerTest extends TestCase $listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager, null, '_switch_user', 'ROLE_ALLOWED_TO_SWITCH', null, true); $listener($this->event); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $this->tokenStorage->getToken()); + $this->assertInstanceOf(UsernamePasswordToken::class, $this->tokenStorage->getToken()); $this->assertFalse($this->event->hasResponse()); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index b978777084..ffdec63b27 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -33,9 +33,9 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase public function testHandleWhenUsernameLength($username, $ok) { $request = Request::create('/login_check', 'POST', ['_username' => $username]); - $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); + $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock()); - $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); + $httpUtils = $this->getMockBuilder(HttpUtils::class)->getMock(); $httpUtils ->expects($this->any()) ->method('checkRequestPath') @@ -46,14 +46,14 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase ->willReturn(new RedirectResponse('/hello')) ; - $failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); + $failureHandler = $this->getMockBuilder(\Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface::class)->getMock(); $failureHandler ->expects($ok ? $this->never() : $this->once()) ->method('onAuthenticationFailure') ->willReturn(new Response()) ; - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')->disableOriginalConstructor()->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager::class)->disableOriginalConstructor()->getMock(); $authenticationManager ->expects($ok ? $this->once() : $this->never()) ->method('authenticate') @@ -61,9 +61,9 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase ; $listener = new UsernamePasswordFormAuthenticationListener( - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(), $authenticationManager, - $this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface::class)->getMock(), $httpUtils, 'TheProviderKey', new DefaultAuthenticationSuccessHandler($httpUtils), @@ -86,18 +86,18 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase */ public function testHandleNonStringUsernameWithArray($postOnly) { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $this->expectExceptionMessage('The key "_username" must be a string, "array" given.'); $request = Request::create('/login_check', 'POST', ['_username' => []]); - $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); + $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock()); $listener = new UsernamePasswordFormAuthenticationListener( new TokenStorage(), - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(), new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE), $httpUtils = new HttpUtils(), 'foo', new DefaultAuthenticationSuccessHandler($httpUtils), - new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils), + new DefaultAuthenticationFailureHandler($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $httpUtils), ['require_previous_session' => false, 'post_only' => $postOnly] ); $event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); @@ -109,18 +109,18 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase */ public function testHandleNonStringUsernameWithInt($postOnly) { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $this->expectExceptionMessage('The key "_username" must be a string, "integer" given.'); $request = Request::create('/login_check', 'POST', ['_username' => 42]); - $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); + $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock()); $listener = new UsernamePasswordFormAuthenticationListener( new TokenStorage(), - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(), new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE), $httpUtils = new HttpUtils(), 'foo', new DefaultAuthenticationSuccessHandler($httpUtils), - new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils), + new DefaultAuthenticationFailureHandler($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $httpUtils), ['require_previous_session' => false, 'post_only' => $postOnly] ); $event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); @@ -132,18 +132,18 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase */ public function testHandleNonStringUsernameWithObject($postOnly) { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $this->expectExceptionMessage('The key "_username" must be a string, "object" given.'); $request = Request::create('/login_check', 'POST', ['_username' => new \stdClass()]); - $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); + $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock()); $listener = new UsernamePasswordFormAuthenticationListener( new TokenStorage(), - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(), new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE), $httpUtils = new HttpUtils(), 'foo', new DefaultAuthenticationSuccessHandler($httpUtils), - new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils), + new DefaultAuthenticationFailureHandler($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $httpUtils), ['require_previous_session' => false, 'post_only' => $postOnly] ); $event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); @@ -162,15 +162,15 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase ->willReturn('someUsername'); $request = Request::create('/login_check', 'POST', ['_username' => $usernameClass]); - $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); + $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock()); $listener = new UsernamePasswordFormAuthenticationListener( new TokenStorage(), - $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), + $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(), new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE), $httpUtils = new HttpUtils(), 'foo', new DefaultAuthenticationSuccessHandler($httpUtils), - new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils), + new DefaultAuthenticationFailureHandler($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $httpUtils), ['require_previous_session' => false, 'post_only' => $postOnly] ); $event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php index b71d4fc490..d12a30974f 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php @@ -106,7 +106,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase public function testAttemptAuthenticationNoJson() { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $this->expectExceptionMessage('Invalid JSON'); $this->createListener(); $request = new Request(); @@ -118,7 +118,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase public function testAttemptAuthenticationNoUsername() { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $this->expectExceptionMessage('The key "username" must be provided'); $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"usr": "dunglas", "password": "foo"}'); @@ -129,7 +129,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase public function testAttemptAuthenticationNoPassword() { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $this->expectExceptionMessage('The key "password" must be provided'); $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "pass": "foo"}'); @@ -140,7 +140,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase public function testAttemptAuthenticationUsernameNotAString() { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $this->expectExceptionMessage('The key "username" must be a string.'); $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": 1, "password": "foo"}'); @@ -151,7 +151,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase public function testAttemptAuthenticationPasswordNotAString() { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $this->expectExceptionMessage('The key "password" must be a string.'); $this->createListener(); $request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": 1}'); @@ -221,7 +221,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase $this->configurePreviousSession($request); $event = new RequestEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST); - $sessionStrategy = $this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(); + $sessionStrategy = $this->getMockBuilder(\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface::class)->getMock(); $sessionStrategy->expects($this->once()) ->method('onAuthentication') ->with($request, $this->isInstanceOf(TokenInterface::class)); @@ -233,7 +233,7 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase private function configurePreviousSession(Request $request) { - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock(); $session->expects($this->any()) ->method('getName') ->willReturn('test_session_name'); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php index c81b2d589e..52ed236889 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php @@ -32,9 +32,9 @@ class X509AuthenticationListenerTest extends TestCase $request = new Request([], [], [], [], [], $serverVars); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey'); @@ -60,9 +60,9 @@ class X509AuthenticationListenerTest extends TestCase { $request = new Request([], [], [], [], [], ['SSL_CLIENT_S_DN' => $credentials]); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey'); @@ -86,12 +86,12 @@ class X509AuthenticationListenerTest extends TestCase public function testGetPreAuthenticatedDataNoData() { - $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); + $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class); $request = new Request([], [], [], [], [], []); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey'); @@ -109,9 +109,9 @@ class X509AuthenticationListenerTest extends TestCase 'TheUserKey' => 'TheUser', 'TheCredentialsKey' => 'TheCredentials', ]); - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(); - $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); + $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey', 'TheUserKey', 'TheCredentialsKey'); diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php index 50675a6003..3eb2607ba6 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php @@ -23,7 +23,7 @@ class FirewallMapTest extends TestCase $request = new Request(); - $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); + $notMatchingMatcher = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestMatcher::class)->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') @@ -33,7 +33,7 @@ class FirewallMapTest extends TestCase $map->add($notMatchingMatcher, [function () {}]); - $matchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); + $matchingMatcher = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestMatcher::class)->getMock(); $matchingMatcher ->expects($this->once()) ->method('matches') @@ -41,11 +41,11 @@ class FirewallMapTest extends TestCase ->willReturn(true) ; $theListener = function () {}; - $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); + $theException = $this->getMockBuilder(\Symfony\Component\Security\Http\Firewall\ExceptionListener::class)->disableOriginalConstructor()->getMock(); $map->add($matchingMatcher, [$theListener], $theException); - $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); + $tooLateMatcher = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestMatcher::class)->getMock(); $tooLateMatcher ->expects($this->never()) ->method('matches') @@ -65,7 +65,7 @@ class FirewallMapTest extends TestCase $request = new Request(); - $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); + $notMatchingMatcher = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestMatcher::class)->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') @@ -76,11 +76,11 @@ class FirewallMapTest extends TestCase $map->add($notMatchingMatcher, [function () {}]); $theListener = function () {}; - $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); + $theException = $this->getMockBuilder(\Symfony\Component\Security\Http\Firewall\ExceptionListener::class)->disableOriginalConstructor()->getMock(); $map->add(null, [$theListener], $theException); - $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); + $tooLateMatcher = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestMatcher::class)->getMock(); $tooLateMatcher ->expects($this->never()) ->method('matches') @@ -100,7 +100,7 @@ class FirewallMapTest extends TestCase $request = new Request(); - $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); + $notMatchingMatcher = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestMatcher::class)->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php index 983aec3b74..77cb3948e7 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php @@ -24,18 +24,18 @@ class FirewallTest extends TestCase { public function testOnKernelRequestRegistersExceptionListener() { - $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock(); - $listener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); + $listener = $this->getMockBuilder(ExceptionListener::class)->disableOriginalConstructor()->getMock(); $listener ->expects($this->once()) ->method('register') ->with($this->equalTo($dispatcher)) ; - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); + $map = $this->getMockBuilder(FirewallMapInterface::class)->getMock(); $map ->expects($this->once()) ->method('getListeners') @@ -43,7 +43,7 @@ class FirewallTest extends TestCase ->willReturn([[], $listener, null]) ; - $event = new RequestEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $firewall = new Firewall($map, $dispatcher); $firewall->onKernelRequest($event); @@ -61,7 +61,7 @@ class FirewallTest extends TestCase $called[] = 2; }; - $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); + $map = $this->getMockBuilder(FirewallMapInterface::class)->getMock(); $map ->expects($this->once()) ->method('getListeners') @@ -71,8 +71,8 @@ class FirewallTest extends TestCase $event = $this->getMockBuilder(RequestEvent::class) ->setMethods(['hasResponse']) ->setConstructorArgs([ - $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), - $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(), + $this->getMockBuilder(HttpKernelInterface::class)->getMock(), + $this->getMockBuilder(Request::class)->disableOriginalConstructor()->disableOriginalClone()->getMock(), HttpKernelInterface::MASTER_REQUEST, ]) ->getMock() @@ -83,7 +83,7 @@ class FirewallTest extends TestCase ->willReturn(true) ; - $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); + $firewall = new Firewall($map, $this->getMockBuilder(EventDispatcherInterface::class)->getMock()); $firewall->onKernelRequest($event); $this->assertSame([1], $called); @@ -91,19 +91,19 @@ class FirewallTest extends TestCase public function testOnKernelRequestWithSubRequest() { - $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); + $map = $this->getMockBuilder(FirewallMapInterface::class)->getMock(); $map ->expects($this->never()) ->method('getListeners') ; $event = new RequestEvent( - $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), - $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(), + $this->getMockBuilder(HttpKernelInterface::class)->getMock(), + $this->getMockBuilder(Request::class)->getMock(), HttpKernelInterface::SUB_REQUEST ); - $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); + $firewall = new Firewall($map, $this->getMockBuilder(EventDispatcherInterface::class)->getMock()); $firewall->onKernelRequest($event); $this->assertFalse($event->hasResponse()); diff --git a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php index 05d02b886e..932f1cfb55 100644 --- a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php +++ b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php @@ -86,7 +86,7 @@ class HttpUtilsTest extends TestCase public function testCreateRedirectResponseWithRouteName() { - $utils = new HttpUtils($urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()); + $utils = new HttpUtils($urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock()); $urlGenerator ->expects($this->any()) @@ -97,7 +97,7 @@ class HttpUtilsTest extends TestCase $urlGenerator ->expects($this->any()) ->method('getContext') - ->willReturn($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Routing\RequestContext::class)->getMock()) ; $response = $utils->createRedirectResponse($this->getRequest(), 'foobar'); @@ -120,7 +120,7 @@ class HttpUtilsTest extends TestCase public function testCreateRequestWithRouteName() { - $utils = new HttpUtils($urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()); + $utils = new HttpUtils($urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock()); $urlGenerator ->expects($this->once()) @@ -130,7 +130,7 @@ class HttpUtilsTest extends TestCase $urlGenerator ->expects($this->any()) ->method('getContext') - ->willReturn($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()) + ->willReturn($this->getMockBuilder(\Symfony\Component\Routing\RequestContext::class)->getMock()) ; $subRequest = $utils->createRequest($this->getRequest(), 'foobar'); @@ -140,7 +140,7 @@ class HttpUtilsTest extends TestCase public function testCreateRequestWithAbsoluteUrl() { - $utils = new HttpUtils($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()); + $utils = new HttpUtils($this->getMockBuilder(UrlGeneratorInterface::class)->getMock()); $subRequest = $utils->createRequest($this->getRequest(), 'http://symfony.com/'); $this->assertEquals('/', $subRequest->getPathInfo()); @@ -149,7 +149,7 @@ class HttpUtilsTest extends TestCase public function testCreateRequestPassesSessionToTheNewRequest() { $request = $this->getRequest(); - $request->setSession($session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); + $request->setSession($session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock()); $utils = new HttpUtils($this->getUrlGenerator()); $subRequest = $utils->createRequest($request, '/foobar'); @@ -195,7 +195,7 @@ class HttpUtilsTest extends TestCase public function testCheckRequestPathWithUrlMatcherAndResourceNotFound() { - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); + $urlMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\UrlMatcherInterface::class)->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -210,7 +210,7 @@ class HttpUtilsTest extends TestCase public function testCheckRequestPathWithUrlMatcherAndMethodNotAllowed() { $request = $this->getRequest(); - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $urlMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $urlMatcher ->expects($this->any()) ->method('matchRequest') @@ -224,7 +224,7 @@ class HttpUtilsTest extends TestCase public function testCheckRequestPathWithUrlMatcherAndResourceFoundByUrl() { - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); + $urlMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\UrlMatcherInterface::class)->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -239,7 +239,7 @@ class HttpUtilsTest extends TestCase public function testCheckRequestPathWithUrlMatcherAndResourceFoundByRequest() { $request = $this->getRequest(); - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $urlMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $urlMatcher ->expects($this->any()) ->method('matchRequest') @@ -253,8 +253,8 @@ class HttpUtilsTest extends TestCase public function testCheckRequestPathWithUrlMatcherLoadingException() { - $this->expectException('RuntimeException'); - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); + $this->expectException(\RuntimeException::class); + $urlMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\UrlMatcherInterface::class)->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -267,7 +267,7 @@ class HttpUtilsTest extends TestCase public function testCheckPathWithoutRouteParam() { - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); + $urlMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\UrlMatcherInterface::class)->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -280,7 +280,7 @@ class HttpUtilsTest extends TestCase public function testUrlMatcher() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface'); new HttpUtils($this->getUrlGenerator(), new \stdClass()); } @@ -305,7 +305,7 @@ class HttpUtilsTest extends TestCase public function testUrlGeneratorIsRequiredToGenerateUrl() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('You must provide a UrlGeneratorInterface instance to be able to use routes.'); $utils = new HttpUtils(); $utils->generateUri(new Request(), 'route_name'); @@ -313,7 +313,7 @@ class HttpUtilsTest extends TestCase private function getUrlGenerator($generatedUrl = '/foo/bar') { - $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); + $urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); $urlGenerator ->expects($this->any()) ->method('generate') diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php index f2407fcb3f..cee1d5076a 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php @@ -24,7 +24,7 @@ class CookieClearingLogoutHandlerTest extends TestCase { $request = new Request(); $response = new Response(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $handler = new CookieClearingLogoutHandler(['foo' => ['path' => '/foo', 'domain' => 'foo.foo', 'secure' => true, 'samesite' => Cookie::SAMESITE_STRICT], 'foo2' => ['path' => null, 'domain' => null]]); diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/CsrfTokenClearingLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/CsrfTokenClearingLogoutHandlerTest.php index 06eb56139e..7e75ce4549 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/CsrfTokenClearingLogoutHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/CsrfTokenClearingLogoutHandlerTest.php @@ -39,7 +39,7 @@ class CsrfTokenClearingLogoutHandlerTest extends TestCase $this->assertSame('bar', $this->session->get('foo/foo')); $this->assertSame('baz', $this->session->get('foo/foobar')); - $this->csrfTokenClearingLogoutHandler->logout(new Request(), new Response(), $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $this->csrfTokenClearingLogoutHandler->logout(new Request(), new Response(), $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); $this->assertFalse($this->csrfTokenStorage->hasToken('foo')); $this->assertFalse($this->csrfTokenStorage->hasToken('foobar')); @@ -59,7 +59,7 @@ class CsrfTokenClearingLogoutHandlerTest extends TestCase $this->assertSame('bar', $this->session->get('bar/foo')); $this->assertSame('baz', $this->session->get('bar/foobar')); - $this->csrfTokenClearingLogoutHandler->logout(new Request(), new Response(), $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $this->csrfTokenClearingLogoutHandler->logout(new Request(), new Response(), $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); $this->assertTrue($barNamespaceCsrfSessionStorage->hasToken('foo')); $this->assertTrue($barNamespaceCsrfSessionStorage->hasToken('foobar')); diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php index d0c6383236..24e198228f 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php @@ -19,10 +19,10 @@ class DefaultLogoutSuccessHandlerTest extends TestCase { public function testLogout() { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); $response = new RedirectResponse('/dashboard'); - $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); + $httpUtils = $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)->getMock(); $httpUtils->expects($this->once()) ->method('createRedirectResponse') ->with($request, '/dashboard') diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/LogoutUrlGeneratorTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/LogoutUrlGeneratorTest.php index 1d9c5e6c88..08e2a730bf 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/LogoutUrlGeneratorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/LogoutUrlGeneratorTest.php @@ -48,7 +48,7 @@ class LogoutUrlGeneratorTest extends TestCase public function testGetLogoutPathWithoutLogoutListenerRegisteredForKeyThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('No LogoutListener found for firewall key "unregistered_key".'); $this->generator->registerListener('secured_area', '/logout', null, null, null); @@ -65,7 +65,7 @@ class LogoutUrlGeneratorTest extends TestCase public function testGuessFromAnonymousTokenThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Unable to generate a logout url for an anonymous token.'); $this->tokenStorage->setToken(new AnonymousToken('default', 'anon.')); @@ -99,7 +99,7 @@ class LogoutUrlGeneratorTest extends TestCase public function testUnableToGuessThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Unable to find the current firewall LogoutListener, please provide the provider key manually'); $this->generator->registerListener('secured_area', '/logout', null, null); diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php index cf25d1f77c..f8fb31dbea 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php @@ -21,9 +21,9 @@ class SessionLogoutHandlerTest extends TestCase { $handler = new SessionLogoutHandler(); - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); $response = new Response(); - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class)->disableOriginalConstructor()->getMock(); $request ->expects($this->once()) @@ -36,6 +36,6 @@ class SessionLogoutHandlerTest extends TestCase ->method('invalidate') ; - $handler->logout($request, $response, $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); + $handler->logout($request, $response, $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()); } } diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php index 7a0506dfe8..6055908031 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php @@ -52,7 +52,7 @@ class AbstractRememberMeServicesTest extends TestCase public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $service = $this->getService(null, ['name' => 'foo', 'path' => null, 'domain' => null]); $request = new Request(); $request->cookies->set('foo', 'foo'); @@ -72,7 +72,7 @@ class AbstractRememberMeServicesTest extends TestCase $request = new Request(); $request->cookies->set('foo', 'foo'); - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -100,10 +100,10 @@ class AbstractRememberMeServicesTest extends TestCase $service = $this->getService(null, $options); $request = new Request(); $response = new Response(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $service->logout($request, $response, $token); $cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Cookie', $cookie); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\Cookie::class, $cookie); $this->assertTrue($cookie->isCleared()); $this->assertSame($options['name'], $cookie->getName()); $this->assertSame($options['path'], $cookie->getPath()); @@ -135,7 +135,7 @@ class AbstractRememberMeServicesTest extends TestCase $service = $this->getService(null, ['name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null]); $request = new Request(); $response = new Response(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -157,8 +157,8 @@ class AbstractRememberMeServicesTest extends TestCase $service = $this->getService(null, ['name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo', 'path' => null, 'domain' => null]); $request = new Request(); $response = new Response(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -181,8 +181,8 @@ class AbstractRememberMeServicesTest extends TestCase $service = $this->getService(null, ['name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null]); $request = new Request(); $response = new Response(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -208,8 +208,8 @@ class AbstractRememberMeServicesTest extends TestCase $request = new Request(); $request->request->set('foo', ['bar' => $value]); $response = new Response(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -235,8 +235,8 @@ class AbstractRememberMeServicesTest extends TestCase $request = new Request(); $request->request->set('foo', $value); $response = new Response(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -277,7 +277,7 @@ class AbstractRememberMeServicesTest extends TestCase public function testThereShouldBeNoCookieDelimiterInCookieParts() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('cookie delimiter'); $cookieParts = ['aa', 'b'.AbstractRememberMeServices::COOKIE_DELIMITER.'b', 'cc']; $service = $this->getService(); @@ -291,14 +291,14 @@ class AbstractRememberMeServicesTest extends TestCase $userProvider = $this->getProvider(); } - return $this->getMockForAbstractClass('Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices', [ + return $this->getMockForAbstractClass(AbstractRememberMeServices::class, [ [$userProvider], 'foosecret', 'fookey', $options, $logger, ]); } protected function getProvider() { - $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $provider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); $provider ->expects($this->any()) ->method('supportsClass') diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index a3d9c2c5fe..5b9157f455 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -62,7 +62,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $tokenValue = 'foovalue', ])); - $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); + $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -81,7 +81,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); - $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); + $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -106,7 +106,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); - $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); + $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock(); $service->setTokenProvider($tokenProvider); $tokenProvider @@ -137,7 +137,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); - $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); + $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -152,7 +152,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase public function testAutoLogin() { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -171,7 +171,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); - $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); + $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -182,7 +182,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $returnedToken = $service->autoLogin($request); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', $returnedToken); + $this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::class, $returnedToken); $this->assertSame($user, $returnedToken->getUser()); $this->assertEquals('foosecret', $returnedToken->getSecret()); $this->assertTrue($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME)); @@ -194,9 +194,9 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); $response = new Response(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); - $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); + $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock(); $tokenProvider ->expects($this->once()) ->method('deleteTokenBySeries') @@ -220,9 +220,9 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $service = $this->getService(null, ['name' => 'foo', 'path' => null, 'domain' => null]); $request = new Request(); $response = new Response(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); - $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); + $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock(); $tokenProvider ->expects($this->never()) ->method('deleteTokenBySeries') @@ -243,9 +243,9 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $request->cookies->set('foo', 'somefoovalue'); $response = new Response(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); - $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); + $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock(); $tokenProvider ->expects($this->never()) ->method('deleteTokenBySeries') @@ -273,20 +273,20 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $response = new Response(); - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $account ->expects($this->once()) ->method('getUsername') ->willReturn('foo') ; - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token ->expects($this->any()) ->method('getUser') ->willReturn($account) ; - $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); + $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock(); $tokenProvider ->expects($this->once()) ->method('createNewToken') @@ -329,7 +329,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase protected function getProvider() { - $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $provider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); $provider ->expects($this->any()) ->method('supportsClass') diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php index 832c4b912e..fb65baa612 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php @@ -83,7 +83,7 @@ class ResponseListenerTest extends TestCase private function getResponse() { $response = new Response(); - $response->headers = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->getMock(); + $response->headers = $this->getMockBuilder(\Symfony\Component\HttpFoundation\ResponseHeaderBag::class)->getMock(); return $response; } diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php index 4a34d61421..5a1330f747 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php @@ -64,7 +64,7 @@ class TokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $request->cookies->set('foo', base64_encode('class:'.base64_encode('foouser').':123456789:fooHash')); - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user ->expects($this->once()) ->method('getPassword') @@ -89,7 +89,7 @@ class TokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time() - 1, 'foopass')); - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user ->expects($this->once()) ->method('getPassword') @@ -114,7 +114,7 @@ class TokenBasedRememberMeServicesTest extends TestCase */ public function testAutoLogin($username) { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -140,7 +140,7 @@ class TokenBasedRememberMeServicesTest extends TestCase $returnedToken = $service->autoLogin($request); - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', $returnedToken); + $this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::class, $returnedToken); $this->assertSame($user, $returnedToken->getUser()); $this->assertEquals('foosecret', $returnedToken->getSecret()); } @@ -158,7 +158,7 @@ class TokenBasedRememberMeServicesTest extends TestCase $service = $this->getService(null, ['name' => 'foo', 'path' => null, 'domain' => null, 'secure' => true, 'httponly' => false]); $request = new Request(); $response = new Response(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $service->logout($request, $response, $token); @@ -188,7 +188,7 @@ class TokenBasedRememberMeServicesTest extends TestCase $service = $this->getService(null, ['name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null]); $request = new Request(); $response = new Response(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -210,8 +210,8 @@ class TokenBasedRememberMeServicesTest extends TestCase $request = new Request(); $response = new Response(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); + $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(); $user ->expects($this->once()) ->method('getPassword') @@ -275,7 +275,7 @@ class TokenBasedRememberMeServicesTest extends TestCase protected function getProvider() { - $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $provider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock(); $provider ->expects($this->any()) ->method('supportsClass') diff --git a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php index c4df17b53b..71798aa843 100644 --- a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php @@ -27,7 +27,7 @@ class SessionAuthenticationStrategyTest extends TestCase public function testUnsupportedStrategy() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Invalid session authentication strategy "foo"'); $request = $this->getRequest(); $request->expects($this->never())->method('getSession'); @@ -38,7 +38,7 @@ class SessionAuthenticationStrategyTest extends TestCase public function testSessionIsMigrated() { - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock(); $session->expects($this->once())->method('migrate')->with($this->equalTo(true)); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); @@ -47,7 +47,7 @@ class SessionAuthenticationStrategyTest extends TestCase public function testSessionIsInvalidated() { - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); + $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock(); $session->expects($this->once())->method('invalidate'); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::INVALIDATE); @@ -56,7 +56,7 @@ class SessionAuthenticationStrategyTest extends TestCase private function getRequest($session = null) { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock(); if (null !== $session) { $request->expects($this->any())->method('getSession')->willReturn($session); @@ -67,6 +67,6 @@ class SessionAuthenticationStrategyTest extends TestCase private function getToken() { - return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock(); } } diff --git a/src/Symfony/Component/Security/Http/Tests/Util/TargetPathTraitTest.php b/src/Symfony/Component/Security/Http/Tests/Util/TargetPathTraitTest.php index 9ef79f89a3..c97363fdaf 100644 --- a/src/Symfony/Component/Security/Http/Tests/Util/TargetPathTraitTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Util/TargetPathTraitTest.php @@ -12,7 +12,7 @@ class TargetPathTraitTest extends TestCase { $obj = new TestClassWithTargetPathTrait(); - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface') + $session = $this->getMockBuilder(SessionInterface::class) ->getMock(); $session->expects($this->once()) @@ -26,7 +26,7 @@ class TargetPathTraitTest extends TestCase { $obj = new TestClassWithTargetPathTrait(); - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface') + $session = $this->getMockBuilder(SessionInterface::class) ->getMock(); $session->expects($this->once()) @@ -45,7 +45,7 @@ class TargetPathTraitTest extends TestCase { $obj = new TestClassWithTargetPathTrait(); - $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface') + $session = $this->getMockBuilder(SessionInterface::class) ->getMock(); $session->expects($this->once()) diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/DiscriminatorMapTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/DiscriminatorMapTest.php index 81f2db2cdd..6570bc5804 100644 --- a/src/Symfony/Component/Serializer/Tests/Annotation/DiscriminatorMapTest.php +++ b/src/Symfony/Component/Serializer/Tests/Annotation/DiscriminatorMapTest.php @@ -35,25 +35,25 @@ class DiscriminatorMapTest extends TestCase public function testExceptionWithoutTypeProperty() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); new DiscriminatorMap(['mapping' => ['foo' => 'FooClass']]); } public function testExceptionWithEmptyTypeProperty() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); new DiscriminatorMap(['typeProperty' => '', 'mapping' => ['foo' => 'FooClass']]); } public function testExceptionWithoutMappingProperty() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); new DiscriminatorMap(['typeProperty' => 'type']); } public function testExceptionWitEmptyMappingProperty() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); new DiscriminatorMap(['typeProperty' => 'type', 'mapping' => []]); } } diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/GroupsTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/GroupsTest.php index 3fad6d82f8..45a755e090 100644 --- a/src/Symfony/Component/Serializer/Tests/Annotation/GroupsTest.php +++ b/src/Symfony/Component/Serializer/Tests/Annotation/GroupsTest.php @@ -21,19 +21,19 @@ class GroupsTest extends TestCase { public function testEmptyGroupsParameter() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); new Groups(['value' => []]); } public function testNotAnArrayGroupsParameter() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); new Groups(['value' => 12]); } public function testInvalidGroupsParameter() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); new Groups(['value' => ['a', 1, new \stdClass()]]); } diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php index 2c421576d1..9fbe55ce07 100644 --- a/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php +++ b/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php @@ -21,7 +21,7 @@ class MaxDepthTest extends TestCase { public function testNotSetMaxDepthParameter() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" should be set.'); new MaxDepth([]); } @@ -41,7 +41,7 @@ class MaxDepthTest extends TestCase */ public function testNotAnIntMaxDepthParameter($value) { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" must be a positive integer.'); new MaxDepth(['value' => $value]); } diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php index cb934580b0..7881b63f6b 100644 --- a/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php +++ b/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php @@ -21,7 +21,7 @@ class SerializedNameTest extends TestCase { public function testNotSetSerializedNameParameter() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\SerializedName" should be set.'); new SerializedName([]); } @@ -39,7 +39,7 @@ class SerializedNameTest extends TestCase */ public function testNotAStringSerializedNameParameter($value) { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\SerializedName" must be a non-empty string.'); new SerializedName(['value' => $value]); } diff --git a/src/Symfony/Component/Serializer/Tests/DependencyInjection/SerializerPassTest.php b/src/Symfony/Component/Serializer/Tests/DependencyInjection/SerializerPassTest.php index 65d7a65f5a..9f5b1141bf 100644 --- a/src/Symfony/Component/Serializer/Tests/DependencyInjection/SerializerPassTest.php +++ b/src/Symfony/Component/Serializer/Tests/DependencyInjection/SerializerPassTest.php @@ -25,7 +25,7 @@ class SerializerPassTest extends TestCase { public function testThrowExceptionWhenNoNormalizers() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('You must tag at least one service as "serializer.normalizer" to use the "serializer" service'); $container = new ContainerBuilder(); $container->register('serializer'); @@ -36,7 +36,7 @@ class SerializerPassTest extends TestCase public function testThrowExceptionWhenNoEncoders() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('You must tag at least one service as "serializer.encoder" to use the "serializer" service'); $container = new ContainerBuilder(); $container->register('serializer') diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php index 215e733861..7ab6486692 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php @@ -27,7 +27,7 @@ class ChainDecoderTest extends TestCase protected function setUp(): void { $this->decoder1 = $this - ->getMockBuilder('Symfony\Component\Serializer\Encoder\DecoderInterface') + ->getMockBuilder(\Symfony\Component\Serializer\Encoder\DecoderInterface::class) ->getMock(); $this->decoder1 @@ -40,7 +40,7 @@ class ChainDecoderTest extends TestCase ]); $this->decoder2 = $this - ->getMockBuilder('Symfony\Component\Serializer\Encoder\DecoderInterface') + ->getMockBuilder(\Symfony\Component\Serializer\Encoder\DecoderInterface::class) ->getMock(); $this->decoder2 @@ -72,7 +72,7 @@ class ChainDecoderTest extends TestCase public function testDecodeUnsupportedFormat() { - $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Serializer\Exception\RuntimeException::class); $this->chainDecoder->decode('string_to_decode', self::FORMAT_3); } } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php index 51c4f962dd..ba747933b7 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php @@ -29,7 +29,7 @@ class ChainEncoderTest extends TestCase protected function setUp(): void { $this->encoder1 = $this - ->getMockBuilder('Symfony\Component\Serializer\Encoder\EncoderInterface') + ->getMockBuilder(EncoderInterface::class) ->getMock(); $this->encoder1 @@ -42,7 +42,7 @@ class ChainEncoderTest extends TestCase ]); $this->encoder2 = $this - ->getMockBuilder('Symfony\Component\Serializer\Encoder\EncoderInterface') + ->getMockBuilder(EncoderInterface::class) ->getMock(); $this->encoder2 @@ -74,7 +74,7 @@ class ChainEncoderTest extends TestCase public function testEncodeUnsupportedFormat() { - $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Serializer\Exception\RuntimeException::class); $this->chainEncoder->encode(['foo' => 123], self::FORMAT_3); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php index 809bd02796..a51e23e56b 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php @@ -60,7 +60,7 @@ class JsonDecodeTest extends TestCase */ public function testDecodeWithException($value) { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->decode->decode($value, JsonEncoder::FORMAT); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php index 157b3999ea..57b74d4c67 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php @@ -53,7 +53,7 @@ class JsonEncodeTest extends TestCase public function testEncodeWithError() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->encode->encode("\xB1\x31", JsonEncoder::FORMAT); } } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php index b74d10bfca..3dedbd327c 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php @@ -67,7 +67,7 @@ class JsonEncoderTest extends TestCase public function testEncodeNotUtf8WithoutPartialOnError() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $arr = [ 'utf8' => 'Hello World!', 'notUtf8' => "\xb0\xd0\xb5\xd0", diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index a26f876918..0064bcefc8 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -86,7 +86,7 @@ class XmlEncoderTest extends TestCase public function testDocTypeIsNotAllowed() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->expectExceptionMessage('Document types are not allowed.'); $this->encoder->decode('', 'foo'); } @@ -708,19 +708,19 @@ XML; public function testDecodeInvalidXml() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->encoder->decode('', 'xml'); } public function testPreventsComplexExternalEntities() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->encoder->decode(']>&test;', 'xml'); } public function testDecodeEmptyXml() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->expectExceptionMessage('Invalid XML data, it can not be empty.'); $this->encoder->decode(' ', 'xml'); } diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/AttributeMetadataTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/AttributeMetadataTest.php index 9102374fd3..28f51c080c 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/AttributeMetadataTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/AttributeMetadataTest.php @@ -22,7 +22,7 @@ class AttributeMetadataTest extends TestCase public function testInterface() { $attributeMetadata = new AttributeMetadata('name'); - $this->assertInstanceOf('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface', $attributeMetadata); + $this->assertInstanceOf(\Symfony\Component\Serializer\Mapping\AttributeMetadataInterface::class, $attributeMetadata); } public function testGetName() diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php index 636d8a8ab8..9906959e4c 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/ClassMetadataTest.php @@ -23,7 +23,7 @@ class ClassMetadataTest extends TestCase public function testInterface() { $classMetadata = new ClassMetadata('name'); - $this->assertInstanceOf('Symfony\Component\Serializer\Mapping\ClassMetadataInterface', $classMetadata); + $this->assertInstanceOf(\Symfony\Component\Serializer\Mapping\ClassMetadataInterface::class, $classMetadata); } public function testAttributeMetadata() diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php index 907311d435..cd185853b3 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php @@ -57,7 +57,7 @@ class CacheMetadataFactoryTest extends TestCase public function testInvalidClassThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter()); diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php index db0e887fb5..596d235ab9 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php @@ -26,7 +26,7 @@ class ClassMetadataFactoryTest extends TestCase public function testInterface() { $classMetadata = new ClassMetadataFactory(new LoaderChain([])); - $this->assertInstanceOf('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface', $classMetadata); + $this->assertInstanceOf(\Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface::class, $classMetadata); } public function testGetMetadataFor() diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php index 617d27afbd..1f5166d878 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php @@ -40,7 +40,7 @@ class AnnotationLoaderTest extends TestCase public function testInterface() { - $this->assertInstanceOf('Symfony\Component\Serializer\Mapping\Loader\LoaderInterface', $this->loader); + $this->assertInstanceOf(\Symfony\Component\Serializer\Mapping\Loader\LoaderInterface::class, $this->loader); } public function testLoadClassMetadataReturnsTrueIfSuccessful() diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php index 4fc4032f96..1d9fdfdf6d 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php @@ -43,7 +43,7 @@ class XmlFileLoaderTest extends TestCase public function testInterface() { - $this->assertInstanceOf('Symfony\Component\Serializer\Mapping\Loader\LoaderInterface', $this->loader); + $this->assertInstanceOf(\Symfony\Component\Serializer\Mapping\Loader\LoaderInterface::class, $this->loader); } public function testLoadClassMetadataReturnsTrueIfSuccessful() diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php index 83e68f73e9..3dc537a72b 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php @@ -43,7 +43,7 @@ class YamlFileLoaderTest extends TestCase public function testInterface() { - $this->assertInstanceOf('Symfony\Component\Serializer\Mapping\Loader\LoaderInterface', $this->loader); + $this->assertInstanceOf(\Symfony\Component\Serializer\Mapping\Loader\LoaderInterface::class, $this->loader); } public function testLoadClassMetadataReturnsTrueIfSuccessful() @@ -59,7 +59,7 @@ class YamlFileLoaderTest extends TestCase public function testLoadClassMetadataReturnsThrowsInvalidMapping() { - $this->expectException('Symfony\Component\Serializer\Exception\MappingException'); + $this->expectException(\Symfony\Component\Serializer\Exception\MappingException::class); $loader = new YamlFileLoader(__DIR__.'/../../Fixtures/invalid-mapping.yml'); $loader->loadClassMetadata($this->metadata); } diff --git a/src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php b/src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php index 4847004c97..15e36a0df4 100644 --- a/src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php +++ b/src/Symfony/Component/Serializer/Tests/NameConverter/CamelCaseToSnakeCaseNameConverterTest.php @@ -22,7 +22,7 @@ class CamelCaseToSnakeCaseNameConverterTest extends TestCase public function testInterface() { $attributeMetadata = new CamelCaseToSnakeCaseNameConverter(); - $this->assertInstanceOf('Symfony\Component\Serializer\NameConverter\NameConverterInterface', $attributeMetadata); + $this->assertInstanceOf(\Symfony\Component\Serializer\NameConverter\NameConverterInterface::class, $attributeMetadata); } /** diff --git a/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php b/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php index 540e59ed58..6a55f3142c 100644 --- a/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php +++ b/src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php @@ -30,7 +30,7 @@ final class MetadataAwareNameConverterTest extends TestCase { $classMetadataFactory = $this->createMock(ClassMetadataFactoryInterface::class); $nameConverter = new MetadataAwareNameConverter($classMetadataFactory); - $this->assertInstanceOf('Symfony\Component\Serializer\NameConverter\NameConverterInterface', $nameConverter); + $this->assertInstanceOf(NameConverterInterface::class, $nameConverter); } /** diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php index 49df663042..9c26dd5bf6 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php @@ -39,8 +39,8 @@ class AbstractNormalizerTest extends TestCase protected function setUp(): void { - $loader = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\Loader\LoaderChain')->setConstructorArgs([[]])->getMock(); - $this->classMetadata = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory')->setConstructorArgs([$loader])->getMock(); + $loader = $this->getMockBuilder(\Symfony\Component\Serializer\Mapping\Loader\LoaderChain::class)->setConstructorArgs([[]])->getMock(); + $this->classMetadata = $this->getMockBuilder(\Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory::class)->setConstructorArgs([$loader])->getMock(); $this->normalizer = new AbstractNormalizerDummy($this->classMetadata); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php index 1b6e1b0a06..ccc7be237a 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -61,7 +61,7 @@ class AbstractObjectNormalizerTest extends TestCase public function testDenormalizeWithExtraAttributes() { - $this->expectException('Symfony\Component\Serializer\Exception\ExtraAttributesException'); + $this->expectException(\Symfony\Component\Serializer\Exception\ExtraAttributesException::class); $this->expectExceptionMessage('Extra attributes are not allowed ("fooFoo", "fooBar" are unknown).'); $factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); $normalizer = new AbstractObjectNormalizerDummy($factory); @@ -75,7 +75,7 @@ class AbstractObjectNormalizerTest extends TestCase public function testDenormalizeWithExtraAttributesAndNoGroupsWithMetadataFactory() { - $this->expectException('Symfony\Component\Serializer\Exception\ExtraAttributesException'); + $this->expectException(\Symfony\Component\Serializer\Exception\ExtraAttributesException::class); $this->expectExceptionMessage('Extra attributes are not allowed ("fooFoo", "fooBar" are unknown).'); $normalizer = new AbstractObjectNormalizerWithMetadata(); $normalizer->denormalize( @@ -278,7 +278,7 @@ class AbstractObjectNormalizerTest extends TestCase */ public function testExtraAttributesException() { - $this->expectException('Symfony\Component\Serializer\Exception\LogicException'); + $this->expectException(\Symfony\Component\Serializer\Exception\LogicException::class); $this->expectExceptionMessage('A class metadata factory must be provided in the constructor when setting "allow_extra_attributes" to false.'); $normalizer = new ObjectNormalizer(); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php index ad55636742..1a83c24bf2 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php @@ -30,7 +30,7 @@ class ArrayDenormalizerTest extends TestCase protected function setUp(): void { - $this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')->getMock(); + $this->serializer = $this->getMockBuilder(\Symfony\Component\Serializer\Serializer::class)->getMock(); $this->denormalizer = new ArrayDenormalizer(); $this->denormalizer->setSerializer($this->serializer); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php index b7566f8cf4..8551370d7a 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php @@ -31,9 +31,9 @@ class CustomNormalizerTest extends TestCase public function testInterface() { - $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\NormalizerInterface', $this->normalizer); - $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\DenormalizerInterface', $this->normalizer); - $this->assertInstanceOf('Symfony\Component\Serializer\SerializerAwareInterface', $this->normalizer); + $this->assertInstanceOf(\Symfony\Component\Serializer\Normalizer\NormalizerInterface::class, $this->normalizer); + $this->assertInstanceOf(\Symfony\Component\Serializer\Normalizer\DenormalizerInterface::class, $this->normalizer); + $this->assertInstanceOf(\Symfony\Component\Serializer\SerializerAwareInterface::class, $this->normalizer); } public function testSerialize() diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php index f1a906b593..1e54f5b37b 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php @@ -36,8 +36,8 @@ class DataUriNormalizerTest extends TestCase public function testInterface() { - $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\NormalizerInterface', $this->normalizer); - $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\DenormalizerInterface', $this->normalizer); + $this->assertInstanceOf(\Symfony\Component\Serializer\Normalizer\NormalizerInterface::class, $this->normalizer); + $this->assertInstanceOf(\Symfony\Component\Serializer\Normalizer\DenormalizerInterface::class, $this->normalizer); } public function testSupportNormalization() @@ -91,7 +91,7 @@ class DataUriNormalizerTest extends TestCase { $file = $this->normalizer->denormalize(self::TEST_TXT_DATA, 'SplFileInfo'); - $this->assertInstanceOf('SplFileInfo', $file); + $this->assertInstanceOf(\SplFileInfo::class, $file); $this->assertSame(file_get_contents(self::TEST_TXT_DATA), $this->getContent($file)); } @@ -99,7 +99,7 @@ class DataUriNormalizerTest extends TestCase { $file = $this->normalizer->denormalize(self::TEST_TXT_DATA, 'SplFileObject'); - $this->assertInstanceOf('SplFileObject', $file); + $this->assertInstanceOf(\SplFileObject::class, $file); $this->assertEquals(file_get_contents(self::TEST_TXT_DATA), $this->getContent($file)); } @@ -107,13 +107,13 @@ class DataUriNormalizerTest extends TestCase { $file = $this->normalizer->denormalize(self::TEST_GIF_DATA, 'Symfony\Component\HttpFoundation\File\File'); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $file); + $this->assertInstanceOf(File::class, $file); $this->assertSame(file_get_contents(self::TEST_GIF_DATA), $this->getContent($file->openFile())); } public function testGiveNotAccessToLocalFiles() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->expectExceptionMessage('The provided "data:" URI is not valid.'); $this->normalizer->denormalize('/etc/shadow', 'SplFileObject'); } @@ -123,7 +123,7 @@ class DataUriNormalizerTest extends TestCase */ public function testInvalidData($uri) { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->normalizer->denormalize($uri, 'SplFileObject'); } @@ -149,7 +149,7 @@ class DataUriNormalizerTest extends TestCase */ public function testValidData($uri) { - $this->assertInstanceOf('SplFileObject', $this->normalizer->denormalize($uri, 'SplFileObject')); + $this->assertInstanceOf(\SplFileObject::class, $this->normalizer->denormalize($uri, 'SplFileObject')); } public function validUriProvider() diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php index 3e60a360ec..414733592d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php @@ -82,7 +82,7 @@ class DateIntervalNormalizerTest extends TestCase public function testNormalizeInvalidObjectThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The object must be an instance of "\DateInterval".'); $this->normalizer->normalize(new \stdClass()); } @@ -130,26 +130,26 @@ class DateIntervalNormalizerTest extends TestCase public function testDenormalizeExpectsString() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $this->normalizer->denormalize(1234, \DateInterval::class); } public function testDenormalizeNonISO8601IntervalStringThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->expectExceptionMessage('Expected a valid ISO 8601 interval string.'); $this->normalizer->denormalize('10 years 2 months 3 days', \DateInterval::class, null); } public function testDenormalizeInvalidDataThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->normalizer->denormalize('invalid interval', \DateInterval::class); } public function testDenormalizeFormatMismatchThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->normalizer->denormalize('P00Y00M00DT00H00M00S', \DateInterval::class, null, [DateIntervalNormalizer::FORMAT_KEY => 'P%yY%mM%dD']); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php index f4669b134e..6be20c5cac 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php @@ -181,7 +181,7 @@ class DateTimeNormalizerTest extends TestCase public function testNormalizeInvalidObjectThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The object must implement the "\DateTimeInterface".'); $this->normalizer->normalize(new \stdClass()); } @@ -270,27 +270,27 @@ class DateTimeNormalizerTest extends TestCase public function testDenormalizeInvalidDataThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->normalizer->denormalize('invalid date', \DateTimeInterface::class); } public function testDenormalizeNullThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->expectExceptionMessage('The data is either an empty string or null, you should pass a string that can be parsed with the passed format or a valid DateTime string.'); $this->normalizer->denormalize(null, \DateTimeInterface::class); } public function testDenormalizeEmptyStringThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->expectExceptionMessage('The data is either an empty string or null, you should pass a string that can be parsed with the passed format or a valid DateTime string.'); $this->normalizer->denormalize('', \DateTimeInterface::class); } public function testDenormalizeFormatMismatchThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->normalizer->denormalize('2016-01-01T00:00:00+00:00', \DateTimeInterface::class, null, [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d|']); } } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeZoneNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeZoneNormalizerTest.php index 91d144e844..0fdbca0497 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeZoneNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeZoneNormalizerTest.php @@ -44,7 +44,7 @@ class DateTimeZoneNormalizerTest extends TestCase public function testNormalizeBadObjectTypeThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $this->normalizer->normalize(new \stdClass()); } @@ -63,13 +63,13 @@ class DateTimeZoneNormalizerTest extends TestCase public function testDenormalizeNullTimeZoneThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\NotNormalizableValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\NotNormalizableValueException::class); $this->normalizer->denormalize(null, \DateTimeZone::class, null); } public function testDenormalizeBadTimeZoneThrowsException() { - $this->expectException('Symfony\Component\Serializer\Exception\NotNormalizableValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\NotNormalizableValueException::class); $this->normalizer->denormalize('Jupiter/Europa', \DateTimeZone::class, null); } } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index a3b4819656..5f464f9a5a 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -75,8 +75,8 @@ class GetSetMethodNormalizerTest extends TestCase public function testInterface() { - $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\NormalizerInterface', $this->normalizer); - $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\DenormalizerInterface', $this->normalizer); + $this->assertInstanceOf(NormalizerInterface::class, $this->normalizer); + $this->assertInstanceOf(DenormalizerInterface::class, $this->normalizer); } public function testNormalize() @@ -424,9 +424,9 @@ class GetSetMethodNormalizerTest extends TestCase public function testUnableToNormalizeObjectAttribute() { - $this->expectException('Symfony\Component\Serializer\Exception\LogicException'); + $this->expectException(\Symfony\Component\Serializer\Exception\LogicException::class); $this->expectExceptionMessage('Cannot normalize attribute "object" because the injected serializer is not a normalizer'); - $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock(); + $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); $this->normalizer->setSerializer($serializer); $obj = new GetSetDummy(); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php index f1373516a9..8e9464d801 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php @@ -78,7 +78,7 @@ class JsonSerializableNormalizerTest extends TestCase private function doTestCircularNormalize(bool $legacy = false) { - $this->expectException('Symfony\Component\Serializer\Exception\CircularReferenceException'); + $this->expectException(\Symfony\Component\Serializer\Exception\CircularReferenceException::class); $legacy ? $this->normalizer->setCircularReferenceLimit(1) : $this->createNormalizer([JsonSerializableNormalizer::CIRCULAR_REFERENCE_LIMIT => 1]); $this->serializer @@ -96,7 +96,7 @@ class JsonSerializableNormalizerTest extends TestCase public function testInvalidDataThrowException() { - $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The object must implement "JsonSerializable".'); $this->normalizer->normalize(new \stdClass()); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 4a2ac344ec..0f4ef94cd0 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -247,7 +247,7 @@ class ObjectNormalizerTest extends TestCase public function testConstructorWithUnknownObjectTypeHintDenormalize() { - $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Serializer\Exception\RuntimeException::class); $this->expectExceptionMessage('Could not determine the class of the parameter "unknown".'); $data = [ 'id' => 10, @@ -690,9 +690,9 @@ class ObjectNormalizerTest extends TestCase public function testUnableToNormalizeObjectAttribute() { - $this->expectException('Symfony\Component\Serializer\Exception\LogicException'); + $this->expectException(\Symfony\Component\Serializer\Exception\LogicException::class); $this->expectExceptionMessage('Cannot normalize attribute "object" because the injected serializer is not a normalizer'); - $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock(); + $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); $this->normalizer->setSerializer($serializer); $obj = new ObjectDummy(); @@ -754,7 +754,7 @@ class ObjectNormalizerTest extends TestCase public function testThrowUnexpectedValueException() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $this->normalizer->denormalize(['foo' => 'bar'], ObjectTypeHinted::class); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php index 8c7a0ead2c..1a471b78af 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -71,7 +71,7 @@ class PropertyNormalizerTest extends TestCase private function createNormalizer(array $defaultContext = []) { - $this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock(); + $this->serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); $this->normalizer = new PropertyNormalizer(null, null, null, null, null, $defaultContext); $this->normalizer->setSerializer($this->serializer); } @@ -395,9 +395,9 @@ class PropertyNormalizerTest extends TestCase public function testUnableToNormalizeObjectAttribute() { - $this->expectException('Symfony\Component\Serializer\Exception\LogicException'); + $this->expectException(\Symfony\Component\Serializer\Exception\LogicException::class); $this->expectExceptionMessage('Cannot normalize attribute "bar" because the injected serializer is not a normalizer'); - $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock(); + $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); $this->normalizer->setSerializer($serializer); $obj = new PropertyDummy(); diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index cde5fc0665..8179b2b2eb 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -54,11 +54,11 @@ class SerializerTest extends TestCase { $serializer = new Serializer(); - $this->assertInstanceOf('Symfony\Component\Serializer\SerializerInterface', $serializer); - $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\NormalizerInterface', $serializer); - $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\DenormalizerInterface', $serializer); - $this->assertInstanceOf('Symfony\Component\Serializer\Encoder\EncoderInterface', $serializer); - $this->assertInstanceOf('Symfony\Component\Serializer\Encoder\DecoderInterface', $serializer); + $this->assertInstanceOf(\Symfony\Component\Serializer\SerializerInterface::class, $serializer); + $this->assertInstanceOf(NormalizerInterface::class, $serializer); + $this->assertInstanceOf(DenormalizerInterface::class, $serializer); + $this->assertInstanceOf(\Symfony\Component\Serializer\Encoder\EncoderInterface::class, $serializer); + $this->assertInstanceOf(\Symfony\Component\Serializer\Encoder\DecoderInterface::class, $serializer); } /** @@ -81,8 +81,8 @@ class SerializerTest extends TestCase public function testNormalizeNoMatch() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); - $serializer = new Serializer([$this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock()]); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); + $serializer = new Serializer([$this->getMockBuilder(CustomNormalizer::class)->getMock()]); $serializer->normalize(new \stdClass(), 'xml'); } @@ -102,21 +102,21 @@ class SerializerTest extends TestCase public function testNormalizeOnDenormalizer() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $serializer = new Serializer([new TestDenormalizer()], []); $this->assertTrue($serializer->normalize(new \stdClass(), 'json')); } public function testDenormalizeNoMatch() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); - $serializer = new Serializer([$this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock()]); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); + $serializer = new Serializer([$this->getMockBuilder(CustomNormalizer::class)->getMock()]); $serializer->denormalize('foo', 'stdClass'); } public function testDenormalizeOnNormalizer() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $serializer = new Serializer([new TestNormalizer()], []); $data = ['title' => 'foo', 'numbers' => [5, 3]]; $this->assertTrue($serializer->denormalize(json_encode($data), 'stdClass', 'json')); @@ -133,14 +133,14 @@ class SerializerTest extends TestCase public function testNormalizeWithSupportOnData() { - $normalizer1 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\NormalizerInterface')->getMock(); + $normalizer1 = $this->getMockBuilder(NormalizerInterface::class)->getMock(); $normalizer1->method('supportsNormalization') ->willReturnCallback(function ($data, $format) { return isset($data->test); }); $normalizer1->method('normalize')->willReturn('test1'); - $normalizer2 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\NormalizerInterface')->getMock(); + $normalizer2 = $this->getMockBuilder(NormalizerInterface::class)->getMock(); $normalizer2->method('supportsNormalization') ->willReturn(true); $normalizer2->method('normalize')->willReturn('test2'); @@ -156,14 +156,14 @@ class SerializerTest extends TestCase public function testDenormalizeWithSupportOnData() { - $denormalizer1 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\DenormalizerInterface')->getMock(); + $denormalizer1 = $this->getMockBuilder(DenormalizerInterface::class)->getMock(); $denormalizer1->method('supportsDenormalization') ->willReturnCallback(function ($data, $type, $format) { return isset($data['test1']); }); $denormalizer1->method('denormalize')->willReturn('test1'); - $denormalizer2 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\DenormalizerInterface')->getMock(); + $denormalizer2 = $this->getMockBuilder(DenormalizerInterface::class)->getMock(); $denormalizer2->method('supportsDenormalization') ->willReturn(true); $denormalizer2->method('denormalize')->willReturn('test2'); @@ -213,7 +213,7 @@ class SerializerTest extends TestCase public function testSerializeNoEncoder() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $serializer = new Serializer([], []); $data = ['title' => 'foo', 'numbers' => [5, 3]]; $serializer->serialize($data, 'json'); @@ -221,7 +221,7 @@ class SerializerTest extends TestCase public function testSerializeNoNormalizer() { - $this->expectException('Symfony\Component\Serializer\Exception\LogicException'); + $this->expectException(\Symfony\Component\Serializer\Exception\LogicException::class); $serializer = new Serializer([], ['json' => new JsonEncoder()]); $data = ['title' => 'foo', 'numbers' => [5, 3]]; $serializer->serialize(Model::fromArray($data), 'json'); @@ -247,7 +247,7 @@ class SerializerTest extends TestCase public function testDeserializeNoNormalizer() { - $this->expectException('Symfony\Component\Serializer\Exception\LogicException'); + $this->expectException(\Symfony\Component\Serializer\Exception\LogicException::class); $serializer = new Serializer([], ['json' => new JsonEncoder()]); $data = ['title' => 'foo', 'numbers' => [5, 3]]; $serializer->deserialize(json_encode($data), Model::class, 'json'); @@ -255,7 +255,7 @@ class SerializerTest extends TestCase public function testDeserializeWrongNormalizer() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $serializer = new Serializer([new CustomNormalizer()], ['json' => new JsonEncoder()]); $data = ['title' => 'foo', 'numbers' => [5, 3]]; $serializer->deserialize(json_encode($data), Model::class, 'json'); @@ -263,7 +263,7 @@ class SerializerTest extends TestCase public function testDeserializeNoEncoder() { - $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Serializer\Exception\UnexpectedValueException::class); $serializer = new Serializer([], []); $data = ['title' => 'foo', 'numbers' => [5, 3]]; $serializer->deserialize(json_encode($data), Model::class, 'json'); @@ -471,14 +471,14 @@ class SerializerTest extends TestCase public function testExceptionWhenTypeIsNotKnownInDiscriminator() { - $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Serializer\Exception\RuntimeException::class); $this->expectExceptionMessage('The type "second" has no mapped class for the abstract object "Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface"'); $this->serializerWithClassDiscriminator()->deserialize('{"type":"second","one":1}', DummyMessageInterface::class, 'json'); } public function testExceptionWhenTypeIsNotInTheBodyToDeserialiaze() { - $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Serializer\Exception\RuntimeException::class); $this->expectExceptionMessage('Type property "type" not found for the abstract object "Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface"'); $this->serializerWithClassDiscriminator()->deserialize('{"one":1}', DummyMessageInterface::class, 'json'); } diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php index 06808616e3..294fc70deb 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -122,7 +122,7 @@ class StopwatchEventTest extends TestCase public function testStopWithoutStart() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $event = new StopwatchEvent(microtime(true) * 1000); $event->stop(); } diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index 5dd0c3c2d8..a5bcb5d724 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php @@ -30,7 +30,7 @@ class StopwatchTest extends TestCase $stopwatch = new Stopwatch(); $event = $stopwatch->start('foo', 'cat'); - $this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event); + $this->assertInstanceOf(\Symfony\Component\Stopwatch\StopwatchEvent::class, $event); $this->assertEquals('cat', $event->getCategory()); $this->assertSame($event, $stopwatch->getEvent('foo')); } @@ -62,14 +62,14 @@ class StopwatchTest extends TestCase { $stopwatch = new Stopwatch(); - $sections = new \ReflectionProperty('Symfony\Component\Stopwatch\Stopwatch', 'sections'); + $sections = new \ReflectionProperty(Stopwatch::class, 'sections'); $sections->setAccessible(true); $section = $sections->getValue($stopwatch); - $events = new \ReflectionProperty('Symfony\Component\Stopwatch\Section', 'events'); + $events = new \ReflectionProperty(\Symfony\Component\Stopwatch\Section::class, 'events'); $events->setAccessible(true); - $stopwatchMockEvent = $this->getMockBuilder('Symfony\Component\Stopwatch\StopwatchEvent') + $stopwatchMockEvent = $this->getMockBuilder(\Symfony\Component\Stopwatch\StopwatchEvent::class) ->setConstructorArgs([microtime(true) * 1000]) ->getMock() ; @@ -86,20 +86,20 @@ class StopwatchTest extends TestCase usleep(200000); $event = $stopwatch->stop('foo'); - $this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event); + $this->assertInstanceOf(\Symfony\Component\Stopwatch\StopwatchEvent::class, $event); $this->assertEqualsWithDelta(200, $event->getDuration(), self::DELTA); } public function testUnknownEvent() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $stopwatch = new Stopwatch(); $stopwatch->getEvent('foo'); } public function testStopWithoutStart() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $stopwatch = new Stopwatch(); $stopwatch->stop('foo'); } @@ -163,7 +163,7 @@ class StopwatchTest extends TestCase public function testReopenANewSectionShouldThrowAnException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $stopwatch = new Stopwatch(); $stopwatch->openSection('section'); } diff --git a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php index 862b0f04d4..c590d8557d 100644 --- a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php @@ -36,7 +36,7 @@ class DelegatingEngineTest extends TestCase public function testRenderWithNoSupportedEngine() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('No engine is able to work with the template "template.php"'); $firstEngine = $this->getEngineMock('template.php', false); $secondEngine = $this->getEngineMock('template.php', false); @@ -61,7 +61,7 @@ class DelegatingEngineTest extends TestCase public function testStreamRequiresStreamingEngine() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Template "template.php" cannot be streamed as the engine supporting it does not implement StreamingEngineInterface'); $delegatingEngine = new DelegatingEngine([new TestEngine()]); $delegatingEngine->stream('template.php', ['foo' => 'bar']); @@ -110,7 +110,7 @@ class DelegatingEngineTest extends TestCase public function testGetInvalidEngine() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('No engine is able to work with the template "template.php"'); $firstEngine = $this->getEngineMock('template.php', false); $secondEngine = $this->getEngineMock('template.php', false); @@ -121,7 +121,7 @@ class DelegatingEngineTest extends TestCase private function getEngineMock($template, $supports) { - $engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock(); + $engine = $this->getMockBuilder(EngineInterface::class)->getMock(); $engine->expects($this->once()) ->method('supports') @@ -133,7 +133,7 @@ class DelegatingEngineTest extends TestCase private function getStreamingEngineMock($template, $supports) { - $engine = $this->getMockForAbstractClass('Symfony\Component\Templating\Tests\MyStreamingEngine'); + $engine = $this->getMockForAbstractClass(\Symfony\Component\Templating\Tests\MyStreamingEngine::class); $engine->expects($this->once()) ->method('supports') diff --git a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php index 651c8e3b63..d15b9549b0 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php @@ -35,7 +35,7 @@ class CacheLoaderTest extends TestCase $loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir); $this->assertFalse($loader->load(new TemplateReference('foo', 'php')), '->load() returns false if the embed loader is not able to load the template'); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger ->expects($this->once()) ->method('debug') @@ -43,7 +43,7 @@ class CacheLoaderTest extends TestCase $loader->setLogger($logger); $loader->load(new TemplateReference('index')); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger ->expects($this->once()) ->method('debug') diff --git a/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php index 213468d4f9..bb63c12fb2 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/FilesystemLoaderTest.php @@ -49,16 +49,16 @@ class FilesystemLoaderTest extends TestCase $path = self::$fixturesPath.'/templates'; $loader = new ProjectTemplateLoader2($pathPattern); $storage = $loader->load(new TemplateReference($path.'/foo.php', 'php')); - $this->assertInstanceOf('Symfony\Component\Templating\Storage\FileStorage', $storage, '->load() returns a FileStorage if you pass an absolute path'); + $this->assertInstanceOf(\Symfony\Component\Templating\Storage\FileStorage::class, $storage, '->load() returns a FileStorage if you pass an absolute path'); $this->assertEquals($path.'/foo.php', (string) $storage, '->load() returns a FileStorage pointing to the passed absolute path'); $this->assertFalse($loader->load(new TemplateReference('bar', 'php')), '->load() returns false if the template is not found'); $storage = $loader->load(new TemplateReference('foo.php', 'php')); - $this->assertInstanceOf('Symfony\Component\Templating\Storage\FileStorage', $storage, '->load() returns a FileStorage if you pass a relative template that exists'); + $this->assertInstanceOf(\Symfony\Component\Templating\Storage\FileStorage::class, $storage, '->load() returns a FileStorage if you pass a relative template that exists'); $this->assertEquals($path.'/foo.php', (string) $storage, '->load() returns a FileStorage pointing to the absolute path of the template'); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger->expects($this->exactly(2))->method('debug'); $loader = new ProjectTemplateLoader2($pathPattern); diff --git a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php index 166629b36c..d31dba8725 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php @@ -20,7 +20,7 @@ class LoaderTest extends TestCase public function testGetSetLogger() { $loader = new ProjectTemplateLoader4(); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $loader->setLogger($logger); $this->assertSame($logger, $loader->getLogger(), '->setLogger() sets the logger instance'); } diff --git a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php index 0de88516a6..79be3c740b 100644 --- a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php @@ -129,7 +129,7 @@ class PhpEngineTest extends TestCase */ public function testRenderForbiddenParameter($name) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $engine = new ProjectTemplateEngine(new TemplateNameParser(), $this->loader); $this->loader->setTemplate('foo.php', 'bar'); $engine->render('foo.php', [$name => 'foo']); diff --git a/src/Symfony/Component/Templating/Tests/Storage/FileStorageTest.php b/src/Symfony/Component/Templating/Tests/Storage/FileStorageTest.php index ed3ca51d9d..2a0e73c195 100644 --- a/src/Symfony/Component/Templating/Tests/Storage/FileStorageTest.php +++ b/src/Symfony/Component/Templating/Tests/Storage/FileStorageTest.php @@ -19,7 +19,7 @@ class FileStorageTest extends TestCase public function testGetContent() { $storage = new FileStorage('foo'); - $this->assertInstanceOf('Symfony\Component\Templating\Storage\Storage', $storage, 'FileStorage is an instance of Storage'); + $this->assertInstanceOf(\Symfony\Component\Templating\Storage\Storage::class, $storage, 'FileStorage is an instance of Storage'); $storage = new FileStorage(__DIR__.'/../Fixtures/templates/foo.php'); $this->assertEquals(''."\n", $storage->getContent(), '->getContent() returns the content of the template'); } diff --git a/src/Symfony/Component/Templating/Tests/Storage/StringStorageTest.php b/src/Symfony/Component/Templating/Tests/Storage/StringStorageTest.php index ecfeb800c8..7b32542e18 100644 --- a/src/Symfony/Component/Templating/Tests/Storage/StringStorageTest.php +++ b/src/Symfony/Component/Templating/Tests/Storage/StringStorageTest.php @@ -19,7 +19,7 @@ class StringStorageTest extends TestCase public function testGetContent() { $storage = new StringStorage('foo'); - $this->assertInstanceOf('Symfony\Component\Templating\Storage\Storage', $storage, 'StringStorage is an instance of Storage'); + $this->assertInstanceOf(\Symfony\Component\Templating\Storage\Storage::class, $storage, 'StringStorage is an instance of Storage'); $storage = new StringStorage('foo'); $this->assertEquals('foo', $storage->getContent(), '->getContent() returns the content of the template'); } diff --git a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php index d6e4af8fb6..520ae33400 100644 --- a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php @@ -35,7 +35,7 @@ class YamlFileDumper extends FileDumper */ public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) { - if (!class_exists('Symfony\Component\Yaml\Yaml')) { + if (!class_exists(Yaml::class)) { throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.'); } diff --git a/src/Symfony/Component/Translation/Loader/FileLoader.php b/src/Symfony/Component/Translation/Loader/FileLoader.php index 7ec54a3c87..42c687d22f 100644 --- a/src/Symfony/Component/Translation/Loader/FileLoader.php +++ b/src/Symfony/Component/Translation/Loader/FileLoader.php @@ -47,7 +47,7 @@ abstract class FileLoader extends ArrayLoader $catalogue = parent::load($messages, $locale, $domain); - if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + if (class_exists(FileResource::class)) { $catalogue->addResource(new FileResource($resource)); } diff --git a/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php b/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php index 545c2b02b8..dfdabc9d4f 100644 --- a/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IcuDatFileLoader.php @@ -52,7 +52,7 @@ class IcuDatFileLoader extends IcuResFileLoader $catalogue = new MessageCatalogue($locale); $catalogue->add($messages, $domain); - if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + if (class_exists(FileResource::class)) { $catalogue->addResource(new FileResource($resource.'.dat')); } diff --git a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php index 6dddf63f2c..126556fee0 100644 --- a/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php @@ -52,7 +52,7 @@ class IcuResFileLoader implements LoaderInterface $catalogue = new MessageCatalogue($locale); $catalogue->add($messages, $domain); - if (class_exists('Symfony\Component\Config\Resource\DirectoryResource')) { + if (class_exists(DirectoryResource::class)) { $catalogue->addResource(new DirectoryResource($resource)); } diff --git a/src/Symfony/Component/Translation/Loader/QtFileLoader.php b/src/Symfony/Component/Translation/Loader/QtFileLoader.php index 2d4a4c084f..29567789e7 100644 --- a/src/Symfony/Component/Translation/Loader/QtFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/QtFileLoader.php @@ -65,7 +65,7 @@ class QtFileLoader implements LoaderInterface $translation = $translation->nextSibling; } - if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + if (class_exists(FileResource::class)) { $catalogue->addResource(new FileResource($resource)); } } diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index 35fcc1ec4a..11a721f455 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -41,7 +41,7 @@ class XliffFileLoader implements LoaderInterface $catalogue = new MessageCatalogue($locale); $this->extract($resource, $catalogue, $domain); - if (class_exists('Symfony\Component\Config\Resource\FileResource')) { + if (class_exists(FileResource::class)) { $catalogue->addResource(new FileResource($resource)); } diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index e4bee0cfbf..b03c7b77d0 100644 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -32,7 +32,7 @@ class YamlFileLoader extends FileLoader protected function loadResource($resource) { if (null === $this->yamlParser) { - if (!class_exists('Symfony\Component\Yaml\Parser')) { + if (!class_exists(\Symfony\Component\Yaml\Parser::class)) { throw new LogicException('Loading translations from the YAML format requires the Symfony Yaml component.'); } diff --git a/src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php b/src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php index f82b18fdd7..30fc1171ed 100644 --- a/src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php +++ b/src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php @@ -41,7 +41,7 @@ abstract class AbstractOperationTest extends TestCase public function testGetMessagesFromUnknownDomain() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->createOperation( new MessageCatalogue('en'), new MessageCatalogue('en') diff --git a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php index 272ee15adc..4a3351f6ec 100644 --- a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php +++ b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php @@ -107,7 +107,7 @@ class XliffLintCommandTest extends TestCase public function testLintFileNotReadable() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $tester = $this->createCommandTester(); $filename = $this->createFile(); unlink($filename); diff --git a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php index 1a600c8c6b..e1c5f67f0a 100644 --- a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php +++ b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php @@ -19,7 +19,7 @@ class TranslationDataCollectorTest extends TestCase { protected function setUp(): void { - if (!class_exists('Symfony\Component\HttpKernel\DataCollector\DataCollector')) { + if (!class_exists(\Symfony\Component\HttpKernel\DataCollector\DataCollector::class)) { $this->markTestSkipped('The "DataCollector" is not available'); } } @@ -140,7 +140,7 @@ class TranslationDataCollectorTest extends TestCase private function getTranslator() { $translator = $this - ->getMockBuilder('Symfony\Component\Translation\DataCollectorTranslator') + ->getMockBuilder(DataCollectorTranslator::class) ->disableOriginalConstructor() ->getMock() ; diff --git a/src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationExtractorPassTest.php b/src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationExtractorPassTest.php index 113536bca8..6364b9bcaf 100644 --- a/src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationExtractorPassTest.php +++ b/src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationExtractorPassTest.php @@ -48,7 +48,7 @@ class TranslationExtractorPassTest extends TestCase public function testProcessMissingAlias() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('The alias for the tag "translation.extractor" of service "foo.id" must be set.'); $container = new ContainerBuilder(); $container->register('translation.extractor'); diff --git a/src/Symfony/Component/Translation/Tests/IntervalTest.php b/src/Symfony/Component/Translation/Tests/IntervalTest.php index ea3e4d8d59..61b88dbb02 100644 --- a/src/Symfony/Component/Translation/Tests/IntervalTest.php +++ b/src/Symfony/Component/Translation/Tests/IntervalTest.php @@ -29,7 +29,7 @@ class IntervalTest extends TestCase public function testTestException() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); Interval::test(1, 'foobar'); } diff --git a/src/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php index 9537e1f1c4..44cba5f340 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php @@ -41,7 +41,7 @@ class CsvFileLoaderTest extends TestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new CsvFileLoader(); $resource = __DIR__.'/../fixtures/not-exists.csv'; $loader->load($resource, 'en', 'domain1'); @@ -49,7 +49,7 @@ class CsvFileLoaderTest extends TestCase public function testLoadNonLocalResource() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new CsvFileLoader(); $resource = 'http://example.com/resources.csv'; $loader->load($resource, 'en', 'domain1'); diff --git a/src/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php index 77db041f5d..fe107210d5 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php @@ -21,7 +21,7 @@ class IcuDatFileLoaderTest extends LocalizedTestCase { public function testLoadInvalidResource() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new IcuDatFileLoader(); $loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted/resources', 'es', 'domain2'); } @@ -53,7 +53,7 @@ class IcuDatFileLoaderTest extends LocalizedTestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new IcuDatFileLoader(); $loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1'); } diff --git a/src/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php index 99b2f90421..c334652232 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php @@ -33,14 +33,14 @@ class IcuResFileLoaderTest extends LocalizedTestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new IcuResFileLoader(); $loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1'); } public function testLoadInvalidResource() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new IcuResFileLoader(); $loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted', 'en', 'domain1'); } diff --git a/src/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php index fd66e2015a..3330e7e372 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php @@ -41,7 +41,7 @@ class IniFileLoaderTest extends TestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new IniFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.ini'; $loader->load($resource, 'en', 'domain1'); diff --git a/src/Symfony/Component/Translation/Tests/Loader/JsonFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/JsonFileLoaderTest.php index c5a9ca64d4..c3ef1f7628 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/JsonFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/JsonFileLoaderTest.php @@ -41,7 +41,7 @@ class JsonFileLoaderTest extends TestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new JsonFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.json'; $loader->load($resource, 'en', 'domain1'); @@ -49,7 +49,7 @@ class JsonFileLoaderTest extends TestCase public function testParseException() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $this->expectExceptionMessage('Error parsing JSON: Syntax error, malformed JSON'); $loader = new JsonFileLoader(); $resource = __DIR__.'/../fixtures/malformed.json'; diff --git a/src/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php index 3fe3a9925b..8da81ba8c7 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php @@ -44,7 +44,7 @@ class MoFileLoaderTest extends TestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new MoFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.mo'; $loader->load($resource, 'en', 'domain1'); @@ -52,7 +52,7 @@ class MoFileLoaderTest extends TestCase public function testLoadInvalidResource() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new MoFileLoader(); $resource = __DIR__.'/../fixtures/empty.mo'; $loader->load($resource, 'en', 'domain1'); diff --git a/src/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php index d4da6452f6..1b2c9fac06 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php @@ -30,7 +30,7 @@ class PhpFileLoaderTest extends TestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new PhpFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.php'; $loader->load($resource, 'en', 'domain1'); @@ -38,7 +38,7 @@ class PhpFileLoaderTest extends TestCase public function testLoadThrowsAnExceptionIfFileNotLocal() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new PhpFileLoader(); $resource = 'http://example.com/resources.php'; $loader->load($resource, 'en', 'domain1'); diff --git a/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php index 72c4c66723..04c084eac5 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php @@ -55,7 +55,7 @@ class PoFileLoaderTest extends TestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new PoFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.po'; $loader->load($resource, 'en', 'domain1'); diff --git a/src/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php index 95981c7fe8..0d2817b39c 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php @@ -34,7 +34,7 @@ class QtFileLoaderTest extends TestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new QtFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.ts'; $loader->load($resource, 'en', 'domain1'); @@ -42,7 +42,7 @@ class QtFileLoaderTest extends TestCase public function testLoadNonLocalResource() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new QtFileLoader(); $resource = 'http://domain1.com/resources.ts'; $loader->load($resource, 'en', 'domain1'); @@ -50,7 +50,7 @@ class QtFileLoaderTest extends TestCase public function testLoadInvalidResource() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new QtFileLoader(); $resource = __DIR__.'/../fixtures/invalid-xml-resources.xlf'; $loader->load($resource, 'en', 'domain1'); @@ -61,7 +61,7 @@ class QtFileLoaderTest extends TestCase $loader = new QtFileLoader(); $resource = __DIR__.'/../fixtures/empty.xlf'; - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $this->expectExceptionMessage(sprintf('Unable to load "%s".', $resource)); $loader->load($resource, 'en', 'domain1'); diff --git a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php index 1ae24711e9..4592bc872a 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php @@ -112,21 +112,21 @@ class XliffFileLoaderTest extends TestCase public function testLoadInvalidResource() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new XliffFileLoader(); $loader->load(__DIR__.'/../fixtures/resources.php', 'en', 'domain1'); } public function testLoadResourceDoesNotValidate() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new XliffFileLoader(); $loader->load(__DIR__.'/../fixtures/non-valid.xlf', 'en', 'domain1'); } public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new XliffFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.xlf'; $loader->load($resource, 'en', 'domain1'); @@ -134,7 +134,7 @@ class XliffFileLoaderTest extends TestCase public function testLoadThrowsAnExceptionIfFileNotLocal() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new XliffFileLoader(); $resource = 'http://example.com/resources.xlf'; $loader->load($resource, 'en', 'domain1'); @@ -142,7 +142,7 @@ class XliffFileLoaderTest extends TestCase public function testDocTypeIsNotAllowed() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $this->expectExceptionMessage('Document types are not allowed.'); $loader = new XliffFileLoader(); $loader->load(__DIR__.'/../fixtures/withdoctype.xlf', 'en', 'domain1'); @@ -153,7 +153,7 @@ class XliffFileLoaderTest extends TestCase $loader = new XliffFileLoader(); $resource = __DIR__.'/../fixtures/empty.xlf'; - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $this->expectExceptionMessage(sprintf('Unable to load "%s":', $resource)); $loader->load($resource, 'en', 'domain1'); diff --git a/src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php index b46fff7470..f1e6f4aece 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php @@ -41,7 +41,7 @@ class YamlFileLoaderTest extends TestCase public function testLoadNonExistingResource() { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loader = new YamlFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.yml'; $loader->load($resource, 'en', 'domain1'); @@ -49,7 +49,7 @@ class YamlFileLoaderTest extends TestCase public function testLoadThrowsAnExceptionIfFileNotLocal() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new YamlFileLoader(); $resource = 'http://example.com/resources.yml'; $loader->load($resource, 'en', 'domain1'); @@ -57,7 +57,7 @@ class YamlFileLoaderTest extends TestCase public function testLoadThrowsAnExceptionIfNotAnArray() { - $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); $loader = new YamlFileLoader(); $resource = __DIR__.'/../fixtures/non-valid.yml'; $loader->load($resource, 'en', 'domain1'); diff --git a/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php b/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php index 450e060aab..668fb9d7e8 100644 --- a/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php @@ -20,7 +20,7 @@ class LoggingTranslatorTest extends TestCase { public function testTransWithNoTranslationIsLogged() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger->expects($this->exactly(1)) ->method('warning') ->with('Translation not found.') @@ -36,7 +36,7 @@ class LoggingTranslatorTest extends TestCase */ public function testTransChoiceFallbackIsLogged() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger->expects($this->once()) ->method('debug') ->with('Translation use fallback catalogue.') @@ -55,7 +55,7 @@ class LoggingTranslatorTest extends TestCase */ public function testTransChoiceWithNoTranslationIsLogged() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger->expects($this->exactly(1)) ->method('warning') ->with('Translation not found.') diff --git a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php index b4e3149c7c..31d550406d 100644 --- a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php @@ -137,10 +137,10 @@ class MessageCatalogueTest extends TestCase public function testAddCatalogue() { - $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); + $r = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); $r->expects($this->any())->method('__toString')->willReturn('r'); - $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); + $r1 = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); $r1->expects($this->any())->method('__toString')->willReturn('r1'); $catalogue = new MessageCatalogue('en', ['domain1' => ['foo' => 'foo']]); @@ -161,13 +161,13 @@ class MessageCatalogueTest extends TestCase public function testAddFallbackCatalogue() { - $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); + $r = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); $r->expects($this->any())->method('__toString')->willReturn('r'); - $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); + $r1 = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); $r1->expects($this->any())->method('__toString')->willReturn('r1'); - $r2 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); + $r2 = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); $r2->expects($this->any())->method('__toString')->willReturn('r2'); $catalogue = new MessageCatalogue('fr_FR', ['domain1' => ['foo' => 'foo'], 'domain2' => ['bar' => 'bar']]); @@ -190,7 +190,7 @@ class MessageCatalogueTest extends TestCase public function testAddFallbackCatalogueWithParentCircularReference() { - $this->expectException('Symfony\Component\Translation\Exception\LogicException'); + $this->expectException(\Symfony\Component\Translation\Exception\LogicException::class); $main = new MessageCatalogue('en_US'); $fallback = new MessageCatalogue('fr_FR'); @@ -200,7 +200,7 @@ class MessageCatalogueTest extends TestCase public function testAddFallbackCatalogueWithFallbackCircularReference() { - $this->expectException('Symfony\Component\Translation\Exception\LogicException'); + $this->expectException(\Symfony\Component\Translation\Exception\LogicException::class); $fr = new MessageCatalogue('fr'); $en = new MessageCatalogue('en'); $es = new MessageCatalogue('es'); @@ -212,7 +212,7 @@ class MessageCatalogueTest extends TestCase public function testAddCatalogueWhenLocaleIsNotTheSameAsTheCurrentOne() { - $this->expectException('Symfony\Component\Translation\Exception\LogicException'); + $this->expectException(\Symfony\Component\Translation\Exception\LogicException::class); $catalogue = new MessageCatalogue('en'); $catalogue->addCatalogue(new MessageCatalogue('fr', [])); } @@ -220,11 +220,11 @@ class MessageCatalogueTest extends TestCase public function testGetAddResource() { $catalogue = new MessageCatalogue('en'); - $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); + $r = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); $r->expects($this->any())->method('__toString')->willReturn('r'); $catalogue->addResource($r); $catalogue->addResource($r); - $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); + $r1 = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); $r1->expects($this->any())->method('__toString')->willReturn('r1'); $catalogue->addResource($r1); diff --git a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php index 20609dddae..1e67878e1f 100644 --- a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php @@ -41,7 +41,7 @@ class MessageSelectorTest extends TestCase */ public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number) { - $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); $selector = new MessageSelector(); $selector->choose($id, $number, 'en'); diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index 8efa318cac..a523b2bbae 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -101,7 +101,7 @@ class TranslatorCacheTest extends TestCase $catalogue->addResource(new StaleResource()); // better use a helper class than a mock, because it gets serialized in the cache and re-loaded /** @var LoaderInterface|MockObject $loader */ - $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); $loader ->expects($this->exactly(2)) ->method('load') @@ -248,8 +248,8 @@ class TranslatorCacheTest extends TestCase public function testRefreshCacheWhenResourcesAreNoLongerFresh() { - $resource = $this->getMockBuilder('Symfony\Component\Config\Resource\SelfCheckingResourceInterface')->getMock(); - $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); + $resource = $this->getMockBuilder(SelfCheckingResourceInterface::class)->getMock(); + $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); $resource->method('isFresh')->willReturn(false); $loader ->expects($this->exactly(2)) @@ -305,7 +305,7 @@ class TranslatorCacheTest extends TestCase private function createFailingLoader(): LoaderInterface { - $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); $loader ->expects($this->never()) ->method('load'); diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index 6df6d71564..a647ea5379 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -37,7 +37,7 @@ class TranslatorTest extends TestCase */ public function testConstructorInvalidLocale($locale) { - $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); new Translator($locale); } @@ -76,7 +76,7 @@ class TranslatorTest extends TestCase */ public function testSetInvalidLocale($locale) { - $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); $translator = new Translator('fr'); $translator->setLocale($locale); } @@ -170,7 +170,7 @@ class TranslatorTest extends TestCase */ public function testSetFallbackInvalidLocales($locale) { - $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); $translator = new Translator('fr'); $translator->setFallbackLocales(['fr', $locale]); } @@ -213,7 +213,7 @@ class TranslatorTest extends TestCase */ public function testAddResourceInvalidLocales($locale) { - $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); $translator = new Translator('fr'); $translator->addResource('array', ['foo' => 'foofoo'], $locale); } @@ -258,7 +258,7 @@ class TranslatorTest extends TestCase */ public function testTransWithoutFallbackLocaleFile($format, $loader) { - $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); + $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); $loaderClass = 'Symfony\\Component\\Translation\\Loader\\'.$loader; $translator = new Translator('en'); $translator->addLoader($format, new $loaderClass()); @@ -374,7 +374,7 @@ class TranslatorTest extends TestCase public function testWhenAResourceHasNoRegisteredLoader() { - $this->expectException('Symfony\Component\Translation\Exception\RuntimeException'); + $this->expectException(RuntimeException::class); $translator = new Translator('en'); $translator->addResource('array', ['foo' => 'foofoo'], 'en'); @@ -428,7 +428,7 @@ class TranslatorTest extends TestCase */ public function testTransInvalidLocale($locale) { - $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); $translator = new Translator('en'); $translator->addLoader('array', new ArrayLoader()); $translator->addResource('array', ['foo' => 'foofoo'], 'en'); @@ -491,7 +491,7 @@ class TranslatorTest extends TestCase */ public function testTransChoiceInvalidLocale($locale) { - $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); $translator = new Translator('en'); $translator->addLoader('array', new ArrayLoader()); $translator->addResource('array', ['foo' => 'foofoo'], 'en'); diff --git a/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php index d3b6754d33..9567f71db8 100644 --- a/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php +++ b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php @@ -20,7 +20,7 @@ class TranslationWriterTest extends TestCase { public function testWrite() { - $dumper = $this->getMockBuilder('Symfony\Component\Translation\Dumper\DumperInterface')->getMock(); + $dumper = $this->getMockBuilder(DumperInterface::class)->getMock(); $dumper ->expects($this->once()) ->method('dump'); diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index 1045ed0ea5..f51172a8ac 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -87,7 +87,7 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface protected function formatValue($value, $format = 0) { if (($format & self::PRETTY_DATE) && $value instanceof \DateTimeInterface) { - if (class_exists('IntlDateFormatter')) { + if (class_exists(\IntlDateFormatter::class)) { $formatter = new \IntlDateFormatter(\Locale::getDefault(), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT, 'UTC'); return $formatter->format(new \DateTime( diff --git a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php index 3a6f5e4dd5..be0613ce2c 100644 --- a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php @@ -68,7 +68,7 @@ class ExpressionValidator extends ConstraintValidator private function getExpressionLanguage(): ExpressionLanguage { if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { + if (!class_exists(ExpressionLanguage::class)) { throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } $this->expressionLanguage = new ExpressionLanguage(); diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index 040e40d660..d46cb26cec 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -107,7 +107,7 @@ abstract class ConstraintValidatorTestCase extends TestCase { $translator = $this->getMockBuilder(TranslatorInterface::class)->getMock(); $translator->expects($this->any())->method('trans')->willReturnArgument(0); - $validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); + $validator = $this->getMockBuilder(\Symfony\Component\Validator\Validator\ValidatorInterface::class)->getMock(); $context = new ExecutionContext($validator, $this->root, $translator); $context->setGroup($this->group); diff --git a/src/Symfony/Component/Validator/Tests/ConstraintTest.php b/src/Symfony/Component/Validator/Tests/ConstraintTest.php index 26cc460d39..23466dd4ff 100644 --- a/src/Symfony/Component/Validator/Tests/ConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/ConstraintTest.php @@ -38,7 +38,7 @@ class ConstraintTest extends TestCase public function testSetNotExistingPropertyThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); new ConstraintA([ 'foo' => 'bar', @@ -49,14 +49,14 @@ class ConstraintTest extends TestCase { $constraint = new ConstraintA(); - $this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $constraint->foo = 'bar'; } public function testInvalidAndRequiredOptionsPassed() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); new ConstraintC([ 'option1' => 'default', @@ -104,14 +104,14 @@ class ConstraintTest extends TestCase public function testSetUndefinedDefaultProperty() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new ConstraintB('foo'); } public function testRequiredOptionsMustBeDefined() { - $this->expectException('Symfony\Component\Validator\Exception\MissingOptionsException'); + $this->expectException(\Symfony\Component\Validator\Exception\MissingOptionsException::class); new ConstraintC(); } @@ -209,7 +209,7 @@ class ConstraintTest extends TestCase public function testGetErrorNameForUnknownCode() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); Constraint::getErrorName(1); } @@ -226,7 +226,7 @@ class ConstraintTest extends TestCase public function testInvalidOptions() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException'); + $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage('The options "0", "5" do not exist in constraint "Symfony\Component\Validator\Tests\Fixtures\ConstraintA".'); new ConstraintA(['property2' => 'foo', 'bar', 5 => 'baz']); } @@ -244,7 +244,7 @@ class ConstraintTest extends TestCase public function testAnnotationSetUndefinedDefaultOption() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('No default option is configured for constraint "Symfony\Component\Validator\Tests\Fixtures\ConstraintB".'); new ConstraintB(['value' => 1]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index 6a0e738ee0..483e2c1310 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -82,14 +82,14 @@ abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTe */ public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options) { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(ConstraintDefinitionException::class); $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.'); $this->createConstraint($options); } public function testThrowsConstraintExceptionIfBothValueAndPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.'); $this->createConstraint(([ 'value' => 'value', diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php index 5893298711..78e5b60103 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php @@ -22,7 +22,7 @@ class AllTest extends TestCase { public function testRejectNonConstraints() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new All([ 'foo', ]); @@ -30,7 +30,7 @@ class AllTest extends TestCase public function testRejectValidConstraint() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new All([ new Valid(), ]); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php index 6c10a4e4ec..fb7fd281bb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php @@ -33,7 +33,7 @@ class AllValidatorTest extends ConstraintValidatorTestCase public function testThrowsExceptionIfNotTraversable() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate('foo.barbar', new All(new Range(['min' => 4]))); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php index b07f6f9f83..e1cf94c175 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php @@ -105,7 +105,7 @@ class BicValidatorTest extends ConstraintValidatorTestCase public function testThrowsConstraintExceptionIfBothValueAndPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(ConstraintDefinitionException::class); $this->expectExceptionMessage('The "iban" and "ibanPropertyPath" options of the Iban constraint cannot be used at the same time'); new Bic([ 'iban' => 'value', @@ -129,7 +129,7 @@ class BicValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Bic()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php index 4e712b92ad..627da6702e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php @@ -182,7 +182,7 @@ class CallbackValidatorTest extends ConstraintValidatorTestCase public function testExpectValidMethods() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $object = new CallbackValidatorTest_Object(); $this->validator->validate($object, new Callback(['callback' => ['foobar']])); @@ -190,7 +190,7 @@ class CallbackValidatorTest extends ConstraintValidatorTestCase public function testExpectValidCallbacks() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $object = new CallbackValidatorTest_Object(); $this->validator->validate($object, new Callback(['callback' => ['foo', 'bar']])); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index c9fb882db3..c5ea94984d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -39,7 +39,7 @@ class ChoiceValidatorTest extends ConstraintValidatorTestCase public function testExpectArrayIfMultipleIsTrue() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $constraint = new Choice([ 'choices' => ['foo', 'bar'], 'multiple' => true, @@ -62,13 +62,13 @@ class ChoiceValidatorTest extends ConstraintValidatorTestCase public function testChoicesOrCallbackExpected() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->validator->validate('foobar', new Choice()); } public function testValidCallbackExpected() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->validator->validate('foobar', new Choice(['callback' => 'abcd'])); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php index 254154dae7..8a1c73e1f6 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php @@ -25,7 +25,7 @@ class CollectionTest extends TestCase { public function testRejectInvalidFieldsOption() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new Collection([ 'fields' => 'foo', ]); @@ -33,7 +33,7 @@ class CollectionTest extends TestCase public function testRejectNonConstraints() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new Collection([ 'foo' => 'bar', ]); @@ -41,7 +41,7 @@ class CollectionTest extends TestCase public function testRejectValidConstraint() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new Collection([ 'foo' => new Valid(), ]); @@ -49,7 +49,7 @@ class CollectionTest extends TestCase public function testRejectValidConstraintWithinOptional() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new Collection([ 'foo' => new Optional(new Valid()), ]); @@ -57,7 +57,7 @@ class CollectionTest extends TestCase public function testRejectValidConstraintWithinRequired() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new Collection([ 'foo' => new Required(new Valid()), ]); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php index 3b3ee04509..effac4156c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php @@ -54,7 +54,7 @@ abstract class CollectionValidatorTest extends ConstraintValidatorTestCase public function testThrowsExceptionIfNotTraversable() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate('foobar', new Collection(['fields' => [ 'foo' => new Range(['min' => 4]), ]])); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php index 82c224ff4d..69466d3d53 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php @@ -105,7 +105,7 @@ class CompositeTest extends TestCase public function testFailIfExplicitNestedGroupsNotSubsetOfExplicitParentGroups() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new ConcreteComposite([ 'constraints' => [ new NotNull(['groups' => ['Default', 'Foobar']]), @@ -138,7 +138,7 @@ class CompositeTest extends TestCase public function testFailIfNoConstraint() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new ConcreteComposite([ new NotNull(['groups' => 'Default']), 'NotBlank', @@ -147,7 +147,7 @@ class CompositeTest extends TestCase public function testFailIfNoConstraintObject() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new ConcreteComposite([ new NotNull(['groups' => 'Default']), new \ArrayObject(), @@ -156,7 +156,7 @@ class CompositeTest extends TestCase public function testValidCantBeNested() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new ConcreteComposite([ new Valid(), ]); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php index 664b96b2d2..74738b32c8 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php @@ -36,7 +36,7 @@ abstract class CountValidatorTest extends ConstraintValidatorTestCase public function testExpectsCountableType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Count(5)); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 4f8ad86c5c..f2b07bc594 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -55,7 +55,7 @@ class CountryValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Country()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index 08aef0010d..997eaff22e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -55,7 +55,7 @@ class CurrencyValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Currency()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php index 97ee2f9a52..0f736a7abb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -60,7 +60,7 @@ class DateTimeValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new DateTime()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php index dd8f3f104d..64fec4bb67 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -60,7 +60,7 @@ class DateValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Date()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php index cdf087b108..e80b3d8b94 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php @@ -36,7 +36,7 @@ class EmailTest extends TestCase public function testUnknownModesTriggerException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "mode" parameter value is not valid.'); new Email(['mode' => 'Unknown Mode']); } @@ -50,14 +50,14 @@ class EmailTest extends TestCase public function testInvalidNormalizerThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).'); new Email(['normalizer' => 'Unknown Callable']); } public function testInvalidNormalizerObjectThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).'); new Email(['normalizer' => new \stdClass()]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 08a3c4ee76..c27a902035 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -41,7 +41,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase public function testUnknownDefaultModeTriggerException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "defaultMode" parameter value is not valid.'); new EmailValidator('Unknown Mode'); } @@ -69,7 +69,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Email()); } @@ -238,7 +238,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase public function testUnknownModesOnValidateTriggerException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The "Symfony\Component\Validator\Constraints\Email::$mode" parameter value is not valid.'); $constraint = new Email(); $constraint->mode = 'Unknown Mode'; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index c5b2ebee07..900d0743de 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -283,7 +283,7 @@ class ExpressionValidatorTest extends ConstraintValidatorTestCase 'expression' => 'false', ]); - $expressionLanguage = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ExpressionLanguage')->getMock(); + $expressionLanguage = $this->getMockBuilder(ExpressionLanguage::class)->getMock(); $used = false; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php index dfeeeb774e..45b5ee6342 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php @@ -55,7 +55,7 @@ class FileTest extends TestCase */ public function testInvalidValueForMaxSizeThrowsExceptionAfterInitialization($maxSize) { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(ConstraintDefinitionException::class); $file = new File(['maxSize' => 1000]); $file->maxSize = $maxSize; } @@ -80,7 +80,7 @@ class FileTest extends TestCase */ public function testInvalidMaxSize($maxSize) { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(ConstraintDefinitionException::class); new File(['maxSize' => $maxSize]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index a61e212e01..405fd3ab8d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -68,7 +68,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleTypeOrFile() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new File()); } @@ -224,7 +224,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase public function testInvalidMaxSize() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new File([ 'maxSize' => '1abc', ]); @@ -284,7 +284,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase public function testValidMimeType() { $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') + ->getMockBuilder(\Symfony\Component\HttpFoundation\File\File::class) ->setConstructorArgs([__DIR__.'/Fixtures/foo']) ->getMock(); $file @@ -308,7 +308,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase public function testValidWildcardMimeType() { $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') + ->getMockBuilder(\Symfony\Component\HttpFoundation\File\File::class) ->setConstructorArgs([__DIR__.'/Fixtures/foo']) ->getMock(); $file @@ -332,7 +332,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase public function testInvalidMimeType() { $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') + ->getMockBuilder(\Symfony\Component\HttpFoundation\File\File::class) ->setConstructorArgs([__DIR__.'/Fixtures/foo']) ->getMock(); $file @@ -363,7 +363,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase public function testInvalidWildcardMimeType() { $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') + ->getMockBuilder(\Symfony\Component\HttpFoundation\File\File::class) ->setConstructorArgs([__DIR__.'/Fixtures/foo']) ->getMock(); $file @@ -439,7 +439,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase [(string) \UPLOAD_ERR_EXTENSION, 'uploadExtensionErrorMessage'], ]; - if (class_exists('Symfony\Component\HttpFoundation\File\UploadedFile')) { + if (class_exists(UploadedFile::class)) { // when no maxSize is specified on constraint, it should use the ini value $tests[] = [(string) \UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [ '{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576, diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php index 8db8eddf7c..4979487e4a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php @@ -55,7 +55,7 @@ class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends Greate public function testThrowsConstraintExceptionIfPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('The "propertyPath" option of the "Symfony\Component\Validator\Constraints\PositiveOrZero" constraint cannot be set.'); return new PositiveOrZero(['propertyPath' => 'field']); @@ -63,7 +63,7 @@ class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends Greate public function testThrowsConstraintExceptionIfValue() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('The "value" option of the "Symfony\Component\Validator\Constraints\PositiveOrZero" constraint cannot be set.'); return new PositiveOrZero(['value' => 0]); @@ -74,14 +74,14 @@ class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends Greate */ public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options) { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.'); $this->markTestSkipped('Value option always set for PositiveOrZero constraint'); } public function testThrowsConstraintExceptionIfBothValueAndPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.'); $this->markTestSkipped('Value option is set for PositiveOrZero constraint automatically'); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php index ef10787bcc..6fb8f4c92e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php @@ -53,7 +53,7 @@ class GreaterThanValidatorWithPositiveConstraintTest extends GreaterThanValidato public function testThrowsConstraintExceptionIfPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('The "propertyPath" option of the "Symfony\Component\Validator\Constraints\Positive" constraint cannot be set.'); return new Positive(['propertyPath' => 'field']); @@ -61,7 +61,7 @@ class GreaterThanValidatorWithPositiveConstraintTest extends GreaterThanValidato public function testThrowsConstraintExceptionIfValue() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('The "value" option of the "Symfony\Component\Validator\Constraints\Positive" constraint cannot be set.'); return new Positive(['value' => 0]); @@ -72,14 +72,14 @@ class GreaterThanValidatorWithPositiveConstraintTest extends GreaterThanValidato */ public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options) { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.'); $this->markTestSkipped('Value option always set for Positive constraint.'); } public function testThrowsConstraintExceptionIfBothValueAndPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.'); $this->markTestSkipped('Value option is set for Positive constraint automatically'); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php index 2ad9ceb5d8..28050270f1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php @@ -202,7 +202,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase public function testInvalidMinWidth() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new Image([ 'minWidth' => '1abc', ]); @@ -212,7 +212,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase public function testInvalidMaxWidth() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new Image([ 'maxWidth' => '1abc', ]); @@ -222,7 +222,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase public function testInvalidMinHeight() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new Image([ 'minHeight' => '1abc', ]); @@ -232,7 +232,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase public function testInvalidMaxHeight() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new Image([ 'maxHeight' => '1abc', ]); @@ -242,7 +242,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase public function testInvalidMinPixels() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new Image([ 'minPixels' => '1abc', ]); @@ -252,7 +252,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase public function testInvalidMaxPixels() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new Image([ 'maxPixels' => '1abc', ]); @@ -305,7 +305,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase public function testInvalidMinRatio() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new Image([ 'minRatio' => '1abc', ]); @@ -315,7 +315,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase public function testInvalidMaxRatio() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $constraint = new Image([ 'maxRatio' => '1abc', ]); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php index f8147ac27f..b0d9930fec 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php @@ -28,14 +28,14 @@ class IpTest extends TestCase public function testInvalidNormalizerThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).'); new Ip(['normalizer' => 'Unknown Callable']); } public function testInvalidNormalizerObjectThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).'); new Ip(['normalizer' => new \stdClass()]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php index 554f80d1fb..c3401b011b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php @@ -38,13 +38,13 @@ class IpValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Ip()); } public function testInvalidValidatorVersion() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new Ip([ 'version' => 666, ]); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php index 895f9fbf18..057c4d3c04 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php @@ -138,7 +138,7 @@ class IsbnValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $constraint = new Isbn(true); $this->validator->validate(new \stdClass(), $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php index 9099dae62f..52199b8d03 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php @@ -108,7 +108,7 @@ class IssnValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $constraint = new Issn(); $this->validator->validate(new \stdClass(), $constraint); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index 669e7d2d97..090b122076 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -55,7 +55,7 @@ class LanguageValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Language()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php index 16a9115515..0b8a14e85c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php @@ -28,14 +28,14 @@ class LengthTest extends TestCase public function testInvalidNormalizerThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).'); new Length(['min' => 0, 'max' => 10, 'normalizer' => 'Unknown Callable', 'allowEmptyString' => false]); } public function testInvalidNormalizerObjectThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).'); new Length(['min' => 0, 'max' => 10, 'normalizer' => new \stdClass(), 'allowEmptyString' => false]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php index b30ef72da9..c106a1e718 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php @@ -59,7 +59,7 @@ class LengthValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Length(['value' => 5, 'allowEmptyString' => false])); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php index 5e4fff253b..92e9a3620c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php @@ -53,7 +53,7 @@ class LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest extends LessThanO public function testThrowsConstraintExceptionIfPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('The "propertyPath" option of the "Symfony\Component\Validator\Constraints\NegativeOrZero" constraint cannot be set.'); return new NegativeOrZero(['propertyPath' => 'field']); @@ -61,7 +61,7 @@ class LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest extends LessThanO public function testThrowsConstraintExceptionIfValue() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('The "value" option of the "Symfony\Component\Validator\Constraints\NegativeOrZero" constraint cannot be set.'); return new NegativeOrZero(['value' => 0]); @@ -72,14 +72,14 @@ class LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest extends LessThanO */ public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options) { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.'); $this->markTestSkipped('Value option always set for NegativeOrZero constraint'); } public function testThrowsConstraintExceptionIfBothValueAndPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.'); $this->markTestSkipped('Value option is set for NegativeOrZero constraint automatically'); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php index 642bd8341f..7f7da277ae 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php @@ -53,7 +53,7 @@ class LessThanValidatorWithNegativeConstraintTest extends LessThanValidatorTest public function testThrowsConstraintExceptionIfPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('The "propertyPath" option of the "Symfony\Component\Validator\Constraints\Negative" constraint cannot be set.'); return new Negative(['propertyPath' => 'field']); @@ -61,7 +61,7 @@ class LessThanValidatorWithNegativeConstraintTest extends LessThanValidatorTest public function testThrowsConstraintExceptionIfValue() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('The "value" option of the "Symfony\Component\Validator\Constraints\Negative" constraint cannot be set.'); return new Negative(['value' => 0]); @@ -72,14 +72,14 @@ class LessThanValidatorWithNegativeConstraintTest extends LessThanValidatorTest */ public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options) { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.'); $this->markTestSkipped('Value option always set for Negative constraint'); } public function testThrowsConstraintExceptionIfBothValueAndPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.'); $this->markTestSkipped('Value option is set for Negative constraint automatically'); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index de21a2284b..55a41274cf 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -68,13 +68,13 @@ class LocaleValidatorTest extends ConstraintValidatorTestCase */ public function testLegacyExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedTypeException::class); $this->validator->validate(new \stdClass(), new Locale()); } public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Locale(['canonicalize' => true])); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php index 5fde299d70..11e144e607 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php @@ -103,7 +103,7 @@ class LuhnValidatorTest extends ConstraintValidatorTestCase */ public function testInvalidTypes($number) { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $constraint = new Luhn(); $this->validator->validate($number, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php index 285132a1f1..fe6597ceec 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php @@ -28,14 +28,14 @@ class NotBlankTest extends TestCase public function testInvalidNormalizerThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).'); new NotBlank(['normalizer' => 'Unknown Callable']); } public function testInvalidNormalizerObjectThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).'); new NotBlank(['normalizer' => new \stdClass()]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php index a0277d45a6..3f34b008c0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php @@ -153,19 +153,19 @@ class NotCompromisedPasswordValidatorTest extends ConstraintValidatorTestCase public function testInvalidConstraint() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedTypeException::class); $this->validator->validate(null, new Luhn()); } public function testInvalidValue() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedTypeException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedTypeException::class); $this->validator->validate([], new NotCompromisedPassword()); } public function testApiError() { - $this->expectException('Symfony\Contracts\HttpClient\Exception\ExceptionInterface'); + $this->expectException(\Symfony\Contracts\HttpClient\Exception\ExceptionInterface::class); $this->expectExceptionMessage('Problem contacting the Have I been Pwned API.'); $this->validator->validate(self::PASSWORD_TRIGGERING_AN_ERROR, new NotCompromisedPassword()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php index 1062977d8d..f9204858d2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php @@ -9,7 +9,7 @@ class RangeTest extends TestCase { public function testThrowsConstraintExceptionIfBothMinLimitAndPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "min" or "minPropertyPath" options to be set, not both.'); new Range([ 'min' => 'min', @@ -19,7 +19,7 @@ class RangeTest extends TestCase public function testThrowsConstraintExceptionIfBothMaxLimitAndPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('requires only one of the "max" or "maxPropertyPath" options to be set, not both.'); new Range([ 'max' => 'max', @@ -29,14 +29,14 @@ class RangeTest extends TestCase public function testThrowsConstraintExceptionIfNoLimitNorPropertyPath() { - $this->expectException('Symfony\Component\Validator\Exception\MissingOptionsException'); + $this->expectException(\Symfony\Component\Validator\Exception\MissingOptionsException::class); $this->expectExceptionMessage('Either option "min", "minPropertyPath", "max" or "maxPropertyPath" must be given'); new Range([]); } public function testThrowsNoDefaultOptionConfiguredException() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectExceptionMessage('No default option is configured'); new Range('value'); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php index f49f2c0bb4..bca27fa477 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php @@ -95,14 +95,14 @@ class RegexTest extends TestCase public function testInvalidNormalizerThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).'); new Regex(['pattern' => '/^[0-9]+$/', 'normalizer' => 'Unknown Callable']); } public function testInvalidNormalizerObjectThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).'); new Regex(['pattern' => '/^[0-9]+$/', 'normalizer' => new \stdClass()]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index 8ad07d940c..9eb736a0a6 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -38,7 +38,7 @@ class RegexValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Regex(['pattern' => '/^[0-9]+$/'])); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php index 813f06ddbf..b98c17dec9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -49,7 +49,7 @@ class TimeValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Time()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php index 47566ea6de..2801fe2160 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php @@ -34,7 +34,7 @@ class TimezoneTest extends TestCase public function testExceptionForGroupedTimezonesByCountryWithWrongZone() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new Timezone([ 'zone' => \DateTimeZone::ALL, 'countryCode' => 'AR', @@ -43,7 +43,7 @@ class TimezoneTest extends TestCase public function testExceptionForGroupedTimezonesByCountryWithoutZone() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new Timezone(['countryCode' => 'AR']); } @@ -52,7 +52,7 @@ class TimezoneTest extends TestCase */ public function testExceptionForInvalidGroupedTimezones(int $zone) { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); new Timezone(['zone' => $zone]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php index 1f43224641..70f2f88f87 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php @@ -42,7 +42,7 @@ class TimezoneValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Timezone()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php index da46323db3..6d11b1fcc9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php @@ -24,7 +24,7 @@ class UniqueValidatorTest extends ConstraintValidatorTestCase public function testExpectsUniqueConstraintCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate('', new Unique()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php index c1799ed551..3353d7f03e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php @@ -28,14 +28,14 @@ class UrlTest extends TestCase public function testInvalidNormalizerThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).'); new Url(['normalizer' => 'Unknown Callable']); } public function testInvalidNormalizerObjectThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).'); new Url(['normalizer' => new \stdClass()]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index dde594d200..d232043c76 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -49,7 +49,7 @@ class UrlValidatorTest extends ConstraintValidatorTestCase public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Url()); } @@ -367,7 +367,7 @@ class UrlValidatorTest extends ConstraintValidatorTestCase */ public function testCheckDnsWithInvalidType() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidOptionsException::class); DnsMock::withMockedHosts(['example.com' => [['type' => 'A']]]); $constraint = new Url([ diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php index e048ecb211..78bd4a5e52 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php @@ -28,14 +28,14 @@ class UuidTest extends TestCase public function testInvalidNormalizerThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).'); new Uuid(['normalizer' => 'Unknown Callable']); } public function testInvalidNormalizerObjectThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).'); new Uuid(['normalizer' => new \stdClass()]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php index b6d5fb3dba..ac2b7fe213 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php @@ -41,15 +41,15 @@ class UuidValidatorTest extends ConstraintValidatorTestCase public function testExpectsUuidConstraintCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedTypeException'); - $constraint = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\Constraint'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedTypeException::class); + $constraint = $this->getMockForAbstractClass(\Symfony\Component\Validator\Constraint::class); $this->validator->validate('216fff40-98d9-11e3-a5e2-0800200c9a66', $constraint); } public function testExpectsStringCompatibleType() { - $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); + $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->validator->validate(new \stdClass(), new Uuid()); } diff --git a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php index 12176c45a3..4555fcecbe 100644 --- a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php @@ -47,7 +47,7 @@ class ContainerConstraintValidatorFactoryTest extends TestCase public function testGetInstanceInvalidValidatorClass() { - $this->expectException('Symfony\Component\Validator\Exception\ValidatorException'); + $this->expectException(\Symfony\Component\Validator\Exception\ValidatorException::class); $constraint = $this->getMockBuilder(Constraint::class)->getMock(); $constraint ->expects($this->once()) diff --git a/src/Symfony/Component/Validator/Tests/DependencyInjection/AddConstraintValidatorsPassTest.php b/src/Symfony/Component/Validator/Tests/DependencyInjection/AddConstraintValidatorsPassTest.php index 45e73fc434..5e4a009036 100644 --- a/src/Symfony/Component/Validator/Tests/DependencyInjection/AddConstraintValidatorsPassTest.php +++ b/src/Symfony/Component/Validator/Tests/DependencyInjection/AddConstraintValidatorsPassTest.php @@ -47,7 +47,7 @@ class AddConstraintValidatorsPassTest extends TestCase public function testAbstractConstraintValidator() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The service "my_abstract_constraint_validator" tagged "validator.constraint_validator" must not be abstract.'); $container = new ContainerBuilder(); $container->register('validator.validator_factory') diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php index 93834fbf44..04a7d1dff6 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php @@ -43,14 +43,14 @@ class ClassMetadataTest extends TestCase public function testAddConstraintDoesNotAcceptValid() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(ConstraintDefinitionException::class); $this->metadata->addConstraint(new Valid()); } public function testAddConstraintRequiresClassConstraints() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(ConstraintDefinitionException::class); $this->metadata->addConstraint(new PropertyConstraint()); } @@ -264,24 +264,24 @@ class ClassMetadataTest extends TestCase { $this->metadata->setGroupSequence(['Foo', $this->metadata->getDefaultGroup()]); - $this->assertInstanceOf('Symfony\Component\Validator\Constraints\GroupSequence', $this->metadata->getGroupSequence()); + $this->assertInstanceOf(\Symfony\Component\Validator\Constraints\GroupSequence::class, $this->metadata->getGroupSequence()); } public function testGroupSequencesFailIfNotContainingDefaultGroup() { - $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\GroupDefinitionException::class); $this->metadata->setGroupSequence(['Foo', 'Bar']); } public function testGroupSequencesFailIfContainingDefault() { - $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\GroupDefinitionException::class); $this->metadata->setGroupSequence(['Foo', $this->metadata->getDefaultGroup(), Constraint::DEFAULT_GROUP]); } public function testGroupSequenceFailsIfGroupSequenceProviderIsSet() { - $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\GroupDefinitionException::class); $metadata = new ClassMetadata(self::PROVIDERCLASS); $metadata->setGroupSequenceProvider(true); $metadata->setGroupSequence(['GroupSequenceProviderEntity', 'Foo']); @@ -289,7 +289,7 @@ class ClassMetadataTest extends TestCase public function testGroupSequenceProviderFailsIfGroupSequenceIsSet() { - $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\GroupDefinitionException::class); $metadata = new ClassMetadata(self::PROVIDERCLASS); $metadata->setGroupSequence(['GroupSequenceProviderEntity', 'Foo']); $metadata->setGroupSequenceProvider(true); @@ -297,7 +297,7 @@ class ClassMetadataTest extends TestCase public function testGroupSequenceProviderFailsIfDomainClassIsInvalid() { - $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\GroupDefinitionException::class); $metadata = new ClassMetadata('stdClass'); $metadata->setGroupSequenceProvider(true); } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php index 6fe103bf39..6cbfadad5b 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php @@ -18,7 +18,7 @@ class BlackHoleMetadataFactoryTest extends TestCase { public function testGetMetadataForThrowsALogicException() { - $this->expectException('Symfony\Component\Validator\Exception\LogicException'); + $this->expectException(\Symfony\Component\Validator\Exception\LogicException::class); $metadataFactory = new BlackHoleMetadataFactory(); $metadataFactory->getMetadataFor('foo'); } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php index 2a06dcd1b8..20a35e0632 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php @@ -131,8 +131,8 @@ class LazyLoadingMetadataFactoryTest extends TestCase */ public function testReadMetadataFromLegacyCache() { - $loader = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); - $cache = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock(); + $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); + $cache = $this->getMockBuilder(\Symfony\Component\Validator\Mapping\Cache\CacheInterface::class)->getMock(); $factory = new LazyLoadingMetadataFactory($loader, $cache); $metadata = new ClassMetadata(self::PARENT_CLASS); @@ -165,9 +165,9 @@ class LazyLoadingMetadataFactoryTest extends TestCase public function testNonClassNameStringValues() { - $this->expectException('Symfony\Component\Validator\Exception\NoSuchMetadataException'); + $this->expectException(\Symfony\Component\Validator\Exception\NoSuchMetadataException::class); $testedValue = 'error@example.com'; - $loader = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); + $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); $cache = $this->createMock(CacheItemPoolInterface::class); $factory = new LazyLoadingMetadataFactory($loader, $cache); $cache diff --git a/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php index 442afaf134..004b1df2b4 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php @@ -21,7 +21,7 @@ class GetterMetadataTest extends TestCase public function testInvalidPropertyName() { - $this->expectException('Symfony\Component\Validator\Exception\ValidatorException'); + $this->expectException(\Symfony\Component\Validator\Exception\ValidatorException::class); new GetterMetadata(self::CLASSNAME, 'foobar'); } @@ -63,7 +63,7 @@ class GetterMetadataTest extends TestCase public function testUndefinedMethodNameThrowsException() { - $this->expectException('Symfony\Component\Validator\Exception\ValidatorException'); + $this->expectException(\Symfony\Component\Validator\Exception\ValidatorException::class); $this->expectExceptionMessage('The "hasLastName()" method does not exist in class "Symfony\Component\Validator\Tests\Fixtures\Entity".'); new GetterMetadata(self::CLASSNAME, 'lastName', 'hasLastName'); } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php index 2cf009fc08..ae21625665 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php @@ -34,7 +34,7 @@ class FilesLoaderTest extends TestCase public function getFilesLoader(LoaderInterface $loader) { - return $this->getMockForAbstractClass('Symfony\Component\Validator\Tests\Fixtures\FilesLoader', [[ + return $this->getMockForAbstractClass(\Symfony\Component\Validator\Tests\Fixtures\FilesLoader::class, [[ __DIR__.'/constraint-mapping.xml', __DIR__.'/constraint-mapping.yaml', __DIR__.'/constraint-mapping.test', @@ -44,6 +44,6 @@ class FilesLoaderTest extends TestCase public function getFileLoader() { - return $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); + return $this->getMockBuilder(LoaderInterface::class)->getMock(); } } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php index 45b8576f0e..c7ebaaa872 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php @@ -21,12 +21,12 @@ class LoaderChainTest extends TestCase { $metadata = new ClassMetadata('\stdClass'); - $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); + $loader1 = $this->getMockBuilder(\Symfony\Component\Validator\Mapping\Loader\LoaderInterface::class)->getMock(); $loader1->expects($this->once()) ->method('loadClassMetadata') ->with($this->equalTo($metadata)); - $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); + $loader2 = $this->getMockBuilder(\Symfony\Component\Validator\Mapping\Loader\LoaderInterface::class)->getMock(); $loader2->expects($this->once()) ->method('loadClassMetadata') ->with($this->equalTo($metadata)); @@ -43,12 +43,12 @@ class LoaderChainTest extends TestCase { $metadata = new ClassMetadata('\stdClass'); - $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); + $loader1 = $this->getMockBuilder(\Symfony\Component\Validator\Mapping\Loader\LoaderInterface::class)->getMock(); $loader1->expects($this->any()) ->method('loadClassMetadata') ->willReturn(true); - $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); + $loader2 = $this->getMockBuilder(\Symfony\Component\Validator\Mapping\Loader\LoaderInterface::class)->getMock(); $loader2->expects($this->any()) ->method('loadClassMetadata') ->willReturn(false); @@ -65,12 +65,12 @@ class LoaderChainTest extends TestCase { $metadata = new ClassMetadata('\stdClass'); - $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); + $loader1 = $this->getMockBuilder(\Symfony\Component\Validator\Mapping\Loader\LoaderInterface::class)->getMock(); $loader1->expects($this->any()) ->method('loadClassMetadata') ->willReturn(false); - $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); + $loader2 = $this->getMockBuilder(\Symfony\Component\Validator\Mapping\Loader\LoaderInterface::class)->getMock(); $loader2->expects($this->any()) ->method('loadClassMetadata') ->willReturn(false); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php index 1da3f234c9..60caadccff 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php @@ -43,7 +43,7 @@ class YamlFileLoaderTest extends TestCase */ public function testInvalidYamlFiles($path) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $loader = new YamlFileLoader(__DIR__.'/'.$path); $metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity'); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php index cfc09a7a86..70b7e2cea3 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php @@ -43,7 +43,7 @@ class MemberMetadataTest extends TestCase public function testAddConstraintRequiresClassConstraints() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(ConstraintDefinitionException::class); $this->metadata->addConstraint(new ClassConstraint()); } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php index 3796677294..6f926b9b06 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php @@ -26,7 +26,7 @@ class PropertyMetadataTest extends TestCase public function testInvalidPropertyName() { - $this->expectException('Symfony\Component\Validator\Exception\ValidatorException'); + $this->expectException(\Symfony\Component\Validator\Exception\ValidatorException::class); new PropertyMetadata(self::CLASSNAME, 'foobar'); } @@ -54,7 +54,7 @@ class PropertyMetadataTest extends TestCase $metadata = new PropertyMetadata(self::CLASSNAME, 'internal'); $metadata->name = 'test'; - $this->expectException('Symfony\Component\Validator\Exception\ValidatorException'); + $this->expectException(\Symfony\Component\Validator\Exception\ValidatorException::class); $metadata->getPropertyValue($entity); } diff --git a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php index 17a8914304..e3bb8fe366 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php @@ -540,7 +540,7 @@ class RecursiveValidatorTest extends TestCase public function testFailOnScalarReferences() { - $this->expectException('Symfony\Component\Validator\Exception\NoSuchMetadataException'); + $this->expectException(\Symfony\Component\Validator\Exception\NoSuchMetadataException::class); $entity = new Entity(); $entity->reference = 'string'; @@ -795,7 +795,7 @@ class RecursiveValidatorTest extends TestCase public function testMetadataMustExistIfTraversalIsDisabled() { - $this->expectException('Symfony\Component\Validator\Exception\NoSuchMetadataException'); + $this->expectException(\Symfony\Component\Validator\Exception\NoSuchMetadataException::class); $entity = new Entity(); $entity->reference = new \ArrayIterator(); @@ -1663,7 +1663,7 @@ class RecursiveValidatorTest extends TestCase public function testExpectTraversableIfTraversalEnabledOnClass() { - $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); + $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $entity = new Entity(); $this->metadata->addConstraint(new Traverse(true)); @@ -1819,7 +1819,7 @@ class RecursiveValidatorTest extends TestCase public function testValidateFailsIfNoConstraintsAndNoObjectOrArray() { - $this->expectException('Symfony\Component\Validator\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\Validator\Exception\RuntimeException::class); $this->validate('Foobar'); } @@ -1850,8 +1850,8 @@ class RecursiveValidatorTest extends TestCase $entity->initialized = false; // prepare initializers that set "initialized" to true - $initializer1 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock(); - $initializer2 = $this->getMockBuilder('Symfony\\Component\\Validator\\ObjectInitializerInterface')->getMock(); + $initializer1 = $this->getMockBuilder(\Symfony\Component\Validator\ObjectInitializerInterface::class)->getMock(); + $initializer2 = $this->getMockBuilder(\Symfony\Component\Validator\ObjectInitializerInterface::class)->getMock(); $initializer1->expects($this->once()) ->method('initialize') @@ -1993,7 +1993,7 @@ class RecursiveValidatorTest extends TestCase $childB->name = 'fake'; $entity->childA = [$childA]; $entity->childB = [$childB]; - $validatorContext = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock(); + $validatorContext = $this->getMockBuilder(\Symfony\Component\Validator\Validator\ContextualValidatorInterface::class)->getMock(); $validatorContext ->expects($this->once()) ->method('validate') @@ -2001,7 +2001,7 @@ class RecursiveValidatorTest extends TestCase ->willReturnSelf(); $validator = $this - ->getMockBuilder('Symfony\Component\Validator\Validator\RecursiveValidator') + ->getMockBuilder(RecursiveValidator::class) ->disableOriginalConstructor() ->setMethods(['startContext']) ->getMock(); @@ -2027,7 +2027,7 @@ class RecursiveValidatorTest extends TestCase $entity->childA = [$childA]; $entity->childB = [$childB]; - $validatorContext = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock(); + $validatorContext = $this->getMockBuilder(\Symfony\Component\Validator\Validator\ContextualValidatorInterface::class)->getMock(); $validatorContext ->expects($this->once()) ->method('validate') @@ -2035,7 +2035,7 @@ class RecursiveValidatorTest extends TestCase ->willReturnSelf(); $validator = $this - ->getMockBuilder('Symfony\Component\Validator\Validator\RecursiveValidator') + ->getMockBuilder(RecursiveValidator::class) ->disableOriginalConstructor() ->setMethods(['startContext']) ->getMock(); diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php index 95c3447086..ffd05c779f 100644 --- a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -37,7 +37,7 @@ class ValidatorBuilderTest extends TestCase public function testAddObjectInitializer() { $this->assertSame($this->builder, $this->builder->addObjectInitializer( - $this->getMockBuilder('Symfony\Component\Validator\ObjectInitializerInterface')->getMock() + $this->getMockBuilder(\Symfony\Component\Validator\ObjectInitializerInterface::class)->getMock() )); } @@ -98,21 +98,21 @@ class ValidatorBuilderTest extends TestCase public function testSetMetadataCache() { $this->assertSame($this->builder, $this->builder->setMetadataCache( - $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock()) + $this->getMockBuilder(\Symfony\Component\Validator\Mapping\Cache\CacheInterface::class)->getMock()) ); } public function testSetConstraintValidatorFactory() { $this->assertSame($this->builder, $this->builder->setConstraintValidatorFactory( - $this->getMockBuilder('Symfony\Component\Validator\ConstraintValidatorFactoryInterface')->getMock()) + $this->getMockBuilder(\Symfony\Component\Validator\ConstraintValidatorFactoryInterface::class)->getMock()) ); } public function testSetTranslator() { $this->assertSame($this->builder, $this->builder->setTranslator( - $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()) + $this->getMockBuilder(\Symfony\Component\Translation\TranslatorInterface::class)->getMock()) ); } @@ -131,6 +131,6 @@ class ValidatorBuilderTest extends TestCase public function testGetValidator() { - $this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator()); + $this->assertInstanceOf(\Symfony\Component\Validator\Validator\RecursiveValidator::class, $this->builder->getValidator()); } } diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/MemcachedCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/MemcachedCasterTest.php index df48390af9..b252675c7a 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/MemcachedCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/MemcachedCasterTest.php @@ -23,7 +23,7 @@ class MemcachedCasterTest extends TestCase public function testCastMemcachedWithDefaultOptions() { - if (!class_exists('Memcached')) { + if (!class_exists(\Memcached::class)) { $this->markTestSkipped('Memcached not available'); } @@ -53,7 +53,7 @@ EOTXT; public function testCastMemcachedWithCustomOptions() { - if (!class_exists('Memcached')) { + if (!class_exists(\Memcached::class)) { $this->markTestSkipped('Memcached not available'); } diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/PdoCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/PdoCasterTest.php index fca242cfc6..21fecc9962 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/PdoCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/PdoCasterTest.php @@ -34,10 +34,10 @@ class PdoCasterTest extends TestCase $cast = PdoCaster::castPdo($pdo, [], new Stub(), false); - $this->assertInstanceOf('Symfony\Component\VarDumper\Caster\EnumStub', $cast["\0~\0attributes"]); + $this->assertInstanceOf(\Symfony\Component\VarDumper\Caster\EnumStub::class, $cast["\0~\0attributes"]); $attr = $cast["\0~\0attributes"] = $cast["\0~\0attributes"]->value; - $this->assertInstanceOf('Symfony\Component\VarDumper\Caster\ConstStub', $attr['CASE']); + $this->assertInstanceOf(\Symfony\Component\VarDumper\Caster\ConstStub::class, $attr['CASE']); $this->assertSame('NATURAL', $attr['CASE']->class); $this->assertSame('BOTH', $attr['DEFAULT_FETCH_MODE']->class); diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php index e1214765ef..9fc8dcaf0d 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -26,7 +26,7 @@ class ReflectionCasterTest extends TestCase public function testReflectionCaster() { - $var = new \ReflectionClass('ReflectionClass'); + $var = new \ReflectionClass(\ReflectionClass::class); $this->assertDumpMatchesFormat( <<<'EOTXT' diff --git a/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php b/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php index dcce237243..67e53badb6 100644 --- a/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php +++ b/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php @@ -2,7 +2,7 @@ namespace Symfony\Component\VarDumper\Tests\Fixture; -if (!class_exists('Symfony\Component\VarDumper\Tests\Fixture\DumbFoo')) { +if (!class_exists(\Symfony\Component\VarDumper\Tests\Fixture\DumbFoo::class)) { class DumbFoo { public $foo = 'foo'; diff --git a/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php b/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php index 6d0deb68dc..a5ce64a5b0 100644 --- a/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php +++ b/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php @@ -18,7 +18,7 @@ class InstantiatorTest extends TestCase { public function testNotFoundClass() { - $this->expectException('Symfony\Component\VarExporter\Exception\ClassNotFoundException'); + $this->expectException(\Symfony\Component\VarExporter\Exception\ClassNotFoundException::class); $this->expectExceptionMessage('Class "SomeNotExistingClass" not found.'); Instantiator::instantiate('SomeNotExistingClass'); } @@ -28,7 +28,7 @@ class InstantiatorTest extends TestCase */ public function testFailingInstantiation(string $class) { - $this->expectException('Symfony\Component\VarExporter\Exception\NotInstantiableTypeException'); + $this->expectException(\Symfony\Component\VarExporter\Exception\NotInstantiableTypeException::class); $this->expectExceptionMessageMatches('/Type ".*" is not instantiable\./'); Instantiator::instantiate($class); } diff --git a/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php b/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php index 84bb152541..9148028667 100644 --- a/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php +++ b/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php @@ -22,7 +22,7 @@ class VarExporterTest extends TestCase public function testPhpIncompleteClassesAreForbidden() { - $this->expectException('Symfony\Component\VarExporter\Exception\ClassNotFoundException'); + $this->expectException(\Symfony\Component\VarExporter\Exception\ClassNotFoundException::class); $this->expectExceptionMessage('Class "SomeNotExistingClass" not found.'); $unserializeCallback = ini_set('unserialize_callback_func', 'var_dump'); try { @@ -37,7 +37,7 @@ class VarExporterTest extends TestCase */ public function testFailingSerialization($value) { - $this->expectException('Symfony\Component\VarExporter\Exception\NotInstantiableTypeException'); + $this->expectException(\Symfony\Component\VarExporter\Exception\NotInstantiableTypeException::class); $this->expectExceptionMessageMatches('/Type ".*" is not instantiable\./'); $expectedDump = $this->getDump($value); try { @@ -50,7 +50,7 @@ class VarExporterTest extends TestCase public function provideFailingSerialization() { yield [hash_init('md5')]; - yield [new \ReflectionClass('stdClass')]; + yield [new \ReflectionClass(\stdClass::class)]; yield [(new \ReflectionFunction(function (): int {}))->getReturnType()]; yield [new \ReflectionGenerator((function () { yield 123; })())]; yield [function () {}]; @@ -173,11 +173,11 @@ class VarExporterTest extends TestCase $value = new \Error(); - $rt = new \ReflectionProperty('Error', 'trace'); + $rt = new \ReflectionProperty(\Error::class, 'trace'); $rt->setAccessible(true); $rt->setValue($value, ['file' => __FILE__, 'line' => 123]); - $rl = new \ReflectionProperty('Error', 'line'); + $rl = new \ReflectionProperty(\Error::class, 'line'); $rl->setAccessible(true); $rl->setValue($value, 234); diff --git a/src/Symfony/Component/Workflow/Tests/DefinitionTest.php b/src/Symfony/Component/Workflow/Tests/DefinitionTest.php index 6ba3c1ef47..da20a2b3ac 100644 --- a/src/Symfony/Component/Workflow/Tests/DefinitionTest.php +++ b/src/Symfony/Component/Workflow/Tests/DefinitionTest.php @@ -36,7 +36,7 @@ class DefinitionTest extends TestCase public function testSetInitialPlaceAndPlaceIsNotDefined() { - $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); + $this->expectException(\Symfony\Component\Workflow\Exception\LogicException::class); $this->expectExceptionMessage('Place "d" cannot be the initial place as it does not exist.'); new Definition([], [], 'd'); } @@ -54,7 +54,7 @@ class DefinitionTest extends TestCase public function testAddTransitionAndFromPlaceIsNotDefined() { - $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); + $this->expectException(\Symfony\Component\Workflow\Exception\LogicException::class); $this->expectExceptionMessage('Place "c" referenced in transition "name" does not exist.'); $places = range('a', 'b'); @@ -63,7 +63,7 @@ class DefinitionTest extends TestCase public function testAddTransitionAndToPlaceIsNotDefined() { - $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); + $this->expectException(\Symfony\Component\Workflow\Exception\LogicException::class); $this->expectExceptionMessage('Place "c" referenced in transition "name" does not exist.'); $places = range('a', 'b'); diff --git a/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php b/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php index 5e5c8fec6f..6a62c7bfed 100644 --- a/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php +++ b/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php @@ -77,7 +77,7 @@ class InMemoryMetadataStoreTest extends TestCase public function testGetMetadataWithUnknownType() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Could not find a MetadataBag for the subject of type "boolean".'); $this->store->getMetadata('title', true); } diff --git a/src/Symfony/Component/Workflow/Tests/RegistryTest.php b/src/Symfony/Component/Workflow/Tests/RegistryTest.php index 7a02f311c0..26991dd182 100644 --- a/src/Symfony/Component/Workflow/Tests/RegistryTest.php +++ b/src/Symfony/Component/Workflow/Tests/RegistryTest.php @@ -61,7 +61,7 @@ class RegistryTest extends TestCase public function testGetWithMultipleMatch() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Too many workflows (workflow2, workflow3) match this subject (Symfony\Component\Workflow\Tests\Subject2); set a different name on each and use the second (name) argument of this method.'); $w1 = $this->registry->get(new Subject2()); $this->assertInstanceOf(Workflow::class, $w1); @@ -70,7 +70,7 @@ class RegistryTest extends TestCase public function testGetWithNoMatch() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Unable to find a workflow for class "stdClass".'); $w1 = $this->registry->get(new \stdClass()); $this->assertInstanceOf(Workflow::class, $w1); diff --git a/src/Symfony/Component/Workflow/Tests/Validator/StateMachineValidatorTest.php b/src/Symfony/Component/Workflow/Tests/Validator/StateMachineValidatorTest.php index f3014e817d..b929a8ca42 100644 --- a/src/Symfony/Component/Workflow/Tests/Validator/StateMachineValidatorTest.php +++ b/src/Symfony/Component/Workflow/Tests/Validator/StateMachineValidatorTest.php @@ -11,7 +11,7 @@ class StateMachineValidatorTest extends TestCase { public function testWithMultipleTransitionWithSameNameShareInput() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('A transition from a place/state must have an unique name.'); $places = ['a', 'b', 'c']; $transitions[] = new Transition('t1', 'a', 'b'); @@ -35,7 +35,7 @@ class StateMachineValidatorTest extends TestCase public function testWithMultipleTos() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('A transition in StateMachine can only have one output.'); $places = ['a', 'b', 'c']; $transitions[] = new Transition('t1', 'a', ['b', 'c']); @@ -58,7 +58,7 @@ class StateMachineValidatorTest extends TestCase public function testWithMultipleFroms() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('A transition in StateMachine can only have one input.'); $places = ['a', 'b', 'c']; $transitions[] = new Transition('t1', ['a', 'b'], 'c'); @@ -106,7 +106,7 @@ class StateMachineValidatorTest extends TestCase public function testWithTooManyInitialPlaces() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('The state machine "foo" can not store many places. But the definition has 2 initial places. Only one is supported.'); $places = range('a', 'c'); $transitions = []; diff --git a/src/Symfony/Component/Workflow/Tests/Validator/WorkflowValidatorTest.php b/src/Symfony/Component/Workflow/Tests/Validator/WorkflowValidatorTest.php index c67229c073..12b90262f5 100644 --- a/src/Symfony/Component/Workflow/Tests/Validator/WorkflowValidatorTest.php +++ b/src/Symfony/Component/Workflow/Tests/Validator/WorkflowValidatorTest.php @@ -14,7 +14,7 @@ class WorkflowValidatorTest extends TestCase public function testSinglePlaceWorkflowValidatorAndComplexWorkflow() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('The marking store of workflow "foo" can not store many places.'); $definition = $this->createComplexWorkflowDefinition(); @@ -33,7 +33,7 @@ class WorkflowValidatorTest extends TestCase public function testWorkflowWithInvalidNames() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('All transitions for a place must have an unique name. Multiple transitions named "t1" where found for place "a" in workflow "foo".'); $places = range('a', 'c'); @@ -49,7 +49,7 @@ class WorkflowValidatorTest extends TestCase public function testWithTooManyInitialPlaces() { - $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class); $this->expectExceptionMessage('The marking store of workflow "foo" can not store many places. But the definition has 2 initial places. Only one is supported.'); $places = range('a', 'c'); $transitions = []; diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index 54b26421f7..14e30bebc7 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -22,7 +22,7 @@ class WorkflowTest extends TestCase public function testGetMarkingWithInvalidStoreReturn() { - $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); + $this->expectException(\Symfony\Component\Workflow\Exception\LogicException::class); $this->expectExceptionMessage('The value returned by the MarkingStore is not an instance of "Symfony\Component\Workflow\Marking" for workflow "unnamed".'); $subject = new Subject(); $workflow = new Workflow(new Definition([], []), $this->getMockBuilder(MarkingStoreInterface::class)->getMock()); @@ -32,7 +32,7 @@ class WorkflowTest extends TestCase public function testGetMarkingWithEmptyDefinition() { - $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); + $this->expectException(\Symfony\Component\Workflow\Exception\LogicException::class); $this->expectExceptionMessage('The Marking is empty and there is no initial place for workflow "unnamed".'); $subject = new Subject(); $workflow = new Workflow(new Definition([], []), new MethodMarkingStore()); @@ -42,7 +42,7 @@ class WorkflowTest extends TestCase public function testGetMarkingWithImpossiblePlace() { - $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); + $this->expectException(\Symfony\Component\Workflow\Exception\LogicException::class); $this->expectExceptionMessage('Place "nope" is not valid for workflow "unnamed".'); $subject = new Subject(); $subject->setMarking(['nope' => 1]); @@ -169,7 +169,7 @@ class WorkflowTest extends TestCase public function testBuildTransitionBlockerListReturnsUndefinedTransition() { - $this->expectException('Symfony\Component\Workflow\Exception\UndefinedTransitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\UndefinedTransitionException::class); $this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".'); $definition = $this->createSimpleWorkflowDefinition(); $subject = new Subject(); @@ -249,7 +249,7 @@ class WorkflowTest extends TestCase public function testApplyWithNotExisingTransition() { - $this->expectException('Symfony\Component\Workflow\Exception\UndefinedTransitionException'); + $this->expectException(\Symfony\Component\Workflow\Exception\UndefinedTransitionException::class); $this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".'); $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); diff --git a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php index 4b9788c1e0..5ad032bfa0 100644 --- a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php @@ -92,7 +92,7 @@ YAML; public function testLintFileNotReadable() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $tester = $this->createCommandTester(); $filename = $this->createFile(''); unlink($filename); diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index 41c8b02c7b..7f3e245f30 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -194,7 +194,7 @@ EOF; public function testObjectSupportDisabledWithExceptions() { - $this->expectException('Symfony\Component\Yaml\Exception\DumpException'); + $this->expectException(\Symfony\Component\Yaml\Exception\DumpException::class); $this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); } @@ -619,14 +619,14 @@ YAML; public function testZeroIndentationThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The indentation must be greater than zero'); new Dumper(0); } public function testNegativeIndentationThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The indentation must be greater than zero'); new Dumper(-4); } diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 0f608c330c..338ea504a8 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -66,14 +66,14 @@ class InlineTest extends TestCase public function testParsePhpConstantThrowsExceptionWhenUndefined() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('The constant "WRONG_CONSTANT" is not defined'); Inline::parse('!php/const WRONG_CONSTANT', Yaml::PARSE_CONSTANT); } public function testParsePhpConstantThrowsExceptionOnInvalidType() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessageMatches('#The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#'); Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE); } @@ -117,60 +117,60 @@ class InlineTest extends TestCase public function testParseScalarWithNonEscapedBlackslashShouldThrowException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Found unknown escape character "\V".'); Inline::parse('"Foo\Var"'); } public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); Inline::parse('"Foo\\"'); } public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $value = "'don't do somthin' like that'"; Inline::parse($value); } public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $value = '"don"t do somthin" like that"'; Inline::parse($value); } public function testParseInvalidMappingKeyShouldThrowException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $value = '{ "foo " bar": "bar" }'; Inline::parse($value); } public function testParseMappingKeyWithColonNotFollowedBySpace() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}")'); Inline::parse('{foo:""}'); } public function testParseInvalidMappingShouldThrowException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); Inline::parse('[foo] bar'); } public function testParseInvalidSequenceShouldThrowException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); Inline::parse('{ foo: bar } bar'); } public function testParseInvalidTaggedSequenceShouldThrowException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); Inline::parse('!foo { bar: baz } qux', Yaml::PARSE_CUSTOM_TAGS); } @@ -216,14 +216,14 @@ class InlineTest extends TestCase public function testParseUnquotedAsterisk() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('A reference must contain at least one character at line 1.'); Inline::parse('{ foo: * }'); } public function testParseUnquotedAsteriskFollowedByAComment() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('A reference must contain at least one character at line 1.'); Inline::parse('{ foo: * #foo }'); } @@ -610,7 +610,7 @@ class InlineTest extends TestCase */ public function testParseInvalidBinaryData($data, $expectedMessage) { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessageMatches($expectedMessage); Inline::parse($data); @@ -628,7 +628,7 @@ class InlineTest extends TestCase public function testNotSupportedMissingValue() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Malformed inline YAML string: "{this, is not, supported}" at line 1.'); Inline::parse('{this, is not, supported}'); } @@ -645,7 +645,7 @@ class InlineTest extends TestCase public function testMappingKeysCannotBeOmitted() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Missing mapping key'); Inline::parse('{: foo}'); } @@ -676,7 +676,7 @@ class InlineTest extends TestCase */ public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected) { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead'); $this->assertSame($expected, Inline::parse($yaml)); } @@ -729,7 +729,7 @@ class InlineTest extends TestCase public function testUnfinishedInlineMap() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage("Unexpected end of line, expected one of \",}\n\" at line 1 (near \"{abc: 'def'\")."); Inline::parse("{abc: 'def'"); } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index fa5ecfa37a..1db540369d 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -514,7 +514,7 @@ YAML; public function testObjectsSupportDisabledWithExceptions() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $yaml = <<<'EOF' foo: !php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";} bar: 1 @@ -565,14 +565,14 @@ EOF; $this->fail('charsets other than UTF-8 are rejected.'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.'); + $this->assertInstanceOf(ParseException::class, $e, 'charsets other than UTF-8 are rejected.'); } } } public function testUnindentedCollectionException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $yaml = <<<'EOF' collection: @@ -587,7 +587,7 @@ EOF; public function testShortcutKeyUnindentedCollectionException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $yaml = <<<'EOF' collection: @@ -601,7 +601,7 @@ EOF; public function testMultipleDocumentsNotSupportedException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessageMatches('/^Multiple documents are not supported.+/'); Yaml::parse(<<<'EOL' # Ranking of 1998 home runs @@ -620,7 +620,7 @@ EOL public function testSequenceInAMapping() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); Yaml::parse(<<<'EOF' yaml: hash: me @@ -728,7 +728,7 @@ EOT; */ public function testParseExceptionNotAffectedByMultiLineStringLastResortParsing($yaml) { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->parser->parse($yaml); } @@ -760,7 +760,7 @@ EOT; public function testMappingInASequence() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); Yaml::parse(<<<'EOF' yaml: - array stuff @@ -771,7 +771,7 @@ EOF public function testScalarInSequence() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('missing colon'); Yaml::parse(<<<'EOF' foo: @@ -794,7 +794,7 @@ EOF */ public function testMappingDuplicateKeyBlock() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Duplicate key "child" detected'); $input = <<<'EOD' parent: @@ -814,7 +814,7 @@ EOD; public function testMappingDuplicateKeyFlow() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Duplicate key "child" detected'); $input = <<<'EOD' parent: { child: first, child: duplicate } @@ -833,7 +833,7 @@ EOD; */ public function testParseExceptionOnDuplicate($input, $duplicateKey, $lineNumber) { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage(sprintf('Duplicate key "%s" detected at line %d', $duplicateKey, $lineNumber)); Yaml::parse($input); @@ -1059,7 +1059,7 @@ EOF; public function testFloatKeys() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Numeric keys are not supported. Quote your evaluable mapping keys instead'); $yaml = <<<'EOF' foo: @@ -1072,7 +1072,7 @@ EOF; public function testBooleanKeys() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Non-string keys are not supported. Quote your evaluable mapping keys instead'); $yaml = <<<'EOF' true: foo @@ -1109,7 +1109,7 @@ EOF; public function testColonInMappingValueException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('A colon cannot be used in an unquoted mapping value'); $yaml = <<<'EOF' foo: bar: baz @@ -1347,7 +1347,7 @@ EOT */ public function testParseInvalidBinaryData($data, $expectedMessage) { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessageMatches($expectedMessage); $this->parser->parse($data); @@ -2169,35 +2169,35 @@ YAML public function testCustomTagsDisabled() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Tags support is not enabled. Enable the "Yaml::PARSE_CUSTOM_TAGS" flag to use "!iterator" at line 1 (near "!iterator [foo]").'); $this->parser->parse('!iterator [foo]'); } public function testUnsupportedTagWithScalar() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Tags support is not enabled. Enable the "Yaml::PARSE_CUSTOM_TAGS" flag to use "!iterator" at line 1 (near "!iterator foo").'); $this->parser->parse('!iterator foo'); } public function testUnsupportedBuiltInTagWithScalar() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('The string "!!iterator foo" could not be parsed as it uses an unsupported built-in tag at line 1 (near "!!iterator foo").'); $this->parser->parse('!!iterator foo'); } public function testExceptionWhenUsingUnsupportedBuiltInTags() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('The built-in tag "!!foo" is not implemented at line 1 (near "!!foo").'); $this->parser->parse('!!foo'); } public function testComplexMappingThrowsParseException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Complex mappings are not supported at line 1 (near "? "1"").'); $yaml = <<expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Complex mappings are not supported at line 2 (near "? "1"").'); $yaml = <<expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Complex mappings are not supported at line 1 (near "- ? "1"").'); $yaml = <<expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Unable to parse at line 2 (near " foo = bar").'); $ini = <<expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Reference "foo" does not exist at line 2'); $yaml = <<expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessageMatches('#^File ".+/Fixtures/nonexistent.yml" does not exist\.$#'); $this->parser->parseFile(__DIR__.'/Fixtures/nonexistent.yml'); } public function testParsingNotReadableFilesThrowsException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessageMatches('#^File ".+/Fixtures/not_readable.yml" cannot be read\.$#'); if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('chmod is not supported on Windows'); @@ -2498,7 +2498,7 @@ YAML; public function testEvalRefException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Reference "foo" does not exist'); $yaml = <<expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('Circular reference [foo, bar, foo] detected'); $this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS); } diff --git a/src/Symfony/Component/Yaml/Tests/YamlTest.php b/src/Symfony/Component/Yaml/Tests/YamlTest.php index 7be1266497..151b5b9deb 100644 --- a/src/Symfony/Component/Yaml/Tests/YamlTest.php +++ b/src/Symfony/Component/Yaml/Tests/YamlTest.php @@ -26,14 +26,14 @@ class YamlTest extends TestCase public function testZeroIndentationThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The indentation must be greater than zero'); Yaml::dump(['lorem' => 'ipsum', 'dolor' => 'sit'], 2, 0); } public function testNegativeIndentationThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The indentation must be greater than zero'); Yaml::dump(['lorem' => 'ipsum', 'dolor' => 'sit'], 2, -4); } diff --git a/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php b/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php index 5ed9149529..d5b82674fa 100644 --- a/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php +++ b/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php @@ -67,7 +67,7 @@ abstract class ServiceLocatorTest extends TestCase public function testThrowsOnUndefinedInternalService() { if (!$this->getExpectedException()) { - $this->expectException('Psr\Container\NotFoundExceptionInterface'); + $this->expectException(\Psr\Container\NotFoundExceptionInterface::class); $this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.'); } $locator = $this->getServiceLocator([ @@ -79,7 +79,7 @@ abstract class ServiceLocatorTest extends TestCase public function testThrowsOnCircularReference() { - $this->expectException('Psr\Container\ContainerExceptionInterface'); + $this->expectException(\Psr\Container\ContainerExceptionInterface::class); $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".'); $locator = $this->getServiceLocator([ 'foo' => function () use (&$locator) { return $locator->get('bar'); }, diff --git a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php index 5bfb0f8df6..f1261e80d3 100644 --- a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php +++ b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php @@ -161,7 +161,7 @@ class TranslatorTest extends TestCase */ public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $translator = $this->getTranslator(); $translator->trans($id, ['%count%' => $number]);