Merge branch '5.2' into 5.x

* 5.2:
  Use ::class keyword when possible
This commit is contained in:
Fabien Potencier 2021-01-11 10:52:33 +01:00
commit 91d8bebfac
604 changed files with 2270 additions and 2270 deletions

View File

@ -48,7 +48,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames()); $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) { $properties = array_filter($properties, function ($property) {
return false === strpos($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'])]; return [new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])];
} }

View File

@ -229,7 +229,7 @@ EOTXT
private function createCollector($queries) private function createCollector($queries)
{ {
$connection = $this->getMockBuilder('Doctrine\DBAL\Connection') $connection = $this->getMockBuilder(\Doctrine\DBAL\Connection::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$connection->expects($this->any()) $connection->expects($this->any())
@ -249,7 +249,7 @@ EOTXT
->method('getConnection') ->method('getConnection')
->willReturn($connection); ->willReturn($connection);
$logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock(); $logger = $this->getMockBuilder(\Doctrine\DBAL\Logging\DebugStack::class)->getMock();
$logger->queries = $queries; $logger->queries = $queries;
$collector = new DoctrineDataCollector($registry); $collector = new DoctrineDataCollector($registry);

View File

@ -19,7 +19,7 @@ class ContainerAwareLoaderTest extends TestCase
{ {
public function testShouldSetContainerOnContainerAwareFixture() public function testShouldSetContainerOnContainerAwareFixture()
{ {
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
$loader = new ContainerAwareLoader($container); $loader = new ContainerAwareLoader($container);
$fixture = new ContainerAwareFixture(); $fixture = new ContainerAwareFixture();

View File

@ -23,7 +23,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
{ {
public function testExceptionOnAbstractTaggedSubscriber() public function testExceptionOnAbstractTaggedSubscriber()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$container = $this->createBuilder(); $container = $this->createBuilder();
$abstractDefinition = new Definition('stdClass'); $abstractDefinition = new Definition('stdClass');
@ -37,7 +37,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
public function testExceptionOnAbstractTaggedListener() public function testExceptionOnAbstractTaggedListener()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$container = $this->createBuilder(); $container = $this->createBuilder();
$abstractDefinition = new Definition('stdClass'); $abstractDefinition = new Definition('stdClass');

View File

@ -11,7 +11,7 @@ class RegisterMappingsPassTest extends TestCase
{ {
public function testNoDriverParmeterException() 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"'); $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(); $container = $this->createBuilder();
$this->process($container, [ $this->process($container, [

View File

@ -31,7 +31,7 @@ class DoctrineExtensionTest extends TestCase
parent::setUp(); parent::setUp();
$this->extension = $this $this->extension = $this
->getMockBuilder('Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension') ->getMockBuilder(\Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension::class)
->setMethods([ ->setMethods([
'getMappingResourceConfigDirectory', 'getMappingResourceConfigDirectory',
'getObjectManagerElementName', 'getObjectManagerElementName',
@ -52,7 +52,7 @@ class DoctrineExtensionTest extends TestCase
public function testFixManagersAutoMappingsWithTwoAutomappings() public function testFixManagersAutoMappingsWithTwoAutomappings()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$emConfigs = [ $emConfigs = [
'em1' => [ 'em1' => [
'auto_mapping' => true, 'auto_mapping' => true,
@ -235,7 +235,7 @@ class DoctrineExtensionTest extends TestCase
public function testUnrecognizedCacheDriverException() public function testUnrecognizedCacheDriverException()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('"unrecognized_type" is an unrecognized Doctrine cache driver.'); $this->expectExceptionMessage('"unrecognized_type" is an unrecognized Doctrine cache driver.');
$cacheName = 'metadata_cache'; $cacheName = 'metadata_cache';
$container = $this->createContainer(); $container = $this->createContainer();

View File

@ -77,11 +77,11 @@ class DoctrineChoiceLoaderTest extends TestCase
protected function setUp(): void 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->om = $this->getMockBuilder(ObjectManager::class)->getMock();
$this->repository = $this->getMockBuilder(ObjectRepository::class)->getMock(); $this->repository = $this->getMockBuilder(ObjectRepository::class)->getMock();
$this->class = 'stdClass'; $this->class = 'stdClass';
$this->idReader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader') $this->idReader = $this->getMockBuilder(IdReader::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->idReader->expects($this->any()) $this->idReader->expects($this->any())
@ -89,7 +89,7 @@ class DoctrineChoiceLoaderTest extends TestCase
->willReturn(true) ->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->obj1 = (object) ['name' => 'A'];
$this->obj2 = (object) ['name' => 'B']; $this->obj2 = (object) ['name' => 'B'];
$this->obj3 = (object) ['name' => 'C']; $this->obj3 = (object) ['name' => 'C'];

View File

@ -46,7 +46,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
{ {
$em = DoctrineTestHelper::createTestEntityManager(); $em = DoctrineTestHelper::createTestEntityManager();
$query = $this->getMockBuilder('QueryMock') $query = $this->getMockBuilder(\QueryMock::class)
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
->getMock(); ->getMock();
@ -59,7 +59,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2], $expectedType) ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2], $expectedType)
->willReturn($query); ->willReturn($query);
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
->setConstructorArgs([$em]) ->setConstructorArgs([$em])
->setMethods(['getQuery']) ->setMethods(['getQuery'])
->getMock(); ->getMock();
@ -79,7 +79,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
{ {
$em = DoctrineTestHelper::createTestEntityManager(); $em = DoctrineTestHelper::createTestEntityManager();
$query = $this->getMockBuilder('QueryMock') $query = $this->getMockBuilder(\QueryMock::class)
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
->getMock(); ->getMock();
@ -92,7 +92,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2, 3, '9223372036854775808'], Connection::PARAM_INT_ARRAY) ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2, 3, '9223372036854775808'], Connection::PARAM_INT_ARRAY)
->willReturn($query); ->willReturn($query);
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
->setConstructorArgs([$em]) ->setConstructorArgs([$em])
->setMethods(['getQuery']) ->setMethods(['getQuery'])
->getMock(); ->getMock();
@ -115,7 +115,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
{ {
$em = DoctrineTestHelper::createTestEntityManager(); $em = DoctrineTestHelper::createTestEntityManager();
$query = $this->getMockBuilder('QueryMock') $query = $this->getMockBuilder(\QueryMock::class)
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
->getMock(); ->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) ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'], Connection::PARAM_STR_ARRAY)
->willReturn($query); ->willReturn($query);
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
->setConstructorArgs([$em]) ->setConstructorArgs([$em])
->setMethods(['getQuery']) ->setMethods(['getQuery'])
->getMock(); ->getMock();
@ -234,7 +234,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
$em = DoctrineTestHelper::createTestEntityManager(); $em = DoctrineTestHelper::createTestEntityManager();
$query = $this->getMockBuilder('QueryMock') $query = $this->getMockBuilder(\QueryMock::class)
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
->getMock(); ->getMock();
@ -247,7 +247,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', [1, 2, 3], Connection::PARAM_INT_ARRAY) ->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', [1, 2, 3], Connection::PARAM_INT_ARRAY)
->willReturn($query); ->willReturn($query);
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') $qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
->setConstructorArgs([$em]) ->setConstructorArgs([$em])
->setMethods(['getQuery']) ->setMethods(['getQuery'])
->getMock(); ->getMock();

View File

@ -64,7 +64,7 @@ class CollectionToArrayTransformerTest extends TestCase
public function testTransformExpectsArrayOrCollection() public function testTransformExpectsArrayOrCollection()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$this->transformer->transform('Foo'); $this->transformer->transform('Foo');
} }

View File

@ -62,21 +62,21 @@ class DoctrineOrmTypeGuesserTest extends TestCase
$return = []; $return = [];
// Simple field, not nullable // 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->fieldMappings['field'] = true;
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false); $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false);
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
// Simple field, nullable // Simple field, nullable
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->getMock();
$classMetadata->fieldMappings['field'] = true; $classMetadata->fieldMappings['field'] = true;
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true); $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true);
$return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)];
// One-to-one, nullable (by default) // 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); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
$mapping = ['joinColumns' => [[]]]; $mapping = ['joinColumns' => [[]]];
@ -85,7 +85,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
// One-to-one, nullable (explicit) // 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); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
$mapping = ['joinColumns' => [['nullable' => true]]]; $mapping = ['joinColumns' => [['nullable' => true]]];
@ -94,7 +94,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
// One-to-one, not nullable // 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); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
$mapping = ['joinColumns' => [['nullable' => false]]]; $mapping = ['joinColumns' => [['nullable' => false]]];
@ -103,7 +103,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
// One-to-many, no clue // 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); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false);
$return[] = [$classMetadata, null]; $return[] = [$classMetadata, null];

View File

@ -32,7 +32,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
{ {
$this->collection = new ArrayCollection(['test']); $this->collection = new ArrayCollection(['test']);
$this->dispatcher = new EventDispatcher(); $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() $this->form = $this->getBuilder()
->getForm(); ->getForm();
} }

View File

@ -21,10 +21,10 @@ class DbalLoggerTest extends TestCase
*/ */
public function testLog($sql, $params, $logParams) public function testLog($sql, $params, $logParams)
{ {
$logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder(DbalLogger::class)
->setConstructorArgs([$logger, null]) ->setConstructorArgs([$logger, null])
->setMethods(['log']) ->setMethods(['log'])
->getMock() ->getMock()
@ -53,10 +53,10 @@ class DbalLoggerTest extends TestCase
public function testLogNonUtf8() public function testLogNonUtf8()
{ {
$logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder(DbalLogger::class)
->setConstructorArgs([$logger, null]) ->setConstructorArgs([$logger, null])
->setMethods(['log']) ->setMethods(['log'])
->getMock() ->getMock()
@ -76,10 +76,10 @@ class DbalLoggerTest extends TestCase
public function testLogNonUtf8Array() public function testLogNonUtf8Array()
{ {
$logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder(DbalLogger::class)
->setConstructorArgs([$logger, null]) ->setConstructorArgs([$logger, null])
->setMethods(['log']) ->setMethods(['log'])
->getMock() ->getMock()
@ -107,10 +107,10 @@ class DbalLoggerTest extends TestCase
public function testLogLongString() public function testLogLongString()
{ {
$logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder(DbalLogger::class)
->setConstructorArgs([$logger, null]) ->setConstructorArgs([$logger, null])
->setMethods(['log']) ->setMethods(['log'])
->getMock() ->getMock()
@ -135,10 +135,10 @@ class DbalLoggerTest extends TestCase
public function testLogUTF8LongString() public function testLogUTF8LongString()
{ {
$logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
$dbalLogger = $this $dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') ->getMockBuilder(DbalLogger::class)
->setConstructorArgs([$logger, null]) ->setConstructorArgs([$logger, null])
->setMethods(['log']) ->setMethods(['log'])
->getMock() ->getMock()

View File

@ -19,7 +19,7 @@ class ManagerRegistryTest extends TestCase
{ {
public static function setUpBeforeClass(): void 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.'); self::markTestSkipped('proxy-manager-bridge is not yet compatible with namespaced phpunit versions.');
} }
$test = new PhpDumperTest(); $test = new PhpDumperTest();

View File

@ -55,7 +55,7 @@ class DoctrineTransactionMiddlewareTest extends MiddlewareTestCase
public function testTransactionIsRolledBackOnException() public function testTransactionIsRolledBackOnException()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Thrown from next middleware.'); $this->expectExceptionMessage('Thrown from next middleware.');
$this->connection->expects($this->once()) $this->connection->expects($this->once())
->method('beginTransaction') ->method('beginTransaction')

View File

@ -71,7 +71,7 @@ class EntityUserProviderTest extends TestCase
->with('user1') ->with('user1')
->willReturn($user); ->willReturn($user);
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager') $em = $this->getMockBuilder(\Doctrine\ORM\EntityManager::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$em $em
@ -86,7 +86,7 @@ class EntityUserProviderTest extends TestCase
public function testLoadUserByUsernameWithNonUserLoaderRepositoryAndWithoutProperty() 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.'); $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(); $em = DoctrineTestHelper::createTestEntityManager();
$this->createSchema($em); $this->createSchema($em);
@ -107,7 +107,7 @@ class EntityUserProviderTest extends TestCase
$user1 = new User(null, null, 'user1'); $user1 = new User(null, null, 'user1');
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); $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'); $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); $provider->refreshUser($user1);
} }
@ -125,7 +125,7 @@ class EntityUserProviderTest extends TestCase
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
$user2 = new User(1, 2, 'user2'); $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'); $this->expectExceptionMessage('User with id {"id1":1,"id2":2} not found');
$provider->refreshUser($user2); $provider->refreshUser($user2);
@ -168,7 +168,7 @@ class EntityUserProviderTest extends TestCase
public function testLoadUserByUserNameShouldDeclineInvalidInterface() public function testLoadUserByUserNameShouldDeclineInvalidInterface()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$repository = $this->createMock(ObjectRepository::class); $repository = $this->createMock(ObjectRepository::class);
$provider = new EntityUserProvider( $provider = new EntityUserProvider(

View File

@ -46,7 +46,7 @@ class ConsoleHandlerTest extends TestCase
*/ */
public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = []) public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = [])
{ {
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $output = $this->getMockBuilder(OutputInterface::class)->getMock();
$output $output
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('getVerbosity') ->method('getVerbosity')
@ -61,7 +61,7 @@ class ConsoleHandlerTest extends TestCase
$levelName = Logger::getLevelName($level); $levelName = Logger::getLevelName($level);
$levelName = sprintf('%-9s', $levelName); $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); $realOutput->setVerbosity($verbosity);
if ($realOutput->isDebug()) { if ($realOutput->isDebug()) {
$log = "16:21:54 $levelName [app] My info message\n"; $log = "16:21:54 $levelName [app] My info message\n";
@ -110,7 +110,7 @@ class ConsoleHandlerTest extends TestCase
public function testVerbosityChanged() public function testVerbosityChanged()
{ {
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $output = $this->getMockBuilder(OutputInterface::class)->getMock();
$output $output
->expects($this->exactly(2)) ->expects($this->exactly(2))
->method('getVerbosity') ->method('getVerbosity')
@ -131,14 +131,14 @@ class ConsoleHandlerTest extends TestCase
public function testGetFormatter() public function testGetFormatter()
{ {
$handler = new ConsoleHandler(); $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' '-getFormatter returns ConsoleFormatter by default'
); );
} }
public function testWritingAndFormatting() public function testWritingAndFormatting()
{ {
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $output = $this->getMockBuilder(OutputInterface::class)->getMock();
$output $output
->expects($this->any()) ->expects($this->any())
->method('getVerbosity') ->method('getVerbosity')
@ -193,12 +193,12 @@ class ConsoleHandlerTest extends TestCase
$logger->info('After terminate message.'); $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); $dispatcher->dispatch($event, ConsoleEvents::COMMAND);
$this->assertStringContainsString('Before command message.', $out = $output->fetch()); $this->assertStringContainsString('Before command message.', $out = $output->fetch());
$this->assertStringContainsString('After command message.', $out); $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); $dispatcher->dispatch($event, ConsoleEvents::TERMINATE);
$this->assertStringContainsString('Before terminate message.', $out = $output->fetch()); $this->assertStringContainsString('Before terminate message.', $out = $output->fetch());
$this->assertStringContainsString('After terminate message.', $out); $this->assertStringContainsString('After terminate message.', $out);

View File

@ -26,7 +26,7 @@ class HttpCodeActivationStrategyTest extends TestCase
*/ */
public function testExclusionsWithoutCodeLegacy() public function testExclusionsWithoutCodeLegacy()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING); new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING);
} }
@ -35,7 +35,7 @@ class HttpCodeActivationStrategyTest extends TestCase
*/ */
public function testExclusionsWithoutUrlsLegacy() public function testExclusionsWithoutUrlsLegacy()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], Logger::WARNING); new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], Logger::WARNING);
} }

View File

@ -109,7 +109,7 @@ class WebProcessorTest extends TestCase
private function isExtraFieldsSupported() private function isExtraFieldsSupported()
{ {
$monologWebProcessorClass = new \ReflectionClass('Monolog\Processor\WebProcessor'); $monologWebProcessorClass = new \ReflectionClass(\Monolog\Processor\WebProcessor::class);
foreach ($monologWebProcessorClass->getConstructor()->getParameters() as $parameter) { foreach ($monologWebProcessorClass->getConstructor()->getParameters() as $parameter) {
if ('extraFields' === $parameter->getName()) { if ('extraFields' === $parameter->getName()) {

View File

@ -344,7 +344,7 @@ class DeprecationErrorHandler
private static function getPhpUnitErrorHandler() private static function getPhpUnitErrorHandler()
{ {
if (!isset(self::$isAtLeastPhpUnit83)) { 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) { if (!self::$isAtLeastPhpUnit83) {
return 'PHPUnit\Util\ErrorHandler::handleError'; return 'PHPUnit\Util\ErrorHandler::handleError';

View File

@ -135,8 +135,8 @@ class SymfonyTestsListenerTrait
echo "Testing $suiteName\n"; echo "Testing $suiteName\n";
$this->state = 0; $this->state = 0;
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) { if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) { if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
AnnotationRegistry::registerUniqueLoader('class_exists'); AnnotationRegistry::registerUniqueLoader('class_exists');
} else { } else {
AnnotationRegistry::registerLoader('class_exists'); AnnotationRegistry::registerLoader('class_exists');

View File

@ -17,7 +17,7 @@ class BarCovTest extends TestCase
{ {
public function testBarCov() 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.'); $this->markTestSkipped('This test is not part of the main Symfony test suite. It\'s here to test the CoverageListener.');
} }

View File

@ -24,7 +24,7 @@ class ProcessIsolationTest extends TestCase
public function testCallingOtherErrorHandler() public function testCallingOtherErrorHandler()
{ {
$this->expectException('PHPUnit\Framework\Exception'); $this->expectException(\PHPUnit\Framework\Exception::class);
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.'); $this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
trigger_error('Test that PHPUnit\'s error handler fires.', \E_USER_WARNING); trigger_error('Test that PHPUnit\'s error handler fires.', \E_USER_WARNING);

View File

@ -259,17 +259,17 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php'); define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL; require PHPUNIT_COMPOSER_INSTALL;
if (!class_exists('SymfonyExcludeListPhpunit', false)) { if (!class_exists(\SymfonyExcludeListPhpunit::class, false)) {
class SymfonyExcludeListPhpunit {} class SymfonyExcludeListPhpunit {}
} }
if (method_exists('PHPUnit\Util\ExcludeList', 'addDirectory')) { if (method_exists(\PHPUnit\Util\ExcludeList::class, 'addDirectory')) {
(new PHPUnit\Util\Excludelist())->getExcludedDirectories(); (new PHPUnit\Util\Excludelist())->getExcludedDirectories();
PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName())); PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName()));
class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName())); class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName()));
} elseif (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) { } elseif (method_exists(\PHPUnit\Util\Blacklist::class, 'addDirectory')) {
(new PHPUnit\Util\BlackList())->getBlacklistedDirectories(); (new PHPUnit\Util\BlackList())->getBlacklistedDirectories();
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName())); PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListPhpunit::class))->getFileName()));
class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName())); class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass(\SymfonyExcludeListSimplePhpunit::class))->getFileName()));
} else { } else {
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1; PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1;
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1; PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1;
@ -394,7 +394,7 @@ if ($components) {
} }
} }
} elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) { } elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) {
if (!class_exists('SymfonyExcludeListSimplePhpunit', false)) { if (!class_exists(\SymfonyExcludeListSimplePhpunit::class, false)) {
class SymfonyExcludeListSimplePhpunit class SymfonyExcludeListSimplePhpunit
{ {
} }

View File

@ -38,15 +38,15 @@ class PhpDumperTest extends TestCase
*/ */
public function testDumpContainerWithProxyServiceWillShareProxies() public function testDumpContainerWithProxyServiceWillShareProxies()
{ {
if (!class_exists('LazyServiceProjectServiceContainer', false)) { if (!class_exists(\LazyServiceProjectServiceContainer::class, false)) {
eval('?>'.$this->dumpLazyServiceProjectServiceContainer()); eval('?>'.$this->dumpLazyServiceProjectServiceContainer());
} }
$container = new \LazyServiceProjectServiceContainer(); $container = new \LazyServiceProjectServiceContainer();
$proxy = $container->get('foo'); $proxy = $container->get('foo');
$this->assertInstanceOf('stdClass', $proxy); $this->assertInstanceOf(\stdClass::class, $proxy);
$this->assertInstanceOf('ProxyManager\Proxy\LazyLoadingInterface', $proxy); $this->assertInstanceOf(\ProxyManager\Proxy\LazyLoadingInterface::class, $proxy);
$this->assertSame($proxy, $container->get('foo')); $this->assertSame($proxy, $container->get('foo'));
$this->assertFalse($proxy->isProxyInitialized()); $this->assertFalse($proxy->isProxyInitialized());

View File

@ -38,7 +38,7 @@ class RuntimeInstantiatorTest extends TestCase
public function testInstantiateProxy() public function testInstantiateProxy()
{ {
$instance = new \stdClass(); $instance = new \stdClass();
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
$definition = new Definition('stdClass'); $definition = new Definition('stdClass');
$instantiator = function () use ($instance) { $instantiator = function () use ($instance) {
return $instance; return $instance;
@ -47,8 +47,8 @@ class RuntimeInstantiatorTest extends TestCase
/* @var $proxy \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface */ /* @var $proxy \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface */
$proxy = $this->instantiator->instantiateProxy($container, $definition, 'foo', $instantiator); $proxy = $this->instantiator->instantiateProxy($container, $definition, 'foo', $instantiator);
$this->assertInstanceOf('ProxyManager\Proxy\LazyLoadingInterface', $proxy); $this->assertInstanceOf(\ProxyManager\Proxy\LazyLoadingInterface::class, $proxy);
$this->assertInstanceOf('ProxyManager\Proxy\ValueHolderInterface', $proxy); $this->assertInstanceOf(\ProxyManager\Proxy\ValueHolderInterface::class, $proxy);
$this->assertFalse($proxy->isProxyInitialized()); $this->assertFalse($proxy->isProxyInitialized());
$proxy->initializeProxy(); $proxy->initializeProxy();

View File

@ -50,7 +50,7 @@ class AppVariableTest extends TestCase
*/ */
public function testGetSession() public function testGetSession()
{ {
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request = $this->getMockBuilder(Request::class)->getMock();
$request->method('hasSession')->willReturn(true); $request->method('hasSession')->willReturn(true);
$request->method('getSession')->willReturn($session = new Session()); $request->method('getSession')->willReturn($session = new Session());
@ -75,10 +75,10 @@ class AppVariableTest extends TestCase
public function testGetToken() 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); $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); $tokenStorage->method('getToken')->willReturn($token);
$this->assertEquals($token, $this->appVariable->getToken()); $this->assertEquals($token, $this->appVariable->getToken());
@ -86,7 +86,7 @@ class AppVariableTest extends TestCase
public function testGetUser() 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()); $this->assertEquals($user, $this->appVariable->getUser());
} }
@ -100,7 +100,7 @@ class AppVariableTest extends TestCase
public function testGetTokenWithNoToken() 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->appVariable->setTokenStorage($tokenStorage);
$this->assertNull($this->appVariable->getToken()); $this->assertNull($this->appVariable->getToken());
@ -108,7 +108,7 @@ class AppVariableTest extends TestCase
public function testGetUserWithNoToken() 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->appVariable->setTokenStorage($tokenStorage);
$this->assertNull($this->appVariable->getUser()); $this->assertNull($this->appVariable->getUser());
@ -116,37 +116,37 @@ class AppVariableTest extends TestCase
public function testEnvironmentNotSet() public function testEnvironmentNotSet()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->appVariable->getEnvironment(); $this->appVariable->getEnvironment();
} }
public function testDebugNotSet() public function testDebugNotSet()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->appVariable->getDebug(); $this->appVariable->getDebug();
} }
public function testGetTokenWithTokenStorageNotSet() public function testGetTokenWithTokenStorageNotSet()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->appVariable->getToken(); $this->appVariable->getToken();
} }
public function testGetUserWithTokenStorageNotSet() public function testGetUserWithTokenStorageNotSet()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->appVariable->getUser(); $this->appVariable->getUser();
} }
public function testGetRequestWithRequestStackNotSet() public function testGetRequestWithRequestStackNotSet()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->appVariable->getRequest(); $this->appVariable->getRequest();
} }
public function testGetSessionWithRequestStackNotSet() public function testGetSessionWithRequestStackNotSet()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->appVariable->getSession(); $this->appVariable->getSession();
} }
@ -224,7 +224,7 @@ class AppVariableTest extends TestCase
protected function setRequestStack($request) 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); $requestStackMock->method('getCurrentRequest')->willReturn($request);
$this->appVariable->setRequestStack($requestStackMock); $this->appVariable->setRequestStack($requestStackMock);
@ -232,10 +232,10 @@ class AppVariableTest extends TestCase
protected function setTokenStorage($user) 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); $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); $tokenStorage->method('getToken')->willReturn($token);
$token->method('getUser')->willReturn($user); $token->method('getUser')->willReturn($user);
@ -251,11 +251,11 @@ class AppVariableTest extends TestCase
$flashBag = new FlashBag(); $flashBag = new FlashBag();
$flashBag->initialize($flashMessages); $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('isStarted')->willReturn($sessionHasStarted);
$session->method('getFlashBag')->willReturn($flashBag); $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('hasSession')->willReturn(true);
$request->method('getSession')->willReturn($session); $request->method('getSession')->willReturn($session);
$this->setRequestStack($request); $this->setRequestStack($request);

View File

@ -65,7 +65,7 @@ class DebugCommandTest extends TestCase
public function testMalformedTemplateName() 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->expectExceptionMessage('Malformed namespaced template name "@foo" (expecting "@namespace/template_name").');
$this->createCommandTester()->execute(['name' => '@foo']); $this->createCommandTester()->execute(['name' => '@foo']);
} }

View File

@ -48,7 +48,7 @@ class LintCommandTest extends TestCase
public function testLintFileNotReadable() public function testLintFileNotReadable()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$tester = $this->createCommandTester(); $tester = $this->createCommandTester();
$filename = $this->createFile(''); $filename = $this->createFile('');
unlink($filename); unlink($filename);

View File

@ -67,7 +67,7 @@ class DumpExtensionTest extends TestCase
public function testDump($context, $args, $expectedOutput, $debug = true) public function testDump($context, $args, $expectedOutput, $debug = true)
{ {
$extension = new DumpExtension(new VarCloner()); $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, 'debug' => $debug,
'cache' => false, 'cache' => false,
'optimizations' => 0, 'optimizations' => 0,
@ -124,7 +124,7 @@ class DumpExtensionTest extends TestCase
'</pre><script>Sfdump("%s")</script>' '</pre><script>Sfdump("%s")</script>'
); );
$extension = new DumpExtension(new VarCloner(), $dumper); $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, 'debug' => true,
'cache' => false, 'cache' => false,
'optimizations' => 0, 'optimizations' => 0,

View File

@ -50,7 +50,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
'bootstrap_3_horizontal_layout.html.twig', 'bootstrap_3_horizontal_layout.html.twig',
'custom_widgets.html.twig', 'custom_widgets.html.twig',
], $environment); ], $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); $this->registerTwigRuntimeLoader($environment, $this->renderer);
} }

View File

@ -46,7 +46,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
'bootstrap_3_layout.html.twig', 'bootstrap_3_layout.html.twig',
'custom_widgets.html.twig', 'custom_widgets.html.twig',
], $environment); ], $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); $this->registerTwigRuntimeLoader($environment, $this->renderer);
} }
@ -88,7 +88,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
'bootstrap_3_layout.html.twig', 'bootstrap_3_layout.html.twig',
'custom_widgets.html.twig', 'custom_widgets.html.twig',
], $environment); ], $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); $this->registerTwigRuntimeLoader($environment, $this->renderer);
$view = $this->factory $view = $this->factory

View File

@ -52,7 +52,7 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori
'bootstrap_4_horizontal_layout.html.twig', 'bootstrap_4_horizontal_layout.html.twig',
'custom_widgets.html.twig', 'custom_widgets.html.twig',
], $environment); ], $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); $this->registerTwigRuntimeLoader($environment, $this->renderer);
} }

View File

@ -50,7 +50,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
'bootstrap_4_layout.html.twig', 'bootstrap_4_layout.html.twig',
'custom_widgets.html.twig', 'custom_widgets.html.twig',
], $environment); ], $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); $this->registerTwigRuntimeLoader($environment, $this->renderer);
} }
@ -92,7 +92,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
'bootstrap_4_layout.html.twig', 'bootstrap_4_layout.html.twig',
'custom_widgets.html.twig', 'custom_widgets.html.twig',
], $environment); ], $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); $this->registerTwigRuntimeLoader($environment, $this->renderer);
$view = $this->factory $view = $this->factory

View File

@ -53,7 +53,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
'form_div_layout.html.twig', 'form_div_layout.html.twig',
'custom_widgets.html.twig', 'custom_widgets.html.twig',
], $environment); ], $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); $this->registerTwigRuntimeLoader($environment, $this->renderer);
} }
@ -181,7 +181,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
'form_div_layout.html.twig', 'form_div_layout.html.twig',
'custom_widgets.html.twig', 'custom_widgets.html.twig',
], $environment); ], $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); $this->registerTwigRuntimeLoader($environment, $this->renderer);
$view = $this->factory $view = $this->factory

View File

@ -50,7 +50,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
'form_table_layout.html.twig', 'form_table_layout.html.twig',
'custom_widgets.html.twig', 'custom_widgets.html.twig',
], $environment); ], $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); $this->registerTwigRuntimeLoader($environment, $this->renderer);
} }

View File

@ -60,7 +60,7 @@ class HttpFoundationExtensionTest extends TestCase
*/ */
public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected) 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.'); $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) 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.'); $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) 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.'); $this->markTestSkipped('Your version of Symfony HttpFoundation is too old.');
} }

View File

@ -24,7 +24,7 @@ class HttpKernelExtensionTest extends TestCase
{ {
public function testFragmentWithError() public function testFragmentWithError()
{ {
$this->expectException('Twig\Error\RuntimeError'); $this->expectException(\Twig\Error\RuntimeError::class);
$renderer = $this->getFragmentHandler($this->throwException(new \Exception('foo'))); $renderer = $this->getFragmentHandler($this->throwException(new \Exception('foo')));
$this->renderTemplate($renderer); $this->renderTemplate($renderer);
@ -41,13 +41,13 @@ class HttpKernelExtensionTest extends TestCase
public function testUnknownFragmentRenderer() public function testUnknownFragmentRenderer()
{ {
$context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') $context = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock() ->getMock()
; ;
$renderer = new FragmentHandler($context); $renderer = new FragmentHandler($context);
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The "inline" renderer does not exist.'); $this->expectExceptionMessage('The "inline" renderer does not exist.');
$renderer->render('/foo'); $renderer->render('/foo');
@ -55,11 +55,11 @@ class HttpKernelExtensionTest extends TestCase
protected function getFragmentHandler($return) 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('getName')->willReturn('inline');
$strategy->expects($this->once())->method('render')->will($return); $strategy->expects($this->once())->method('render')->will($return);
$context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') $context = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock() ->getMock()
; ;
@ -75,7 +75,7 @@ class HttpKernelExtensionTest extends TestCase
$twig = new Environment($loader, ['debug' => true, 'cache' => false]); $twig = new Environment($loader, ['debug' => true, 'cache' => false]);
$twig->addExtension(new HttpKernelExtension()); $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([ $loader->expects($this->any())->method('load')->willReturnMap([
['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)], ['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)],
]); ]);

View File

@ -24,8 +24,8 @@ class RoutingExtensionTest extends TestCase
*/ */
public function testEscaping($template, $mustBeEscaped) public function testEscaping($template, $mustBeEscaped)
{ {
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); $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')->getMock())); $twig->addExtension(new RoutingExtension($this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock()));
$nodes = $twig->parse($twig->tokenize(new Source($template, ''))); $nodes = $twig->parse($twig->tokenize(new Source($template, '')));

View File

@ -18,7 +18,7 @@ trait RuntimeLoaderProvider
{ {
protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer) 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([ $loader->expects($this->any())->method('load')->will($this->returnValueMap([
['Symfony\Component\Form\FormRenderer', $renderer], ['Symfony\Component\Form\FormRenderer', $renderer],
])); ]));

View File

@ -21,7 +21,7 @@ class StopwatchExtensionTest extends TestCase
{ {
public function testFailIfStoppingWrongEvent() public function testFailIfStoppingWrongEvent()
{ {
$this->expectException('Twig\Error\SyntaxError'); $this->expectException(\Twig\Error\SyntaxError::class);
$this->testTiming('{% stopwatch "foo" %}{% endstopwatch "bar" %}', []); $this->testTiming('{% stopwatch "foo" %}{% endstopwatch "bar" %}', []);
} }
@ -55,7 +55,7 @@ class StopwatchExtensionTest extends TestCase
protected function getStopwatch($events = []) protected function getStopwatch($events = [])
{ {
$events = \is_array($events) ? $events : [$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; $expectedCalls = 0;
$expectedStartCalls = []; $expectedStartCalls = [];

View File

@ -24,7 +24,7 @@ class DumpNodeTest extends TestCase
{ {
$node = new DumpNode('bar', null, 7); $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); $compiler = new Compiler($env);
$expected = <<<'EOTXT' $expected = <<<'EOTXT'
@ -48,7 +48,7 @@ EOTXT;
{ {
$node = new DumpNode('bar', null, 7); $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); $compiler = new Compiler($env);
$expected = <<<'EOTXT' $expected = <<<'EOTXT'
@ -75,7 +75,7 @@ EOTXT;
]); ]);
$node = new DumpNode('bar', $vars, 7); $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); $compiler = new Compiler($env);
$expected = <<<'EOTXT' $expected = <<<'EOTXT'
@ -99,7 +99,7 @@ EOTXT;
]); ]);
$node = new DumpNode('bar', $vars, 7); $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); $compiler = new Compiler($env);
$expected = <<<'EOTXT' $expected = <<<'EOTXT'

View File

@ -54,7 +54,7 @@ class FormThemeTest extends TestCase
$node = new FormThemeNode($form, $resources, 0); $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()); $formRenderer = new FormRenderer($this->getMockBuilder(FormRendererEngineInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $formRenderer); $this->registerTwigRuntimeLoader($environment, $formRenderer);
$compiler = new Compiler($environment); $compiler = new Compiler($environment);

View File

@ -31,7 +31,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); $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( $this->assertEquals(
sprintf( sprintf(
@ -54,7 +54,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); $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( $this->assertEquals(
sprintf( sprintf(
@ -74,7 +74,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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( $this->assertEquals(
sprintf( sprintf(
@ -94,7 +94,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // Otherwise the default label is overwritten with null.
@ -116,7 +116,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // Otherwise the default label is overwritten with null.
@ -137,7 +137,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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( $this->assertEquals(
sprintf( sprintf(
@ -161,7 +161,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // Otherwise the default label is overwritten with null.
@ -190,7 +190,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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( $this->assertEquals(
sprintf( sprintf(
@ -218,7 +218,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // Otherwise the default label is overwritten with null.
@ -255,7 +255,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0); $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! // "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null. // Otherwise the default label is overwritten with null.

View File

@ -29,7 +29,7 @@ class TransNodeTest extends TestCase
$vars = new NameExpression('foo', 0); $vars = new NameExpression('foo', 0);
$node = new TransNode($body, null, null, $vars); $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); $compiler = new Compiler($env);
$this->assertEquals( $this->assertEquals(

View File

@ -26,7 +26,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase
/** @dataProvider getDefaultDomainAssignmentTestData */ /** @dataProvider getDefaultDomainAssignmentTestData */
public function testDefaultDomainAssignment(Node $node) 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(); $visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag // visit trans_default_domain tag
@ -52,7 +52,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase
/** @dataProvider getDefaultDomainAssignmentTestData */ /** @dataProvider getDefaultDomainAssignmentTestData */
public function testNewModuleWithoutDefaultDomainTag(Node $node) 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(); $visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag // visit trans_default_domain tag

View File

@ -25,7 +25,7 @@ class TranslationNodeVisitorTest extends TestCase
/** @dataProvider getMessagesExtractionTestData */ /** @dataProvider getMessagesExtractionTestData */
public function testMessagesExtraction(Node $node, array $expectedMessages) 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 = new TranslationNodeVisitor();
$visitor->enable(); $visitor->enable();
$visitor->enterNode($node, $env); $visitor->enterNode($node, $env);

View File

@ -28,7 +28,7 @@ class FormThemeTokenParserTest extends TestCase
*/ */
public function testCompile($source, $expected) 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()); $env->addTokenParser(new FormThemeTokenParser());
$source = new Source($source, ''); $source = new Source($source, '');
$stream = $env->tokenize($source); $stream = $env->tokenize($source);

View File

@ -26,7 +26,7 @@ class TwigExtractorTest extends TestCase
*/ */
public function testExtract($template, $messages) public function testExtract($template, $messages)
{ {
$loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock();
$twig = new Environment($loader, [ $twig = new Environment($loader, [
'strict_variables' => true, 'strict_variables' => true,
'debug' => true, 'debug' => true,
@ -91,7 +91,7 @@ class TwigExtractorTest extends TestCase
*/ */
public function testExtractSyntaxError($resources, array $messages) 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())); $twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
$extractor = new TwigExtractor($twig); $extractor = new TwigExtractor($twig);

View File

@ -89,7 +89,7 @@ EOT
new TableSeparator(), new TableSeparator(),
['Version', \PHP_VERSION], ['Version', \PHP_VERSION],
['Architecture', (\PHP_INT_SIZE * 8).' bits'], ['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().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'], ['Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'],
['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], ['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'], ['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],

View File

@ -125,7 +125,7 @@ class AnnotationsCacheWarmerTest extends TestCase
*/ */
private function getReadOnlyReader(): object 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('getClassAnnotations');
$readerMock->expects($this->exactly(0))->method('getClassAnnotation'); $readerMock->expects($this->exactly(0))->method('getClassAnnotation');
$readerMock->expects($this->exactly(0))->method('getMethodAnnotations'); $readerMock->expects($this->exactly(0))->method('getMethodAnnotations');

View File

@ -89,7 +89,7 @@ class CachePoolDeleteCommandTest extends TestCase
private function getKernel(): object private function getKernel(): object
{ {
$container = $this $container = $this
->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface') ->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)
->getMock(); ->getMock();
$kernel = $this $kernel = $this

View File

@ -55,7 +55,7 @@ class CachePruneCommandTest extends TestCase
private function getKernel(): object private function getKernel(): object
{ {
$container = $this $container = $this
->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface') ->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)
->getMock(); ->getMock();
$kernel = $this $kernel = $this

View File

@ -55,7 +55,7 @@ class RouterMatchCommandTest extends TestCase
$routeCollection = new RouteCollection(); $routeCollection = new RouteCollection();
$routeCollection->add('foo', new Route('foo')); $routeCollection->add('foo', new Route('foo'));
$requestContext = new RequestContext(); $requestContext = new RequestContext();
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock();
$router $router
->expects($this->any()) ->expects($this->any())
->method('getRouteCollection') ->method('getRouteCollection')
@ -70,7 +70,7 @@ class RouterMatchCommandTest extends TestCase
private function getKernel() private function getKernel()
{ {
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
$container $container
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('has') ->method('has')

View File

@ -60,7 +60,7 @@ bar';
public function testLintFileNotReadable() public function testLintFileNotReadable()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$tester = $this->createCommandTester(); $tester = $this->createCommandTester();
$filename = $this->createFile(''); $filename = $this->createFile('');
unlink($filename); unlink($filename);

View File

@ -82,7 +82,7 @@ class AbstractControllerTest extends TestCase
public function testMissingParameterBag() 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'); $this->expectExceptionMessage('TestAbstractController::getParameter()" method is missing a parameter bag');
$container = new Container(); $container = new Container();

View File

@ -34,7 +34,7 @@ class ProfilerPassTest extends TestCase
*/ */
public function testTemplateNoIdThrowsException() public function testTemplateNoIdThrowsException()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$builder = new ContainerBuilder(); $builder = new ContainerBuilder();
$builder->register('profiler', 'ProfilerClass'); $builder->register('profiler', 'ProfilerClass');
$builder->register('my_collector_service') $builder->register('my_collector_service')

View File

@ -54,7 +54,7 @@ class WorkflowGuardListenerPassTest extends TestCase
public function testExceptionIfTheTokenStorageServiceIsNotPresent() 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->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->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class); $this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
@ -66,7 +66,7 @@ class WorkflowGuardListenerPassTest extends TestCase
public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent() 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->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->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.token_storage', TokenStorageInterface::class); $this->container->register('security.token_storage', TokenStorageInterface::class);
@ -78,7 +78,7 @@ class WorkflowGuardListenerPassTest extends TestCase
public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent() 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->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->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.token_storage', TokenStorageInterface::class); $this->container->register('security.token_storage', TokenStorageInterface::class);
@ -90,7 +90,7 @@ class WorkflowGuardListenerPassTest extends TestCase
public function testExceptionIfTheRoleHierarchyServiceIsNotPresent() 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->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->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.token_storage', TokenStorageInterface::class); $this->container->register('security.token_storage', TokenStorageInterface::class);

View File

@ -48,7 +48,7 @@ class ConfigurationTest extends TestCase
*/ */
public function testInvalidSessionName($sessionName) public function testInvalidSessionName($sessionName)
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(InvalidConfigurationException::class);
$processor = new Processor(); $processor = new Processor();
$processor->processConfiguration( $processor->processConfiguration(
new Configuration(true), new Configuration(true),

View File

@ -67,7 +67,7 @@ class CachePoolClearCommandTest extends AbstractWebTestCase
public function testClearUnexistingPool() 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->expectExceptionMessage('You have requested a non-existent service "unknown_pool"');
$this->createCommandTester() $this->createCommandTester()
->execute(['pools' => ['unknown_pool']], ['decorated' => false]); ->execute(['pools' => ['unknown_pool']], ['decorated' => false]);

View File

@ -63,7 +63,7 @@ class RouterDebugCommandTest extends AbstractWebTestCase
public function testSearchWithThrow() public function testSearchWithThrow()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The route "gerard" does not exist.'); $this->expectExceptionMessage('The route "gerard" does not exist.');
$tester = $this->createCommandTester(); $tester = $this->createCommandTester();
$tester->execute(['name' => 'gerard'], ['interactive' => true]); $tester->execute(['name' => 'gerard'], ['interactive' => true]);

View File

@ -52,7 +52,7 @@ class MicroKernelTraitTest extends TestCase
$this->assertEquals('halloween', $response->getContent()); $this->assertEquals('halloween', $response->getContent());
$this->assertEquals('Have a great day!', $kernel->getContainer()->getParameter('halloween')); $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() public function testAsEventSubscriber()

View File

@ -138,7 +138,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
$loader->load('security_debug.php'); $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.expression_language');
$container->removeDefinition('security.access.expression_voter'); $container->removeDefinition('security.access.expression_voter');
} }
@ -850,7 +850,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
return $this->expressions[$id]; 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.'); throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
} }

View File

@ -24,7 +24,7 @@ class AddSecurityVotersPassTest extends TestCase
{ {
public function testNoVoters() 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".'); $this->expectExceptionMessage('No security voters found. You need to tag at least one with "security.voter".');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container $container

View File

@ -597,7 +597,7 @@ abstract class CompleteConfigurationTest extends TestCase
public function testAccessDecisionManagerServiceAndStrategyCannotBeUsedAtTheSameTime() 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->expectExceptionMessage('Invalid configuration for path "security.access_decision_manager": "strategy" and "service" cannot be used together.');
$this->getContainer('access_decision_manager_service_and_strategy'); $this->getContainer('access_decision_manager_service_and_strategy');
} }
@ -615,14 +615,14 @@ abstract class CompleteConfigurationTest extends TestCase
public function testFirewallUndefinedUserProvider() 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->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
$this->getContainer('firewall_undefined_provider'); $this->getContainer('firewall_undefined_provider');
} }
public function testFirewallListenerUndefinedProvider() 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->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
$this->getContainer('listener_undefined_provider'); $this->getContainer('listener_undefined_provider');
} }

View File

@ -34,7 +34,7 @@ class MainConfigurationTest extends TestCase
public function testNoConfigForProvider() public function testNoConfigForProvider()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$config = [ $config = [
'providers' => [ 'providers' => [
'stub' => [], 'stub' => [],
@ -48,7 +48,7 @@ class MainConfigurationTest extends TestCase
public function testManyConfigForProvider() public function testManyConfigForProvider()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$config = [ $config = [
'providers' => [ 'providers' => [
'stub' => [ 'stub' => [

View File

@ -127,7 +127,7 @@ class AbstractFactoryTest extends TestCase
protected function callFactory($id, $config, $userProviderId, $defaultEntryPointId) 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 $factory
->expects($this->once()) ->expects($this->once())

View File

@ -42,7 +42,7 @@ class GuardAuthenticationFactoryTest extends TestCase
*/ */
public function testAddInvalidConfiguration(array $inputConfig) 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(); $factory = new GuardAuthenticationFactory();
$nodeDefinition = new ArrayNodeDefinition('guard'); $nodeDefinition = new ArrayNodeDefinition('guard');
$factory->addConfiguration($nodeDefinition); $factory->addConfiguration($nodeDefinition);
@ -133,7 +133,7 @@ class GuardAuthenticationFactoryTest extends TestCase
public function testCannotOverrideDefaultEntryPoint() public function testCannotOverrideDefaultEntryPoint()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
// any existing default entry point is used // any existing default entry point is used
$config = [ $config = [
'authenticators' => ['authenticator123'], 'authenticators' => ['authenticator123'],
@ -144,7 +144,7 @@ class GuardAuthenticationFactoryTest extends TestCase
public function testMultipleAuthenticatorsRequiresEntryPoint() public function testMultipleAuthenticatorsRequiresEntryPoint()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
// any existing default entry point is used // any existing default entry point is used
$config = [ $config = [
'authenticators' => ['authenticator123', 'authenticatorABC'], 'authenticators' => ['authenticator123', 'authenticatorABC'],

View File

@ -44,7 +44,7 @@ class SecurityExtensionTest extends TestCase
{ {
public function testInvalidCheckPath() 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/.*".'); $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(); $container = $this->getRawContainer();
@ -68,7 +68,7 @@ class SecurityExtensionTest extends TestCase
public function testFirewallWithoutAuthenticationListener() 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"'); $this->expectExceptionMessage('No authentication listener registered for firewall "some_firewall"');
$container = $this->getRawContainer(); $container = $this->getRawContainer();
@ -89,7 +89,7 @@ class SecurityExtensionTest extends TestCase
public function testFirewallWithInvalidUserProvider() 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'); $this->expectExceptionMessage('Unable to create definition for "security.user.provider.concrete.my_foo" user provider');
$container = $this->getRawContainer(); $container = $this->getRawContainer();
@ -208,7 +208,7 @@ class SecurityExtensionTest extends TestCase
public function testMissingProviderForListener() 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.'); $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 = $this->getRawContainer();
$container->loadFromExtension('security', [ $container->loadFromExtension('security', [

View File

@ -298,7 +298,7 @@ EOTXT
public function testThrowsExceptionOnNoConfiguredEncoders() public function testThrowsExceptionOnNoConfiguredEncoders()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('There are no configured encoders for the "security" extension.'); $this->expectExceptionMessage('There are no configured encoders for the "security" extension.');
$application = new ConsoleApplication(); $application = new ConsoleApplication();
$application->add(new UserPasswordEncoderCommand($this->getMockBuilder(EncoderFactoryInterface::class)->getMock(), [])); $application->add(new UserPasswordEncoderCommand($this->getMockBuilder(EncoderFactoryInterface::class)->getMock(), []));

View File

@ -23,23 +23,23 @@ class ExtensionPass implements CompilerPassInterface
{ {
public function process(ContainerBuilder $container) 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'); $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'); $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'); $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'); $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'); $templateIterator = $container->getDefinition('twig.template_iterator');
$templatePaths = $templateIterator->getArgument(1); $templatePaths = $templateIterator->getArgument(1);
$loader = $container->getDefinition('twig.loader.native_filesystem'); $loader = $container->getDefinition('twig.loader.native_filesystem');
@ -103,7 +103,7 @@ class ExtensionPass implements CompilerPassInterface
$container->getDefinition('twig.extension.yaml')->addTag('twig.extension'); $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'); $container->getDefinition('twig.extension.debug.stopwatch')->addTag('twig.extension');
} }

View File

@ -15,7 +15,7 @@ use Symfony\Bridge\Twig\UndefinedCallableHandler;
use Twig\Environment; use Twig\Environment;
// BC/FC with namespaced Twig // BC/FC with namespaced Twig
class_exists('Twig\Environment'); class_exists(Environment::class);
/** /**
* Twig environment configurator. * Twig environment configurator.

View File

@ -89,7 +89,7 @@ class TwigLoaderPassTest extends TestCase
public function testMapperPassWithZeroTaggedLoaders() public function testMapperPassWithZeroTaggedLoaders()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
$this->pass->process($this->builder); $this->pass->process($this->builder);
} }
} }

View File

@ -17,11 +17,11 @@ class TemplateIteratorTest extends TestCase
{ {
public function testGetIterator() 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('getName')->willReturn('BarBundle');
$bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/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([ $kernel->expects($this->any())->method('getBundles')->willReturn([
$bundle, $bundle,
]); ]);

View File

@ -35,8 +35,8 @@ class ProfilerControllerTest extends WebTestCase
$this->expectException(NotFoundHttpException::class); $this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('The profiler must be enabled.'); $this->expectExceptionMessage('The profiler must be enabled.');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$controller = new ProfilerController($urlGenerator, null, $twig, []); $controller = new ProfilerController($urlGenerator, null, $twig, []);
$controller->homeAction(); $controller->homeAction();
@ -111,8 +111,8 @@ class ProfilerControllerTest extends WebTestCase
$this->expectException(NotFoundHttpException::class); $this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('The profiler must be enabled.'); $this->expectExceptionMessage('The profiler must be enabled.');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$controller = new ProfilerController($urlGenerator, null, $twig, []); $controller = new ProfilerController($urlGenerator, null, $twig, []);
$controller->toolbarAction(Request::create('/_wdt/foo-token'), null); $controller->toolbarAction(Request::create('/_wdt/foo-token'), null);
@ -123,10 +123,10 @@ class ProfilerControllerTest extends WebTestCase
*/ */
public function testToolbarActionWithEmptyToken($token) public function testToolbarActionWithEmptyToken($token)
{ {
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$profiler = $this $profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->getMockBuilder(Profiler::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -150,10 +150,10 @@ class ProfilerControllerTest extends WebTestCase
*/ */
public function testOpeningDisallowedPaths($path, $isAllowed) public function testOpeningDisallowedPaths($path, $isAllowed)
{ {
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$profiler = $this $profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->getMockBuilder(Profiler::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -186,9 +186,9 @@ class ProfilerControllerTest extends WebTestCase
*/ */
public function testReturns404onTokenNotFound($withCsp) public function testReturns404onTokenNotFound($withCsp)
{ {
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$profiler = $this $profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->getMockBuilder(Profiler::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -214,8 +214,8 @@ class ProfilerControllerTest extends WebTestCase
$this->expectException(NotFoundHttpException::class); $this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('The profiler must be enabled.'); $this->expectExceptionMessage('The profiler must be enabled.');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$controller = new ProfilerController($urlGenerator, null, $twig, []); $controller = new ProfilerController($urlGenerator, null, $twig, []);
$controller->searchBarAction(Request::create('/_profiler/search_bar')); $controller->searchBarAction(Request::create('/_profiler/search_bar'));
@ -240,9 +240,9 @@ class ProfilerControllerTest extends WebTestCase
*/ */
public function testSearchResultsAction($withCsp) public function testSearchResultsAction($withCsp)
{ {
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$profiler = $this $profiler = $this
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->getMockBuilder(Profiler::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -306,8 +306,8 @@ class ProfilerControllerTest extends WebTestCase
$this->expectException(NotFoundHttpException::class); $this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('The profiler must be enabled.'); $this->expectExceptionMessage('The profiler must be enabled.');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$controller = new ProfilerController($urlGenerator, null, $twig, []); $controller = new ProfilerController($urlGenerator, null, $twig, []);
$controller->searchBarAction(Request::create('/_profiler/search')); $controller->searchBarAction(Request::create('/_profiler/search'));
@ -345,8 +345,8 @@ class ProfilerControllerTest extends WebTestCase
$this->expectException(NotFoundHttpException::class); $this->expectException(NotFoundHttpException::class);
$this->expectExceptionMessage('The profiler must be enabled.'); $this->expectExceptionMessage('The profiler must be enabled.');
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $urlGenerator = $this->getMockBuilder(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)->getMock();
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$controller = new ProfilerController($urlGenerator, null, $twig, []); $controller = new ProfilerController($urlGenerator, null, $twig, []);
$controller->phpinfoAction(Request::create('/_profiler/phpinfo')); $controller->phpinfoAction(Request::create('/_profiler/phpinfo'));
@ -464,10 +464,10 @@ class ProfilerControllerTest extends WebTestCase
private function createController($profiler, $twig, $withCSP, array $templates = []): ProfilerController 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) { 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'); $nonceGenerator->method('generate')->willReturn('dummy_nonce');
return new ProfilerController($urlGenerator, $profiler, $twig, $templates, new ContentSecurityPolicyHandler($nonceGenerator)); return new ProfilerController($urlGenerator, $profiler, $twig, $templates, new ContentSecurityPolicyHandler($nonceGenerator));

View File

@ -210,7 +210,7 @@ class ContentSecurityPolicyHandlerTest extends TestCase
private function mockNonceGenerator($value) 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()) $generator->expects($this->any())
->method('generate') ->method('generate')

View File

@ -51,7 +51,7 @@ class WebProfilerExtensionTest extends TestCase
{ {
parent::setUp(); 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 = new ContainerBuilder();
$this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true); $this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true);

View File

@ -299,7 +299,7 @@ class WebDebugToolbarListenerTest extends TestCase
protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true) 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()) $request->expects($this->any())
->method('isXmlHttpRequest') ->method('isXmlHttpRequest')
->willReturn($isXmlHttpRequest); ->willReturn($isXmlHttpRequest);
@ -310,7 +310,7 @@ class WebDebugToolbarListenerTest extends TestCase
$request->headers = new HeaderBag(); $request->headers = new HeaderBag();
if ($hasSession) { 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()) $request->expects($this->any())
->method('getSession') ->method('getSession')
->willReturn($session); ->willReturn($session);
@ -321,7 +321,7 @@ class WebDebugToolbarListenerTest extends TestCase
protected function getTwigMock($render = 'WDT') protected function getTwigMock($render = 'WDT')
{ {
$templating = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $templating = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
$templating->expects($this->any()) $templating->expects($this->any())
->method('render') ->method('render')
->willReturn($render); ->willReturn($render);
@ -331,11 +331,11 @@ class WebDebugToolbarListenerTest extends TestCase
protected function getUrlGeneratorMock() protected function getUrlGeneratorMock()
{ {
return $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); return $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
} }
protected function getKernelMock() protected function getKernelMock()
{ {
return $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); return $this->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class)->disableOriginalConstructor()->getMock();
} }
} }

View File

@ -56,7 +56,7 @@ class TemplateManagerTest extends TestCase
public function testGetNameOfInvalidTemplate() 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'); $this->templateManager->getName(new Profile('token'), 'notexistingpanel');
} }
@ -97,12 +97,12 @@ class TemplateManagerTest extends TestCase
protected function mockProfile() protected function mockProfile()
{ {
return $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')->disableOriginalConstructor()->getMock(); return $this->getMockBuilder(Profile::class)->disableOriginalConstructor()->getMock();
} }
protected function mockTwigEnvironment() 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 = $this->createMock(LoaderInterface::class);
$loader $loader
@ -117,7 +117,7 @@ class TemplateManagerTest extends TestCase
protected function mockProfiler() protected function mockProfiler()
{ {
$this->profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') $this->profiler = $this->getMockBuilder(\Symfony\Component\HttpKernel\Profiler\Profiler::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -18,7 +18,7 @@ class RequestStackContextTest extends TestCase
{ {
public function testGetBasePathEmpty() public function testGetBasePathEmpty()
{ {
$requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
$requestStackContext = new RequestStackContext($requestStack); $requestStackContext = new RequestStackContext($requestStack);
$this->assertEmpty($requestStackContext->getBasePath()); $this->assertEmpty($requestStackContext->getBasePath());
@ -28,10 +28,10 @@ class RequestStackContextTest extends TestCase
{ {
$testBasePath = 'test-path'; $testBasePath = 'test-path';
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
$request->method('getBasePath') $request->method('getBasePath')
->willReturn($testBasePath); ->willReturn($testBasePath);
$requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
$requestStack->method('getMasterRequest') $requestStack->method('getMasterRequest')
->willReturn($request); ->willReturn($request);
@ -42,7 +42,7 @@ class RequestStackContextTest extends TestCase
public function testIsSecureFalse() public function testIsSecureFalse()
{ {
$requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
$requestStackContext = new RequestStackContext($requestStack); $requestStackContext = new RequestStackContext($requestStack);
$this->assertFalse($requestStackContext->isSecure()); $this->assertFalse($requestStackContext->isSecure());
@ -50,10 +50,10 @@ class RequestStackContextTest extends TestCase
public function testIsSecureTrue() public function testIsSecureTrue()
{ {
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class)->getMock();
$request->method('isSecure') $request->method('isSecure')
->willReturn(true); ->willReturn(true);
$requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock();
$requestStack->method('getMasterRequest') $requestStack->method('getMasterRequest')
->willReturn($request); ->willReturn($request);
@ -64,7 +64,7 @@ class RequestStackContextTest extends TestCase
public function testDefaultContext() 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); $requestStackContext = new RequestStackContext($requestStack, 'default-path', true);
$this->assertSame('default-path', $requestStackContext->getBasePath()); $this->assertSame('default-path', $requestStackContext->getBasePath());

View File

@ -21,8 +21,8 @@ class PackagesTest extends TestCase
public function testGetterSetters() public function testGetterSetters()
{ {
$packages = new Packages(); $packages = new Packages();
$packages->setDefaultPackage($default = $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')->getMock()); $packages->addPackage('a', $a = $this->getMockBuilder(\Symfony\Component\Asset\PackageInterface::class)->getMock());
$this->assertSame($default, $packages->getPackage()); $this->assertSame($default, $packages->getPackage());
$this->assertSame($a, $packages->getPackage('a')); $this->assertSame($a, $packages->getPackage('a'));
@ -57,14 +57,14 @@ class PackagesTest extends TestCase
public function testNoDefaultPackage() public function testNoDefaultPackage()
{ {
$this->expectException('Symfony\Component\Asset\Exception\LogicException'); $this->expectException(\Symfony\Component\Asset\Exception\LogicException::class);
$packages = new Packages(); $packages = new Packages();
$packages->getPackage(); $packages->getPackage();
} }
public function testUndefinedPackage() public function testUndefinedPackage()
{ {
$this->expectException('Symfony\Component\Asset\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Asset\Exception\InvalidArgumentException::class);
$packages = new Packages(); $packages = new Packages();
$packages->getPackage('a'); $packages->getPackage('a');
} }

View File

@ -77,7 +77,7 @@ class PathPackageTest extends TestCase
public function testVersionStrategyGivesAbsoluteURL() 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()) $versionStrategy->expects($this->any())
->method('applyVersion') ->method('applyVersion')
->willReturn('https://cdn.com/bar/main.css'); ->willReturn('https://cdn.com/bar/main.css');
@ -88,7 +88,7 @@ class PathPackageTest extends TestCase
private function getContext($basePath) 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); $context->expects($this->any())->method('getBasePath')->willReturn($basePath);
return $context; return $context;

View File

@ -86,7 +86,7 @@ class UrlPackageTest extends TestCase
public function testVersionStrategyGivesAbsoluteURL() 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()) $versionStrategy->expects($this->any())
->method('applyVersion') ->method('applyVersion')
->willReturn('https://cdn.com/bar/main.css'); ->willReturn('https://cdn.com/bar/main.css');
@ -97,7 +97,7 @@ class UrlPackageTest extends TestCase
public function testNoBaseUrls() public function testNoBaseUrls()
{ {
$this->expectException('Symfony\Component\Asset\Exception\LogicException'); $this->expectException(\Symfony\Component\Asset\Exception\LogicException::class);
new UrlPackage([], new EmptyVersionStrategy()); new UrlPackage([], new EmptyVersionStrategy());
} }
@ -106,7 +106,7 @@ class UrlPackageTest extends TestCase
*/ */
public function testWrongBaseUrl($baseUrls) public function testWrongBaseUrl($baseUrls)
{ {
$this->expectException('Symfony\Component\Asset\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Asset\Exception\InvalidArgumentException::class);
new UrlPackage($baseUrls, new EmptyVersionStrategy()); new UrlPackage($baseUrls, new EmptyVersionStrategy());
} }
@ -120,7 +120,7 @@ class UrlPackageTest extends TestCase
private function getContext($secure) 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); $context->expects($this->any())->method('isSecure')->willReturn($secure);
return $context; return $context;

View File

@ -88,7 +88,7 @@ class AbstractBrowserTest extends TestCase
$client->request('GET', 'http://example.com/'); $client->request('GET', 'http://example.com/');
$this->assertSame('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request'); $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() public function testGetResponseNull()
@ -296,7 +296,7 @@ class AbstractBrowserTest extends TestCase
$client->clickLink('foo'); $client->clickLink('foo');
$this->fail('->clickLink() throws a \InvalidArgumentException if the link could not be found'); $this->fail('->clickLink() throws a \InvalidArgumentException if the link could not be found');
} catch (\Exception $e) { } 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'); ], 'POST');
$this->fail('->submitForm() throws a \InvalidArgumentException if the form could not be found'); $this->fail('->submitForm() throws a \InvalidArgumentException if the form could not be found');
} catch (\Exception $e) { } 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(); $client->followRedirect();
$this->fail('->followRedirect() throws a \LogicException if the request was not redirected'); $this->fail('->followRedirect() throws a \LogicException if the request was not redirected');
} catch (\Exception $e) { } 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'])); $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
@ -436,7 +436,7 @@ class AbstractBrowserTest extends TestCase
$client->followRedirect(); $client->followRedirect();
$this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); $this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
} catch (\Exception $e) { } 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(); $client->followRedirect();
$this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); $this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
} catch (\Exception $e) { } 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'])); $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'); $client->request('GET', 'http://www.example.com/foo/foobar');
$this->fail('->request() throws a \RuntimeException if the script has an error'); $this->fail('->request() throws a \RuntimeException if the script has an error');
} catch (\Exception $e) { } 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', '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() public function testInternalRequestNull()

View File

@ -77,8 +77,8 @@ class CookieJarTest extends TestCase
$cookieJar->set(new Cookie('bar', 'bar')); $cookieJar->set(new Cookie('bar', 'bar'));
$cookieJar->updateFromSetCookie($setCookies); $cookieJar->updateFromSetCookie($setCookies);
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('foo')); $this->assertInstanceOf(Cookie::class, $cookieJar->get('foo'));
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('bar')); $this->assertInstanceOf(Cookie::class, $cookieJar->get('bar'));
$this->assertEquals('foo', $cookieJar->get('foo')->getValue(), '->updateFromSetCookie() updates cookies from a Set-Cookie header'); $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'); $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'); $barCookie = $cookieJar->get('bar', '/', '.blog.symfony.com');
$phpCookie = $cookieJar->get('PHPSESSID'); $phpCookie = $cookieJar->get('PHPSESSID');
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $fooCookie); $this->assertInstanceOf(Cookie::class, $fooCookie);
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $barCookie); $this->assertInstanceOf(Cookie::class, $barCookie);
$this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $phpCookie); $this->assertInstanceOf(Cookie::class, $phpCookie);
$this->assertEquals('foo', $fooCookie->getValue()); $this->assertEquals('foo', $fooCookie->getValue());
$this->assertEquals('bar', $barCookie->getValue()); $this->assertEquals('bar', $barCookie->getValue());
$this->assertEquals('id', $phpCookie->getValue()); $this->assertEquals('id', $phpCookie->getValue());

View File

@ -104,7 +104,7 @@ class CookieTest extends TestCase
public function testFromStringThrowsAnExceptionIfCookieIsNotValid() public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
Cookie::fromString('foo'); Cookie::fromString('foo');
} }
@ -117,7 +117,7 @@ class CookieTest extends TestCase
public function testFromStringThrowsAnExceptionIfUrlIsNotValid() public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
Cookie::fromString('foo=bar', 'foobar'); Cookie::fromString('foo=bar', 'foobar');
} }
@ -200,7 +200,7 @@ class CookieTest extends TestCase
public function testConstructException() public function testConstructException()
{ {
$this->expectException('UnexpectedValueException'); $this->expectException(\UnexpectedValueException::class);
$this->expectExceptionMessage('The cookie expiration time "string" is not valid.'); $this->expectExceptionMessage('The cookie expiration time "string" is not valid.');
new Cookie('foo', 'bar', 'string'); new Cookie('foo', 'bar', 'string');
} }

View File

@ -55,7 +55,7 @@ class HistoryTest extends TestCase
$history->current(); $history->current();
$this->fail('->current() throws a \LogicException if the history is empty'); $this->fail('->current() throws a \LogicException if the history is empty');
} catch (\Exception $e) { } 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')); $history->add(new Request('http://www.example.com/', 'get'));
@ -72,7 +72,7 @@ class HistoryTest extends TestCase
$history->back(); $history->back();
$this->fail('->back() throws a \LogicException if the history is already on the first page'); $this->fail('->back() throws a \LogicException if the history is already on the first page');
} catch (\Exception $e) { } 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')); $history->add(new Request('http://www.example1.com/', 'get'));
@ -91,7 +91,7 @@ class HistoryTest extends TestCase
$history->forward(); $history->forward();
$this->fail('->forward() throws a \LogicException if the history is already on the last page'); $this->fail('->forward() throws a \LogicException if the history is already on the last page');
} catch (\Exception $e) { } 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(); $history->back();

View File

@ -43,7 +43,7 @@ class TestClient extends AbstractBrowser
protected function getScript($request) protected function getScript($request)
{ {
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response'); $r = new \ReflectionClass(Response::class);
$path = $r->getFileName(); $path = $r->getFileName();
return <<<EOF return <<<EOF

View File

@ -66,7 +66,7 @@ class TestHttpClient extends HttpBrowser
protected function getScript($request) protected function getScript($request)
{ {
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response'); $r = new \ReflectionClass(Response::class);
$path = $r->getFileName(); $path = $r->getFileName();
return <<<EOF return <<<EOF

View File

@ -44,14 +44,14 @@ class ChainAdapterTest extends AdapterTestCase
public function testEmptyAdaptersException() public function testEmptyAdaptersException()
{ {
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('At least one adapter must be specified.'); $this->expectExceptionMessage('At least one adapter must be specified.');
new ChainAdapter([]); new ChainAdapter([]);
} }
public function testInvalidAdapterException() 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'); $this->expectExceptionMessage('The class "stdClass" does not implement');
new ChainAdapter([new \stdClass()]); new ChainAdapter([new \stdClass()]);
} }

View File

@ -68,7 +68,7 @@ class MaxIdLengthAdapterTest extends TestCase
public function testTooLongNamespace() 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->expectExceptionMessage('Namespace must be 26 chars max, 40 given ("----------------------------------------")');
$this->getMockBuilder(MaxIdLengthAdapter::class) $this->getMockBuilder(MaxIdLengthAdapter::class)
->setConstructorArgs([str_repeat('-', 40)]) ->setConstructorArgs([str_repeat('-', 40)])

View File

@ -72,10 +72,10 @@ class MemcachedAdapterTest extends AdapterTestCase
public function testBadOptions($name, $value) public function testBadOptions($name, $value)
{ {
if (\PHP_VERSION_ID < 80000) { if (\PHP_VERSION_ID < 80000) {
$this->expectException('ErrorException'); $this->expectException(\ErrorException::class);
$this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::'); $this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::');
} else { } else {
$this->expectException('Error'); $this->expectException(\Error::class);
$this->expectExceptionMessage('Undefined constant Memcached::'); $this->expectExceptionMessage('Undefined constant Memcached::');
} }
@ -106,7 +106,7 @@ class MemcachedAdapterTest extends AdapterTestCase
public function testOptionSerializer() 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".'); $this->expectExceptionMessage('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
if (!\Memcached::HAVE_JSON) { if (!\Memcached::HAVE_JSON) {
$this->markTestSkipped('Memcached::HAVE_JSON required'); $this->markTestSkipped('Memcached::HAVE_JSON required');

View File

@ -40,7 +40,7 @@ class ProxyAdapterTest extends AdapterTestCase
public function testProxyfiedItem() public function testProxyfiedItem()
{ {
$this->expectException('Exception'); $this->expectException(\Exception::class);
$this->expectExceptionMessage('OK bar'); $this->expectExceptionMessage('OK bar');
$item = new CacheItem(); $item = new CacheItem();
$pool = new ProxyAdapter(new TestingArrayAdapter($item)); $pool = new ProxyAdapter(new TestingArrayAdapter($item));

View File

@ -70,7 +70,7 @@ class RedisAdapterTest extends AbstractRedisAdapterTest
*/ */
public function testFailedCreateConnection(string $dsn) public function testFailedCreateConnection(string $dsn)
{ {
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Redis connection '); $this->expectExceptionMessage('Redis connection ');
RedisAdapter::createConnection($dsn); RedisAdapter::createConnection($dsn);
} }
@ -89,7 +89,7 @@ class RedisAdapterTest extends AbstractRedisAdapterTest
*/ */
public function testInvalidCreateConnection(string $dsn) 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'); $this->expectExceptionMessage('Invalid Redis DSN');
RedisAdapter::createConnection($dsn); RedisAdapter::createConnection($dsn);
} }

View File

@ -19,7 +19,7 @@ class RedisArrayAdapterTest extends AbstractRedisAdapterTest
public static function setUpBeforeClass(): void public static function setUpBeforeClass(): void
{ {
parent::setupBeforeClass(); parent::setupBeforeClass();
if (!class_exists('RedisArray')) { if (!class_exists(\RedisArray::class)) {
self::markTestSkipped('The RedisArray class is required.'); self::markTestSkipped('The RedisArray class is required.');
} }
self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]);

View File

@ -23,7 +23,7 @@ class RedisClusterAdapterTest extends AbstractRedisAdapterTest
{ {
public static function setUpBeforeClass(): void public static function setUpBeforeClass(): void
{ {
if (!class_exists('RedisCluster')) { if (!class_exists(\RedisCluster::class)) {
self::markTestSkipped('The RedisCluster class is required.'); self::markTestSkipped('The RedisCluster class is required.');
} }
if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) {
@ -46,7 +46,7 @@ class RedisClusterAdapterTest extends AbstractRedisAdapterTest
*/ */
public function testFailedCreateConnection(string $dsn) public function testFailedCreateConnection(string $dsn)
{ {
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Redis connection '); $this->expectExceptionMessage('Redis connection ');
RedisAdapter::createConnection($dsn); RedisAdapter::createConnection($dsn);
} }

View File

@ -27,7 +27,7 @@ class CacheItemTest extends TestCase
*/ */
public function testInvalidKey($key) public function testInvalidKey($key)
{ {
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Cache key'); $this->expectExceptionMessage('Cache key');
CacheItem::validateKey($key); CacheItem::validateKey($key);
} }
@ -75,7 +75,7 @@ class CacheItemTest extends TestCase
*/ */
public function testInvalidTag($tag) public function testInvalidTag($tag)
{ {
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Cache tag'); $this->expectExceptionMessage('Cache tag');
$item = new CacheItem(); $item = new CacheItem();
$r = new \ReflectionProperty($item, 'isTaggable'); $r = new \ReflectionProperty($item, 'isTaggable');
@ -87,7 +87,7 @@ class CacheItemTest extends TestCase
public function testNonTaggableItem() 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.'); $this->expectExceptionMessage('Cache item "foo" comes from a non tag-aware pool: you cannot tag it.');
$item = new CacheItem(); $item = new CacheItem();
$r = new \ReflectionProperty($item, 'key'); $r = new \ReflectionProperty($item, 'key');

View File

@ -161,7 +161,7 @@ class CachePoolPassTest extends TestCase
public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes() public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are'); $this->expectExceptionMessage('Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.container_class', 'app');

View File

@ -58,7 +58,7 @@ class CachePoolPrunerPassTest extends TestCase
public function testCompilerPassThrowsOnInvalidDefinitionClass() 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.'); $this->expectExceptionMessage('Class "Symfony\Component\Cache\Tests\DependencyInjection\NotFound" used for service "pool.not-found" cannot be found.');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('console.command.cache_pool_prune')->addArgument([]); $container->register('console.command.cache_pool_prune')->addArgument([]);

View File

@ -56,7 +56,7 @@ class DefaultMarshallerTest extends TestCase
public function testNativeUnserializeNotFoundClass() public function testNativeUnserializeNotFoundClass()
{ {
$this->expectException('DomainException'); $this->expectException(\DomainException::class);
$this->expectExceptionMessage('Class not found: NotExistingClass'); $this->expectExceptionMessage('Class not found: NotExistingClass');
$marshaller = new DefaultMarshaller(); $marshaller = new DefaultMarshaller();
$marshaller->unmarshall('O:16:"NotExistingClass":0:{}'); $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->markTestSkipped('igbinary is not compatible with PHP 7.4.');
} }
$this->expectException('DomainException'); $this->expectException(\DomainException::class);
$this->expectExceptionMessage('Class not found: NotExistingClass'); $this->expectExceptionMessage('Class not found: NotExistingClass');
$marshaller = new DefaultMarshaller(); $marshaller = new DefaultMarshaller();
$marshaller->unmarshall(rawurldecode('%00%00%00%02%17%10NotExistingClass%14%00')); $marshaller->unmarshall(rawurldecode('%00%00%00%02%17%10NotExistingClass%14%00'));
@ -79,7 +79,7 @@ class DefaultMarshallerTest extends TestCase
public function testNativeUnserializeInvalid() public function testNativeUnserializeInvalid()
{ {
$this->expectException('DomainException'); $this->expectException(\DomainException::class);
$this->expectExceptionMessage('unserialize(): Error at offset 0 of 3 bytes'); $this->expectExceptionMessage('unserialize(): Error at offset 0 of 3 bytes');
$marshaller = new DefaultMarshaller(); $marshaller = new DefaultMarshaller();
set_error_handler(function () { return false; }); 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->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'); $this->expectExceptionMessage('igbinary_unserialize_zval: unknown type \'61\', position 5');
$marshaller = new DefaultMarshaller(); $marshaller = new DefaultMarshaller();
set_error_handler(function () { return false; }); set_error_handler(function () { return false; });

View File

@ -22,7 +22,7 @@ trait TagAwareTestTrait
{ {
public function testInvalidTag() public function testInvalidTag()
{ {
$this->expectException('Psr\Cache\InvalidArgumentException'); $this->expectException(\Psr\Cache\InvalidArgumentException::class);
$pool = $this->createCachePool(); $pool = $this->createCachePool();
$item = $pool->getItem('foo'); $item = $pool->getItem('foo');
$item->tag(':'); $item->tag(':');

Some files were not shown because too many files have changed in this diff Show More