diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index 69d58e701d..1bc8609cbf 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -48,7 +48,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, '.'); }); @@ -124,7 +124,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 4106683661..ead0012909 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', @@ -52,7 +52,7 @@ class DoctrineExtensionTest extends TestCase public function testFixManagersAutoMappingsWithTwoAutomappings() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $emConfigs = [ 'em1' => [ 'auto_mapping' => true, @@ -235,7 +235,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 3966be4965..87695af798 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php @@ -77,11 +77,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()) @@ -89,7 +89,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 fc03207e65..d38c195634 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php @@ -46,7 +46,7 @@ class ORMQueryBuilderLoaderTest extends TestCase { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder('QueryMock') + $query = $this->getMockBuilder(\QueryMock::class) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); @@ -59,7 +59,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(); @@ -79,7 +79,7 @@ class ORMQueryBuilderLoaderTest extends TestCase { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder('QueryMock') + $query = $this->getMockBuilder(\QueryMock::class) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); @@ -92,7 +92,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(); @@ -115,7 +115,7 @@ class ORMQueryBuilderLoaderTest extends TestCase { $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder('QueryMock') + $query = $this->getMockBuilder(\QueryMock::class) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); @@ -128,7 +128,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(); @@ -234,7 +234,7 @@ class ORMQueryBuilderLoaderTest extends TestCase $em = DoctrineTestHelper::createTestEntityManager(); - $query = $this->getMockBuilder('QueryMock') + $query = $this->getMockBuilder(\QueryMock::class) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); @@ -247,7 +247,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 458e835d5d..de92223b36 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -62,21 +62,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' => [[]]]; @@ -85,7 +85,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]]]; @@ -94,7 +94,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]]]; @@ -103,7 +103,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/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/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 9d4ebd7d75..f7501f255b 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/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 fedbb83482..d40b0beb38 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php @@ -26,7 +26,7 @@ class HttpCodeActivationStrategyTest extends TestCase */ public function testExclusionsWithoutCodeLegacy() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING); } @@ -35,7 +35,7 @@ class HttpCodeActivationStrategyTest extends TestCase */ public function testExclusionsWithoutUrlsLegacy() { - $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 628facbb21..905e6efb61 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 bca9ddfe5f..9874a469b7 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -344,7 +344,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 6c2dcb9b1e..70aa8eff4f 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -135,8 +135,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 76c1291fe7..7822364abd 100644 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php @@ -259,17 +259,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; @@ -394,7 +394,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/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/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 5676e8c91c..db96facd60 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -65,7 +65,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 b0696790bd..a718b8f9ab 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 237fb2fa99..807af30bd2 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 0d0933eb32..15082326ea 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 54b9b3e2a3..0310d6b2c1 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 cd6bcfb2a9..fe602c7c86 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 b9a239c31a..f8f8de111c 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 4603180858..54c8ec6c00 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php @@ -60,7 +60,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.'); } @@ -75,7 +75,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.'); } @@ -118,7 +118,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/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 16fde044ba..3061f34c91 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 a2cd6963d8..4144192d01 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 66a9515c2d..50ff0d1b52 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, @@ -91,7 +91,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/Bundle/FrameworkBundle/Command/AboutCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php index e39772edf4..4c9f968736 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php @@ -89,7 +89,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/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php index 9c3c005414..f460045ce0 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(): object { - $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/Command/CachePoolDeleteCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php index 42981c4148..dd434edd93 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(): object { $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 4df5fc024c..45e48f90da 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(): object { $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/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/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 447f48984b..a194581b33 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -82,7 +82,7 @@ class AbstractControllerTest extends TestCase 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/DependencyInjection/Compiler/ProfilerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index c9594b0b08..65f047426a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -34,7 +34,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 9ccecd881f..3a4af4b800 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -48,7 +48,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/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 4ce3f35c0b..cc5573d43d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php @@ -52,7 +52,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/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 9cb51f68a5..36b8379f4f 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -138,7 +138,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface $loader->load('security_debug.php'); } - 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'); } @@ -850,7 +850,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 f9d8094fbc..5d98b160df 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -597,7 +597,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'); } @@ -615,14 +615,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 4b1ddcf09c..4d82c6b59f 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 8dd7617d6d..baff9ef6e4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php @@ -42,7 +42,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); @@ -133,7 +133,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'], @@ -144,7 +144,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 7c3443a06d..8dbeb0c1e0 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -44,7 +44,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(); @@ -68,7 +68,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(); @@ -89,7 +89,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(); @@ -208,7 +208,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 8803bb422d..eb6eecc95f 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -23,23 +23,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(1); $loader = $container->getDefinition('twig.loader.native_filesystem'); @@ -103,7 +103,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/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/TemplateIteratorTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php index 0be5fc66a8..e0fedb5cae 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 46b8845614..7cf0554cac 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 0c81d82d7d..a11675fdf7 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 005ce9e434..2e196b2334 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -56,7 +56,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'); } @@ -97,12 +97,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(); $loader = $this->createMock(LoaderInterface::class); $loader @@ -117,7 +117,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/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index 120286cf0d..ae137ed9c3 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -88,7 +88,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'); } public function testGetResponseNull() @@ -296,7 +296,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'); } } @@ -355,7 +355,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'); } } @@ -406,7 +406,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'])); @@ -436,7 +436,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'); } } @@ -466,7 +466,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'])); @@ -749,7 +749,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'); } } @@ -837,7 +837,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()); } public function testInternalRequestNull() 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 5f99eb110d..a9b34139fb 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -104,7 +104,7 @@ class CookieTest extends TestCase public function testFromStringThrowsAnExceptionIfCookieIsNotValid() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); Cookie::fromString('foo'); } @@ -117,7 +117,7 @@ class CookieTest extends TestCase public function testFromStringThrowsAnExceptionIfUrlIsNotValid() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); Cookie::fromString('foo=bar', 'foobar'); } @@ -200,7 +200,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/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 9c230837a5..5ce26b9d7f 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/Traits/TagAwareTestTrait.php b/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php index fb237882dc..21119dece1 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/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index d29b6341b5..ad172038ea 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/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index f66432ef40..3e2d2fe7ee 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -23,14 +23,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']); @@ -38,7 +38,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')); @@ -49,7 +49,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')); @@ -198,7 +198,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'); @@ -208,7 +208,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'); @@ -221,7 +221,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(); @@ -298,7 +298,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')); @@ -316,7 +316,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 20ba6f35a2..9dc194cfca 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -45,7 +45,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); @@ -66,7 +66,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() @@ -77,7 +77,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([]) @@ -155,8 +155,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() @@ -320,7 +320,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 @@ -370,7 +370,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 58a2a4272b..59d04cc151 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 80705837ab..06a227ca3c 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 ab21226ae2..0d72d2b0c7 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/FileLocatorTest.php b/src/Symfony/Component/Config/Tests/FileLocatorTest.php index d4a990b5be..679a4bd68b 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 25d0199d3b..56d4cbee3c 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 d075764af2..4b0e4641f3 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 629cd0b3ff..2bbc95ee61 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 8a9f4cd009..94a62ebef5 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -135,7 +135,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'); @@ -146,7 +146,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'); @@ -205,7 +205,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()); @@ -230,7 +230,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() @@ -271,7 +271,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'); @@ -328,7 +328,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'); @@ -336,7 +336,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()); @@ -351,11 +351,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() @@ -364,10 +364,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() @@ -375,20 +375,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() @@ -398,11 +398,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'); } /** @@ -411,7 +411,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(); @@ -450,7 +450,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() @@ -459,8 +459,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() @@ -469,7 +469,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() @@ -477,7 +477,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')); } /** @@ -485,7 +485,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()); @@ -559,7 +559,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()); @@ -570,7 +570,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()); } @@ -583,7 +583,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()); } @@ -601,7 +601,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'); } @@ -612,7 +612,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"'); @@ -650,7 +650,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'); } @@ -659,8 +659,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()); @@ -696,7 +696,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()); @@ -705,7 +705,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']); @@ -715,7 +715,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()); @@ -728,8 +728,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')); } public function testFindAmbiguousCommandsIfAllAlternativesAreHidden() @@ -865,7 +865,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') @@ -937,8 +937,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); @@ -1069,7 +1069,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') @@ -1108,7 +1108,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') @@ -1145,7 +1145,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(); @@ -1173,7 +1173,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); @@ -1325,7 +1325,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()); @@ -1468,7 +1468,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()); @@ -1680,7 +1680,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'); @@ -1773,7 +1773,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/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 0e025af5c7..d6b44172a5 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 9b3c6ac8e3..68ea3413ef 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -677,7 +677,7 @@ EOD; 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', @@ -744,7 +744,7 @@ EOD; 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?')); @@ -752,7 +752,7 @@ EOD; 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'])); @@ -760,7 +760,7 @@ EOD; public function testAskThrowsExceptionOnMissingInputWithValidator() { - $this->expectException('Symfony\Component\Console\Exception\MissingInputException'); + $this->expectException(\Symfony\Component\Console\Exception\MissingInputException::class); $this->expectExceptionMessage('Aborted.'); $dialog = new QuestionHelper(); @@ -808,7 +808,7 @@ EOD; 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'); } @@ -941,7 +941,7 @@ EOD; 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 5d3ebe1708..98eed92129 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 4aa2ac8781..5ff28f19f4 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(31); diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 0337053e9c..9d462f7aa9 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -1015,7 +1015,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 @@ -1190,7 +1190,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()); @@ -1231,7 +1231,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'); @@ -1239,7 +1239,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 f0061aa3b1..e02b518f70 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -222,7 +222,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 ab3235314e..55d5fd3130 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(); @@ -264,7 +264,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(); @@ -283,7 +283,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(); @@ -328,7 +328,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 d92b9e7a07..0da54c77e9 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); } @@ -87,7 +87,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'); @@ -95,19 +95,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', '-'); } @@ -158,7 +158,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'); @@ -174,7 +174,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 a7c4b57105..8a31b676b0 100644 --- a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -160,7 +160,7 @@ class CommandTesterTest extends TestCase public function testCommandWithWrongInputsNumber() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Aborted.'); $questions = [ 'What\'s your name?', @@ -185,7 +185,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 420c33087d..4e8572aa49 100644 --- a/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php +++ b/src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php @@ -45,7 +45,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/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 5267f6fbb9..5669db3c4c 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -145,7 +145,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))->setDeprecated('symfony/dependency-injection', '5.1', $deprecationMessage = 'The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.'); $this->setAlias(ContainerInterface::class, new Alias('service_container', false))->setDeprecated('symfony/dependency-injection', '5.1', $deprecationMessage); @@ -1587,7 +1587,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 c91f8d58d2..f3091bd9ce 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -553,7 +553,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) { @@ -2051,7 +2051,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 61b4c5fa6c..c590526b6d 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -46,7 +46,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 4f5ec5c090..c6f5613553 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -723,7 +723,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 dd978fd466..e6eb6eb1fd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/AliasTest.php @@ -122,7 +122,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('package', '1.1', $message); } 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 bdcbf8d959..8f3329616e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -242,7 +242,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(); @@ -494,7 +494,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 19ff29dad8..28914f5c89 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php @@ -41,7 +41,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 @@ -54,7 +54,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(); @@ -84,7 +84,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(); @@ -97,7 +97,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 92e0510a6a..a74c203d9f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php @@ -152,7 +152,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); } @@ -176,7 +176,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 612f49fd50..e8a1fbb2a9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php @@ -37,7 +37,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')); } @@ -113,7 +113,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 902fe4eaa9..3e8fb332e5 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 ee5b386932..31469499bf 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 b20a5836c6..d7b0a280c1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php @@ -54,7 +54,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 cbf21c7925..a6d9d430a5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php @@ -408,7 +408,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 9357e848d0..ea8a4c33e9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php @@ -56,7 +56,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 5c3f049234..5b78f50ab2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -43,7 +43,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'); @@ -72,7 +72,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()); @@ -87,7 +87,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()); @@ -100,7 +100,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); @@ -152,7 +152,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()); @@ -165,7 +165,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 fd6a2a88f3..dadd30d0f9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -116,7 +116,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() @@ -140,7 +140,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'); @@ -155,7 +155,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'); @@ -207,7 +207,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'); } @@ -217,7 +217,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')); } @@ -236,7 +236,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); @@ -383,8 +383,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); @@ -398,8 +398,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() @@ -535,7 +535,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'); @@ -576,7 +576,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')); @@ -591,7 +591,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() @@ -655,7 +655,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(); @@ -760,7 +760,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"}'); @@ -773,7 +773,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)%'); @@ -869,7 +869,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%'); @@ -886,7 +886,7 @@ class ContainerBuilderTest extends TestCase public function testMergeLogicException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $container = new ContainerBuilder(); $container->setResourceTracking(false); $container->compile(); @@ -951,7 +951,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())); } @@ -1063,13 +1063,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'); @@ -1081,7 +1081,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']]); @@ -1105,12 +1105,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); @@ -1139,7 +1139,7 @@ class ContainerBuilderTest extends TestCase public function testThrowsExceptionWhenSetDefinitionOnACompiledContainer() { - $this->expectException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); $container = new ContainerBuilder(); $container->setResourceTracking(false); $container->compile(); @@ -1233,7 +1233,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(); @@ -1289,7 +1289,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(); @@ -1299,7 +1299,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(); @@ -1309,7 +1309,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(); @@ -1319,7 +1319,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(); @@ -1329,7 +1329,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(); @@ -1475,7 +1475,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() @@ -1592,7 +1592,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 ce002a6f1e..e32598ced6 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'; @@ -329,7 +329,7 @@ class ContainerTest extends TestCase public function testGetThrowsException() { - $this->expectException('Exception'); + $this->expectException(\Exception::class); $this->expectExceptionMessage('Something went terribly wrong!'); $c = new ProjectServiceContainer(); @@ -382,7 +382,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()); @@ -397,7 +397,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 0ebe8c49bf..f8120261ec 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -84,7 +84,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'); @@ -120,7 +120,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(''); @@ -207,7 +207,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('vendor/package', '1.1', $message); } @@ -292,7 +292,7 @@ class DefinitionTest extends TestCase public function testGetArgumentShouldCheckBounds() { - $this->expectException('OutOfBoundsException'); + $this->expectException(\OutOfBoundsException::class); $def = new Definition('stdClass'); $def->addArgument('foo'); @@ -301,7 +301,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'); @@ -311,7 +311,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 2d9a7a2115..ce1395773b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -169,7 +169,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); @@ -196,7 +196,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); @@ -381,7 +381,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'); @@ -449,7 +449,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'; @@ -666,7 +666,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)'); @@ -677,7 +677,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%'); @@ -827,11 +827,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; } } @@ -967,7 +967,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() @@ -1275,7 +1275,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 452fb79727..79183032f8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php @@ -40,7 +40,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 34dbe43c5b..237a6dd3f2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php @@ -214,7 +214,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')); @@ -225,7 +225,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/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/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 7764231fa6..a9ff6127d0 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php @@ -81,14 +81,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'); @@ -250,7 +250,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'); @@ -276,7 +276,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'); } @@ -284,7 +284,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'); @@ -297,7 +297,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'); } @@ -406,7 +406,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'); @@ -573,7 +573,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'); @@ -626,7 +626,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'); @@ -645,7 +645,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'); @@ -656,7 +656,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'); @@ -713,7 +713,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'); @@ -730,7 +730,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(); @@ -738,7 +738,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(); @@ -747,7 +747,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(); @@ -823,8 +823,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'); @@ -842,7 +842,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(); @@ -852,7 +852,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()); } @@ -861,7 +861,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()); } @@ -870,7 +870,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()); @@ -993,7 +993,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()); @@ -1011,7 +1011,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()); @@ -1029,7 +1029,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()); @@ -1094,7 +1094,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()); @@ -1219,7 +1219,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/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index 2c216cbe7f..f896fba2da 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/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 4239be1ed3..6ced55c069 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 da28110516..bf2cebf6c0 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', []); @@ -180,7 +180,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/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php index 6ac335199a..12cb47a866 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 99575f9f62..ca41d3f93d 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php @@ -21,7 +21,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([]); @@ -30,7 +30,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([]); @@ -198,7 +198,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); @@ -228,7 +228,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 4158f88f85..c901bdc9bd 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'); } @@ -637,7 +637,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'; @@ -652,7 +652,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'; @@ -667,7 +667,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'; @@ -770,7 +770,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'; @@ -785,7 +785,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'; @@ -800,7 +800,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'; @@ -823,7 +823,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'; @@ -849,7 +849,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'; @@ -1194,14 +1194,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')); } @@ -1475,7 +1475,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; @@ -1498,7 +1498,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.'); @@ -1515,7 +1515,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 97e8aa4a07..ebcb0bff1f 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() @@ -922,14 +922,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'); } @@ -944,7 +944,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*'); } @@ -963,7 +963,7 @@ class FinderTest extends Iterator\RealIteratorTestCase public function testGetIteratorWithoutIn() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $finder = Finder::create(); $finder->getIterator(); } @@ -1104,7 +1104,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() @@ -1143,7 +1143,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 c127862e53..08658ddfb7 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 0afa3d4e43..391a425ddd 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php @@ -114,7 +114,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 4931ccb6a3..bd7107de01 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 49d7f1887b..aadba95802 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/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/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index c59b3840a5..8b0564d2d7 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -252,7 +252,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); @@ -261,7 +261,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 e94261cd57..afbf357263 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); } @@ -110,7 +110,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') @@ -160,7 +160,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') @@ -174,7 +174,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') @@ -188,7 +188,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') @@ -202,7 +202,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') @@ -217,7 +217,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') @@ -231,7 +231,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') @@ -245,7 +245,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') @@ -259,7 +259,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') @@ -273,7 +273,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') @@ -287,7 +287,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') @@ -301,7 +301,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') @@ -316,7 +316,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') @@ -330,7 +330,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') @@ -344,7 +344,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 9b3f4644c2..586a488d2d 100644 --- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php @@ -86,7 +86,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]); @@ -141,7 +141,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/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 fd3e93a6d7..182161c1e4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php @@ -189,7 +189,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); @@ -197,7 +197,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'); @@ -208,7 +208,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); @@ -228,7 +228,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'); @@ -236,7 +236,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'); @@ -244,7 +244,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('∞'); @@ -252,7 +252,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 cb94ca785d..0fab26b70e 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 41b927d04a..248fc83555 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/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 d5d3a407a1..7f10108587 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 f6018b19a6..491fc3755d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -88,7 +88,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(), ]); @@ -96,7 +96,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(), ]); @@ -104,7 +104,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() @@ -1820,7 +1820,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 3fb2d75815..61170f4103 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -38,8 +38,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()); @@ -49,7 +49,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()); @@ -62,7 +62,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 a924df59ed..654827d0e8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -323,7 +323,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 a10d407a66..06b19a725a 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 c8c2a70c10..50d178a510 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php @@ -194,7 +194,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 c31f6f8682..7a5a604010 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -660,7 +660,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() @@ -857,7 +857,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, @@ -866,7 +866,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', ]); @@ -874,7 +874,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', ]); @@ -882,7 +882,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', ]); @@ -890,7 +890,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/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 b32e217377..03072f83d4 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 53ecc1cb06..fc4e39d0a6 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); } @@ -40,10 +40,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 9d2eeaae1c..760f8da14e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php @@ -132,7 +132,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()); } @@ -150,7 +150,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']); @@ -160,7 +160,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()); } @@ -168,7 +168,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']); @@ -178,7 +178,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()); } @@ -200,7 +200,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/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/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 8c85fd84ff..f3f27ffef5 100644 --- a/src/Symfony/Component/Form/Tests/FormRendererTest.php +++ b/src/Symfony/Component/Form/Tests/FormRendererTest.php @@ -19,7 +19,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/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 744198f95f..f9fc9746f3 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) @@ -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/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 74be4c101d..f5891d3c53 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -2000,7 +2000,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 31d6bc2c00..ccd3827c06 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -71,7 +71,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 64136b53fc..749cc1f8bd 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); } @@ -66,13 +66,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 208189c2f6..10f62a1fc2 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); @@ -118,7 +118,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/UploadedFileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php index 50374aa081..e558870a92 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 89fdf82ac2..50546311a9 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 8d425d4df8..2b585a95d4 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/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index a1cff9d2fd..ee6f87e7f9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -917,7 +917,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(); @@ -1086,7 +1086,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 = [ @@ -1848,7 +1848,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/Session/SessionTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php index 32bf02fe59..3bb01d2063 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 c5b4395031..e9471a5414 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/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 6f04271856..4a58bca442 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'); } @@ -108,19 +108,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 c3ca8ee520..bc334e1d81 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -50,7 +50,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 0eaa2c197c..c4fa66ee8d 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -696,7 +696,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()); } @@ -714,7 +714,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 eeb39e4dca..28b7bdee06 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/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 2b635556e5..61d28c3cee 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 d394c3bce4..d822299ac7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php @@ -158,7 +158,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()) @@ -182,7 +182,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 308a20127a..d6753cb31b 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 deda5c868d..9347073be2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -42,12 +42,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()); @@ -57,7 +57,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()); @@ -371,7 +371,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 0fa6fcde51..da6fbeb435 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/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 12df187571..7663fb2946 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -36,7 +36,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(); @@ -68,7 +68,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 ); @@ -92,7 +92,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); @@ -122,7 +122,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 408b580630..a11361419c 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/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/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/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 0f0a25ef1c..3193b954be 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 b64924745b..f8fa84dbba 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 b1d225b84e..50b14e9dd4 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -32,7 +32,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); @@ -40,7 +40,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); @@ -157,7 +157,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); @@ -304,7 +304,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'); @@ -316,7 +316,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 038f73230e..37b990f360 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -66,7 +66,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. @@ -112,7 +112,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'); @@ -154,7 +154,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'); @@ -166,7 +166,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( @@ -189,7 +189,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 @@ -211,7 +211,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(); @@ -338,25 +338,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()) @@ -400,7 +400,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'); @@ -434,7 +434,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(); @@ -613,7 +613,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 29067f558b..ccf410c447 100644 --- a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php +++ b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php @@ -22,20 +22,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); } @@ -80,14 +80,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 24ac5ee1af..2f04e68024 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php @@ -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/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 34414b1f74..2a83a88ac2 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -39,7 +39,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); } @@ -69,7 +69,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()); } @@ -77,7 +77,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); @@ -85,7 +85,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([]); } @@ -110,14 +110,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)); @@ -125,27 +125,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/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 99c095977d..b9deeef3df 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -606,7 +606,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(); @@ -623,7 +623,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 eef55abc9f..a6cf8a6c74 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php @@ -24,32 +24,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, 100); } 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); } @@ -67,7 +67,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest public function testFormatWithCurrencyStyle() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); parent::testFormatWithCurrencyStyle(); } @@ -76,7 +76,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); } @@ -85,7 +85,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); } @@ -94,7 +94,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); } @@ -103,7 +103,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); } @@ -112,7 +112,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); } @@ -121,13 +121,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(); } @@ -140,7 +140,7 @@ 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); $currency = 'USD'; $formatter->parseCurrency(3, $currency); @@ -148,21 +148,21 @@ class NumberFormatterTest extends AbstractNumberFormatterTest 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('#0'); } 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(NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '*'); } 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(NumberFormatter::NEGATIVE_PREFIX, '-'); } 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 f969fead7c..b312fe1234 100644 --- a/src/Symfony/Component/Lock/Tests/LockTest.php +++ b/src/Symfony/Component/Lock/Tests/LockTest.php @@ -298,7 +298,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); @@ -319,7 +319,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); @@ -340,7 +340,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 1dbede1920..9431c2dcd7 100644 --- a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php @@ -73,7 +73,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 @@ -168,7 +168,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/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 4c1b2d8259..fb87944a00 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 d1bfab528f..454493f1ef 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 ed696af03c..3da46f4a56 100644 --- a/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php @@ -45,7 +45,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/Bridge/Amqp/Tests/Transport/AmqpReceiverTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpReceiverTest.php index 9116a3682e..ded34544f9 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpReceiverTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/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/Bridge/Amqp/Tests/Transport/AmqpSenderTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpSenderTest.php index 47f47eeb7b..4a9637f78d 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/AmqpSenderTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/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/Bridge/Amqp/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php index 6c7273977e..543494acfb 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php @@ -32,7 +32,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://:'); } @@ -567,7 +567,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/Bridge/Doctrine/Tests/Transport/DoctrineReceiverTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineReceiverTest.php index 6e774ec719..43a0772371 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineReceiverTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/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/Bridge/Doctrine/Tests/Transport/DoctrineTransportFactoryTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineTransportFactoryTest.php index b423c21e27..b74b826392 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineTransportFactoryTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineTransportFactoryTest.php @@ -57,7 +57,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/Messenger/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php index 92d6b855d5..27ded7f46d 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php @@ -155,7 +155,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 09e19ae0e6..1b1ccb5f02 100644 --- a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php +++ b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php @@ -156,7 +156,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'); @@ -256,7 +256,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'); @@ -270,7 +270,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'); @@ -400,7 +400,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 @@ -413,7 +413,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 @@ -426,7 +426,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 @@ -439,7 +439,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 @@ -452,7 +452,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 @@ -465,7 +465,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 @@ -478,7 +478,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 @@ -491,7 +491,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 @@ -504,7 +504,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 @@ -583,7 +583,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', [ @@ -595,7 +595,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/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/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/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/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php b/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php index 9b46ece52f..5f97a97122 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(); @@ -269,7 +269,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'); @@ -280,7 +280,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/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/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/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 4d1c516b49..822a7a4b89 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php @@ -38,11 +38,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()); } @@ -74,7 +74,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 cbc4c097f3..65afd4f3f4 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -253,7 +253,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); @@ -267,7 +267,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/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 912c1f8b0c..50e75b5fd4 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/PhpFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php index f1d03b0c82..c434b254be 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 2f628c4f94..02a77af2e9 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')); @@ -215,7 +215,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); } @@ -225,7 +225,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); } @@ -237,7 +237,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'); @@ -445,7 +445,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'); @@ -477,7 +477,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 10ca522d7e..f7c3299c5a 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')); @@ -144,7 +144,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'); @@ -176,7 +176,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 72d26933ef..4886d71768 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/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 8d4729e135..97cd237850 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php @@ -26,8 +26,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') @@ -44,7 +44,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); @@ -54,7 +54,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(); @@ -80,7 +80,7 @@ class RouteCollectionBuilderTest extends TestCase public function testImportWithoutLoaderThrowsException() { - $this->expectException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); $collectionBuilder = new RouteCollectionBuilder(); $collectionBuilder->import('routing.yml'); } @@ -91,7 +91,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(); @@ -104,7 +104,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') @@ -267,7 +267,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'); @@ -345,7 +345,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 07fa2bb62b..6f5b91f572 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 c07cb3324a..812094dbb8 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -137,7 +137,7 @@ class RouteTest extends TestCase */ public function testSetInvalidRequirement($req) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $route = new Route('/{foo}'); $route->setRequirement('foo', $req); } @@ -198,7 +198,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/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 41dc885dcf..d4e144484e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php @@ -91,17 +91,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/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/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/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php index 58ecff77bf..4519146562 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 0593c9f974..7c6961ce58 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/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php index 12e78ad460..7228af7656 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php @@ -26,8 +26,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( @@ -70,7 +70,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/VoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php index dc1d391477..7899b6a60b 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/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/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/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 460e118ece..d4abf8f3f3 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php @@ -121,8 +121,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(); @@ -133,7 +133,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()) @@ -152,12 +152,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()) @@ -172,7 +172,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') @@ -184,7 +184,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/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 1e6d9d8995..129df28c3b 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 e078a6be12..6309462cc1 100644 --- a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php @@ -190,7 +190,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/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 9a423f3dfe..e9b8ce51e6 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->setFirewallName('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/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 6aaf3c6628..91bed331fa 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php @@ -32,10 +32,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') @@ -43,21 +43,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') @@ -69,7 +69,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)); @@ -79,7 +79,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') @@ -87,21 +87,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') @@ -109,7 +109,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') @@ -121,7 +121,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') @@ -143,7 +143,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') @@ -151,13 +151,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') @@ -166,9 +166,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)); @@ -206,8 +206,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') @@ -226,9 +226,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)); @@ -328,7 +328,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') @@ -336,7 +336,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') @@ -346,7 +346,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 020871ef1d..8bb3420447 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/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/UsernamePasswordJsonAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php index cc31cc8d51..da57ddefd6 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php @@ -129,7 +129,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(); @@ -141,7 +141,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"}'); @@ -152,7 +152,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"}'); @@ -163,7 +163,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"}'); @@ -174,7 +174,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}'); @@ -244,7 +244,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)); @@ -256,7 +256,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 0afb660b85..f4b98fdd98 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php @@ -20,18 +20,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') @@ -39,7 +39,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); @@ -57,7 +57,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') @@ -67,8 +67,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() @@ -79,7 +79,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); @@ -87,19 +87,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 2b74b8ccb0..84fd3dafc8 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php @@ -22,10 +22,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 539ff4c50e..4ea8fa1604 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 7694454304..f8da09a941 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/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 34a6a8ef15..1f5bb3356a 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 68b6f1e3b5..bb9dc3c2f5 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 88c47b6d4f..98024410cc 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -71,7 +71,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'); } @@ -665,19 +665,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 923d8fc39d..87c3ebfd22 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 3034eb4c4a..7ba03dedc2 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 0f7868c09d..973a728e28 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php @@ -35,7 +35,7 @@ abstract 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 8a5e0e13f7..1d41ff1344 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php @@ -44,7 +44,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 2e708665f5..1fc3946dad 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php @@ -45,7 +45,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() @@ -61,7 +61,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 250f6be40e..119edfbfb9 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 1985911ea6..dec6c47b58 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php @@ -40,8 +40,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 55fced0ab3..de88d07813 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( @@ -351,7 +351,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/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 282d8a899f..ffe6374e2d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php @@ -69,7 +69,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()); } @@ -104,26 +104,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 b77e34c619..a041074b84 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php @@ -157,7 +157,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()); } @@ -236,27 +236,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 c16bf1ee1f..5c77f33a51 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -73,8 +73,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() @@ -364,9 +364,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/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index e30fd27e8d..b4d54cf3e4 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -244,7 +244,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, @@ -519,9 +519,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(); @@ -583,7 +583,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 663eacc3ef..991943beb0 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -68,7 +68,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); } @@ -327,9 +327,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 7a6562c235..9260300eea 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -57,11 +57,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); } public function testItThrowsExceptionOnInvalidNormalizer() @@ -82,8 +82,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'); } @@ -103,21 +103,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')); @@ -134,14 +134,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'); @@ -157,14 +157,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'); @@ -214,7 +214,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'); @@ -222,7 +222,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'); @@ -248,7 +248,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'); @@ -256,7 +256,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'); @@ -264,7 +264,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'); @@ -472,14 +472,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 f2aa3e7273..82b3c832a7 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 46febca324..45eada7f3c 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 6d133415d0..3459ba093b 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 bfe6933f5b..c6676fcde5 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 ac589c975e..0b21e8c830 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, string $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 60c5b348e8..2ffba392d5 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 0b7168181d..2a1aecc601 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 9aa30bd652..64bbd3e14f 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 aa89e03978..9cf2fe9760 100644 --- a/src/Symfony/Component/Translation/Loader/QtFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/QtFileLoader.php @@ -70,7 +70,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 dc7e936860..f573dfe4c7 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -46,7 +46,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 d9801a8fa1..3b630911ee 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/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 28c91229b0..ace7b84d5a 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/MessageCatalogueTest.php b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php index d4090b1520..151fb2dc6b 100644 --- a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php @@ -126,10 +126,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']]); @@ -150,13 +150,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']]); @@ -179,7 +179,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'); @@ -189,7 +189,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'); @@ -201,7 +201,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', [])); } @@ -209,11 +209,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/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index a22dcc969f..86ef327aff 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -105,7 +105,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') @@ -252,8 +252,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)) @@ -309,7 +309,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/Writer/TranslationWriterTest.php b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php index 3ea5ca779f..5723ec4fa5 100644 --- a/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php +++ b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php @@ -19,7 +19,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 78aa1cfa3c..f976513ba1 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, int $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/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 38d7076cf2..73af627ac2 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 816fca1de4..786b90f7ec 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php @@ -147,7 +147,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', @@ -182,7 +182,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 86a1af88da..71b6b717ea 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 b8571c5f81..ea169e9726 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 6616457313..c27792fcef 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php @@ -37,7 +37,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 27d83fea27..8f49b7f804 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 f2ca4b5a10..840cb96866 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 438957af74..37c80efd95 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -38,7 +38,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 ed97ece8e5..4aa4990c51 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -38,7 +38,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 84da112693..471578bb49 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php @@ -27,7 +27,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']); } @@ -41,14 +41,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 7a2829f629..d631bad0e6 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -27,7 +27,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'); } @@ -55,7 +55,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()); } @@ -224,7 +224,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/FileTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php index aea824cfda..31227bb737 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php @@ -57,7 +57,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; } @@ -82,7 +82,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 9894bf266c..36987b26a4 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', ]); @@ -307,7 +307,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 @@ -331,7 +331,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 @@ -358,7 +358,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase public function testInvalidMimeType(File $constraint) { $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') + ->getMockBuilder(\Symfony\Component\HttpFoundation\File\File::class) ->setConstructorArgs([__DIR__.'/Fixtures/foo']) ->getMock(); $file @@ -398,7 +398,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 @@ -486,7 +486,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 c614572ae1..34dc92eca1 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 471f7016e6..50aea4f7a0 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 96f1a8139c..1f089088ed 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php @@ -287,7 +287,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', ]); @@ -297,7 +297,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', ]); @@ -307,7 +307,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', ]); @@ -317,7 +317,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', ]); @@ -327,7 +327,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', ]); @@ -337,7 +337,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', ]); @@ -414,7 +414,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', ]); @@ -424,7 +424,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 f9313f9985..459bad5b87 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php @@ -30,14 +30,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 29ae46dacc..1597637611 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 57d087937d..e1a3b1d3c6 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 83b112dfcc..7ba0593f43 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 d17d597e72..ae3afaa56c 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 7748b3063f..34a97b81d7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php @@ -33,14 +33,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']); } 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()]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php index 66633d8db9..9e78bbb695 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 41ca8ded52..0b850b90ce 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/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 0a3ae6b346..a3be128146 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php @@ -49,14 +49,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 868040fafb..6c3438e16d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php @@ -165,19 +165,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/RegexTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php index 909f3e1f2e..db7b406c58 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php @@ -97,14 +97,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 384c0ec36c..d64b7e50be 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 bb447583fe..6d79135520 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -38,7 +38,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 cc4666f170..85c93cbe13 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php @@ -36,7 +36,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', @@ -45,7 +45,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']); } @@ -54,7 +54,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 9e3e4e2f2f..17e088f174 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 ee05aa0b88..19e8531772 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 6fad1a832f..ab6ffeeb69 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php @@ -30,14 +30,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/UuidTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php index d5843d569b..bfa4615bc7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php @@ -30,14 +30,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 7bb500dcaa..0436ee15b7 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 16cce5fbb1..d7114265fb 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php @@ -49,14 +49,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()); } @@ -270,24 +270,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']); @@ -295,7 +295,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); @@ -303,7 +303,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/Loader/FilesLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php index 641aa977c1..c7e89d5a3b 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php @@ -35,7 +35,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', @@ -45,6 +45,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 979b7cfa61..1813019b43 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php @@ -45,7 +45,7 @@ class YamlFileLoaderTest extends TestCase */ public function testInvalidYamlFiles($path) { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $loader = new YamlFileLoader(__DIR__.'/'.$path); $metadata = new ClassMetadata(Entity::class); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php index a82ebae9e7..6793187363 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php @@ -44,7 +44,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 abeb2c5bf1..5739da6ed5 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php @@ -27,7 +27,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'); } @@ -55,7 +55,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 6866a88084..af61c68ac4 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php @@ -544,7 +544,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'; @@ -799,7 +799,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(); @@ -1667,7 +1667,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)); @@ -1902,7 +1902,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'); } @@ -1933,8 +1933,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') @@ -2076,7 +2076,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') @@ -2084,7 +2084,7 @@ class RecursiveValidatorTest extends TestCase ->willReturnSelf(); $validator = $this - ->getMockBuilder('Symfony\Component\Validator\Validator\RecursiveValidator') + ->getMockBuilder(RecursiveValidator::class) ->disableOriginalConstructor() ->setMethods(['startContext']) ->getMock(); @@ -2110,7 +2110,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') @@ -2118,7 +2118,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/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 e5f2cb84ae..a5d059ce23 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -27,7 +27,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 1361fa4554..8fb269805b 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 7eb60be917..228378441f 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/RegistryTest.php b/src/Symfony/Component/Workflow/Tests/RegistryTest.php index 701b7456d0..45f0483fc7 100644 --- a/src/Symfony/Component/Workflow/Tests/RegistryTest.php +++ b/src/Symfony/Component/Workflow/Tests/RegistryTest.php @@ -55,7 +55,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); @@ -64,7 +64,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/Yaml/Tests/Command/LintCommandTest.php b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php index 3750c61205..3eabbdc41e 100644 --- a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php @@ -144,7 +144,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 261e430449..acbde08ae1 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -69,14 +69,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); } @@ -120,60 +120,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); } @@ -219,14 +219,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 }'); } @@ -613,7 +613,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); @@ -631,7 +631,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}'); } @@ -648,7 +648,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}'); } @@ -679,7 +679,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)); } @@ -732,7 +732,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 feec99984a..6bf904a067 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 @@ -564,14 +564,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: @@ -586,7 +586,7 @@ EOF; public function testShortcutKeyUnindentedCollectionException() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $yaml = <<<'EOF' collection: @@ -600,7 +600,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 @@ -619,7 +619,7 @@ EOL public function testSequenceInAMapping() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); Yaml::parse(<<<'EOF' yaml: hash: me @@ -727,7 +727,7 @@ EOT; */ public function testParseExceptionNotAffectedByMultiLineStringLastResortParsing($yaml) { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->parser->parse($yaml); } @@ -759,7 +759,7 @@ EOT; public function testMappingInASequence() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); Yaml::parse(<<<'EOF' yaml: - array stuff @@ -770,7 +770,7 @@ EOF public function testScalarInSequence() { - $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); + $this->expectException(ParseException::class); $this->expectExceptionMessage('missing colon'); Yaml::parse(<<<'EOF' foo: @@ -793,7 +793,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: @@ -813,7 +813,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 } @@ -832,7 +832,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); @@ -1058,7 +1058,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: @@ -1071,7 +1071,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 @@ -1108,7 +1108,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 @@ -1346,7 +1346,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); @@ -2168,35 +2168,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'); @@ -2497,7 +2497,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 4d84f4729f..ffaf877f04 100644 --- a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php +++ b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php @@ -163,7 +163,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]);