Use ::class keyword when possible

This commit is contained in:
Fabien Potencier 2021-01-11 09:47:58 +01:00
parent c79e61f1f2
commit 6c8d5808a6
751 changed files with 3180 additions and 3180 deletions

View File

@ -66,7 +66,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, '.');
}); });
@ -142,7 +142,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
)]; )];
} }
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && isset($metadata->embeddedClasses[$property])) { if ($metadata instanceof ClassMetadataInfo && class_exists(\Doctrine\ORM\Mapping\Embedded::class) && isset($metadata->embeddedClasses[$property])) {
return [new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])]; 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',
@ -51,7 +51,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,
@ -234,7 +234,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

@ -75,11 +75,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())
@ -87,7 +87,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

@ -33,7 +33,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();
@ -46,7 +46,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();
@ -66,7 +66,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();
@ -79,7 +79,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();
@ -102,7 +102,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();
@ -115,7 +115,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'], Connection::PARAM_STR_ARRAY) ->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();
@ -141,7 +141,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();
@ -154,7 +154,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

@ -34,21 +34,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' => [[]]];
@ -57,7 +57,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]]];
@ -66,7 +66,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]]];
@ -75,7 +75,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

@ -118,13 +118,13 @@ class EntityTypeTest extends BaseTypeTest
public function testClassOptionIsRequired() public function testClassOptionIsRequired()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class);
$this->factory->createNamed('name', static::TESTED_TYPE); $this->factory->createNamed('name', static::TESTED_TYPE);
} }
public function testInvalidClassOption() public function testInvalidClassOption()
{ {
$this->expectException('Symfony\Component\Form\Exception\RuntimeException'); $this->expectException(\Symfony\Component\Form\Exception\RuntimeException::class);
$this->factory->createNamed('name', static::TESTED_TYPE, null, [ $this->factory->createNamed('name', static::TESTED_TYPE, null, [
'class' => 'foo', 'class' => 'foo',
]); ]);
@ -219,7 +219,7 @@ class EntityTypeTest extends BaseTypeTest
public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure() public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class);
$this->factory->createNamed('name', static::TESTED_TYPE, null, [ $this->factory->createNamed('name', static::TESTED_TYPE, null, [
'em' => 'default', 'em' => 'default',
'class' => self::SINGLE_IDENT_CLASS, 'class' => self::SINGLE_IDENT_CLASS,
@ -229,7 +229,7 @@ class EntityTypeTest extends BaseTypeTest
public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder() public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder()
{ {
$this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class);
$field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [
'em' => 'default', 'em' => 'default',
'class' => self::SINGLE_IDENT_CLASS, 'class' => self::SINGLE_IDENT_CLASS,
@ -1242,7 +1242,7 @@ class EntityTypeTest extends BaseTypeTest
$choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader'); $choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader');
$choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader'); $choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader');
$this->assertInstanceOf('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface', $choiceLoader1); $this->assertInstanceOf(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class, $choiceLoader1);
$this->assertSame($choiceLoader1, $choiceLoader2); $this->assertSame($choiceLoader1, $choiceLoader2);
$this->assertSame($choiceLoader1, $choiceLoader3); $this->assertSame($choiceLoader1, $choiceLoader3);
} }
@ -1302,7 +1302,7 @@ class EntityTypeTest extends BaseTypeTest
$choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader'); $choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader');
$choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader'); $choiceLoader3 = $form->get('property3')->getConfig()->getOption('choice_loader');
$this->assertInstanceOf('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface', $choiceLoader1); $this->assertInstanceOf(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class, $choiceLoader1);
$this->assertSame($choiceLoader1, $choiceLoader2); $this->assertSame($choiceLoader1, $choiceLoader2);
$this->assertSame($choiceLoader1, $choiceLoader3); $this->assertSame($choiceLoader1, $choiceLoader3);
} }

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

@ -105,7 +105,7 @@ class DoctrineExtractorTest extends TestCase
private function doTestGetPropertiesWithEmbedded(bool $legacy) private function doTestGetPropertiesWithEmbedded(bool $legacy)
{ {
if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { if (!class_exists(\Doctrine\ORM\Mapping\Embedded::class)) {
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
} }
@ -151,7 +151,7 @@ class DoctrineExtractorTest extends TestCase
private function doTestExtractWithEmbedded(bool $legacy) private function doTestExtractWithEmbedded(bool $legacy)
{ {
if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { if (!class_exists(\Doctrine\ORM\Mapping\Embedded::class)) {
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
} }

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

@ -269,7 +269,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled() public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled()
{ {
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
$constraint = new UniqueEntity([ $constraint = new UniqueEntity([
'message' => 'myMessage', 'message' => 'myMessage',
'fields' => ['name', 'name2'], 'fields' => ['name', 'name2'],
@ -578,7 +578,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
public function testDedicatedEntityManagerNullObject() public function testDedicatedEntityManagerNullObject()
{ {
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
$this->expectExceptionMessage('Object manager "foo" does not exist.'); $this->expectExceptionMessage('Object manager "foo" does not exist.');
$constraint = new UniqueEntity([ $constraint = new UniqueEntity([
'message' => 'myMessage', 'message' => 'myMessage',
@ -598,7 +598,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
public function testEntityManagerNullObject() public function testEntityManagerNullObject()
{ {
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
$this->expectExceptionMessage('Unable to find the object manager associated with an entity of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity"'); $this->expectExceptionMessage('Unable to find the object manager associated with an entity of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity"');
$constraint = new UniqueEntity([ $constraint = new UniqueEntity([
'message' => 'myMessage', 'message' => 'myMessage',
@ -680,7 +680,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
public function testInvalidateRepositoryForInheritance() public function testInvalidateRepositoryForInheritance()
{ {
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
$this->expectExceptionMessage('The "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity" entity repository does not support the "Symfony\Bridge\Doctrine\Tests\Fixtures\Person" entity. The entity should be an instance of or extend "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity".'); $this->expectExceptionMessage('The "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity" entity repository does not support the "Symfony\Bridge\Doctrine\Tests\Fixtures\Person" entity. The entity should be an instance of or extend "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity".');
$constraint = new UniqueEntity([ $constraint = new UniqueEntity([
'message' => 'myMessage', 'message' => 'myMessage',

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

@ -22,13 +22,13 @@ class HttpCodeActivationStrategyTest extends TestCase
{ {
public function testExclusionsWithoutCode() public function testExclusionsWithoutCode()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING); new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING);
} }
public function testExclusionsWithoutUrls() public function testExclusionsWithoutUrls()
{ {
$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

@ -332,7 +332,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

@ -133,8 +133,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

@ -262,17 +262,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;
@ -397,7 +397,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

@ -12,7 +12,7 @@
use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { if (class_exists(\PHPUnit_Runner_Version::class) && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
$classes = [ $classes = [
'PHPUnit_Framework_Assert', // override PhpUnit's ForwardCompat child class 'PHPUnit_Framework_Assert', // override PhpUnit's ForwardCompat child class
'PHPUnit_Framework_AssertionFailedError', // override PhpUnit's ForwardCompat child class 'PHPUnit_Framework_AssertionFailedError', // override PhpUnit's ForwardCompat child class
@ -110,15 +110,15 @@ if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
} }
// Detect if we're loaded by an actual run of phpunit // Detect if we're loaded by an actual run of phpunit
if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false) && !class_exists('PHPUnit\TextUI\Command', false)) { if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists(\PHPUnit_TextUI_Command::class, false) && !class_exists(\PHPUnit\TextUI\Command::class, false)) {
return; return;
} }
// Enforce a consistent locale // Enforce a consistent locale
setlocale(\LC_ALL, 'C'); setlocale(\LC_ALL, 'C');
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

@ -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

@ -111,7 +111,7 @@ class ProxyDumperTest extends TestCase
public function testGetProxyFactoryCodeWithoutCustomMethod() public function testGetProxyFactoryCodeWithoutCustomMethod()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Missing factory code to construct the service "foo".'); $this->expectExceptionMessage('Missing factory code to construct the service "foo".');
$definition = new Definition(__CLASS__); $definition = new Definition(__CLASS__);
$definition->setLazy(true); $definition->setLazy(true);

View File

@ -20,7 +20,7 @@ use Twig\Node\Node;
use Twig\Node\TextNode; use Twig\Node\TextNode;
// BC/FC with namespaced Twig // BC/FC with namespaced Twig
class_exists('Twig\Node\Expression\ArrayExpression'); class_exists(ArrayExpression::class);
/** /**
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>

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

@ -91,7 +91,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

@ -62,7 +62,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.');
} }
@ -77,7 +77,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.');
} }
@ -120,7 +120,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

@ -58,14 +58,14 @@ class TranslationExtensionTest extends TestCase
public function testTransUnknownKeyword() public function testTransUnknownKeyword()
{ {
$this->expectException('Twig\Error\SyntaxError'); $this->expectException(\Twig\Error\SyntaxError::class);
$this->expectExceptionMessage('Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3.'); $this->expectExceptionMessage('Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3.');
$this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render(); $this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render();
} }
public function testTransComplexBody() public function testTransComplexBody()
{ {
$this->expectException('Twig\Error\SyntaxError'); $this->expectException(\Twig\Error\SyntaxError::class);
$this->expectExceptionMessage('A message inside a trans tag must be a simple text in "index" at line 2.'); $this->expectExceptionMessage('A message inside a trans tag must be a simple text in "index" at line 2.');
$this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render(); $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
} }
@ -75,7 +75,7 @@ class TranslationExtensionTest extends TestCase
*/ */
public function testTransChoiceComplexBody() public function testTransChoiceComplexBody()
{ {
$this->expectException('Twig\Error\SyntaxError'); $this->expectException(\Twig\Error\SyntaxError::class);
$this->expectExceptionMessage('A message inside a transchoice tag must be a simple text in "index" at line 2.'); $this->expectExceptionMessage('A message inside a transchoice tag must be a simple text in "index" at line 2.');
$this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render(); $this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render();
} }

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,
@ -102,7 +102,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

@ -26,7 +26,7 @@ class TwigEngineTest extends TestCase
{ {
$engine = $this->getTwig(); $engine = $this->getTwig();
$this->assertTrue($engine->exists($this->getMockForAbstractClass('Twig\Template', [], '', false))); $this->assertTrue($engine->exists($this->getMockForAbstractClass(\Twig\Template::class, [], '', false)));
} }
public function testExistsWithNonExistentTemplates() public function testExistsWithNonExistentTemplates()
@ -63,7 +63,7 @@ class TwigEngineTest extends TestCase
public function testRenderWithError() public function testRenderWithError()
{ {
$this->expectException('Twig\Error\SyntaxError'); $this->expectException(\Twig\Error\SyntaxError::class);
$engine = $this->getTwig(); $engine = $this->getTwig();
$engine->render(new TemplateReference('error')); $engine->render(new TemplateReference('error'));
@ -75,7 +75,7 @@ class TwigEngineTest extends TestCase
'index' => 'foo', 'index' => 'foo',
'error' => '{{ foo }', 'error' => '{{ foo }',
])); ]));
$parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $parser = $this->getMockBuilder(\Symfony\Component\Templating\TemplateNameParserInterface::class)->getMock();
return new TwigEngine($twig, $parser); return new TwigEngine($twig, $parser);
} }

View File

@ -82,7 +82,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

@ -197,7 +197,7 @@ class FrameworkExtension extends Extension
// default in the Form and Validator component). If disabled, an identity // default in the Form and Validator component). If disabled, an identity
// translator will be used and everything will still work as expected. // translator will be used and everything will still work as expected.
if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) { if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) {
if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['translator'])) { if (!class_exists(Translator::class) && $this->isConfigEnabled($container, $config['translator'])) {
throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".'); throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".');
} }
@ -268,14 +268,14 @@ class FrameworkExtension extends Extension
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader); $this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
if ($this->isConfigEnabled($container, $config['form'])) { if ($this->isConfigEnabled($container, $config['form'])) {
if (!class_exists('Symfony\Component\Form\Form')) { if (!class_exists(\Symfony\Component\Form\Form::class)) {
throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".'); throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
} }
$this->formConfigEnabled = true; $this->formConfigEnabled = true;
$this->registerFormConfiguration($config, $container, $loader); $this->registerFormConfiguration($config, $container, $loader);
if (class_exists('Symfony\Component\Validator\Validation')) { if (class_exists(\Symfony\Component\Validator\Validation::class)) {
$config['validation']['enabled'] = true; $config['validation']['enabled'] = true;
} else { } else {
$container->setParameter('validator.translation_domain', 'validators'); $container->setParameter('validator.translation_domain', 'validators');
@ -288,7 +288,7 @@ class FrameworkExtension extends Extension
} }
if ($this->isConfigEnabled($container, $config['assets'])) { if ($this->isConfigEnabled($container, $config['assets'])) {
if (!class_exists('Symfony\Component\Asset\Package')) { if (!class_exists(\Symfony\Component\Asset\Package::class)) {
throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".'); throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".');
} }
@ -298,7 +298,7 @@ class FrameworkExtension extends Extension
if ($this->isConfigEnabled($container, $config['templating'])) { if ($this->isConfigEnabled($container, $config['templating'])) {
@trigger_error('Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', \E_USER_DEPRECATED); @trigger_error('Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', \E_USER_DEPRECATED);
if (!class_exists('Symfony\Component\Templating\PhpEngine')) { if (!class_exists(\Symfony\Component\Templating\PhpEngine::class)) {
throw new LogicException('Templating support cannot be enabled as the Templating component is not installed. Try running "composer require symfony/templating".'); throw new LogicException('Templating support cannot be enabled as the Templating component is not installed. Try running "composer require symfony/templating".');
} }
@ -351,7 +351,7 @@ class FrameworkExtension extends Extension
$this->registerSecretsConfiguration($config['secrets'], $container, $loader); $this->registerSecretsConfiguration($config['secrets'], $container, $loader);
if ($this->isConfigEnabled($container, $config['serializer'])) { if ($this->isConfigEnabled($container, $config['serializer'])) {
if (!class_exists('Symfony\Component\Serializer\Serializer')) { if (!class_exists(\Symfony\Component\Serializer\Serializer::class)) {
throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".'); throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
} }
@ -1170,18 +1170,18 @@ class FrameworkExtension extends Extension
$dirs = []; $dirs = [];
$transPaths = []; $transPaths = [];
$nonExistingDirs = []; $nonExistingDirs = [];
if (class_exists('Symfony\Component\Validator\Validation')) { if (class_exists(\Symfony\Component\Validator\Validation::class)) {
$r = new \ReflectionClass('Symfony\Component\Validator\Validation'); $r = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
$dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations'; $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
} }
if (class_exists('Symfony\Component\Form\Form')) { if (class_exists(\Symfony\Component\Form\Form::class)) {
$r = new \ReflectionClass('Symfony\Component\Form\Form'); $r = new \ReflectionClass(\Symfony\Component\Form\Form::class);
$dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations'; $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
} }
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { if (class_exists(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)) {
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); $r = new \ReflectionClass(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
$dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations'; $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
} }
@ -1281,7 +1281,7 @@ class FrameworkExtension extends Extension
return; return;
} }
if (!class_exists('Symfony\Component\Validator\Validation')) { if (!class_exists(\Symfony\Component\Validator\Validation::class)) {
throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".'); throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
} }
@ -1351,8 +1351,8 @@ class FrameworkExtension extends Extension
$files['yaml' === $extension ? 'yml' : $extension][] = $path; $files['yaml' === $extension ? 'yml' : $extension][] = $path;
}; };
if (interface_exists('Symfony\Component\Form\FormInterface')) { if (interface_exists(\Symfony\Component\Form\FormInterface::class)) {
$reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface'); $reflClass = new \ReflectionClass(\Symfony\Component\Form\FormInterface::class);
$fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml'); $fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
} }
@ -1413,7 +1413,7 @@ class FrameworkExtension extends Extension
return; return;
} }
if (!class_exists('Doctrine\Common\Annotations\Annotation')) { if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) {
throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.'); throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
} }
@ -1425,7 +1425,7 @@ class FrameworkExtension extends Extension
} }
if ('none' !== $config['cache']) { if ('none' !== $config['cache']) {
if (!class_exists('Doctrine\Common\Cache\CacheProvider')) { if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.'); throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
} }
@ -1469,7 +1469,7 @@ class FrameworkExtension extends Extension
private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{ {
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) { if (!class_exists(PropertyAccessor::class)) {
return; return;
} }
@ -1523,7 +1523,7 @@ class FrameworkExtension extends Extension
return; return;
} }
if (!class_exists('Symfony\Component\Security\Csrf\CsrfToken')) { if (!class_exists(\Symfony\Component\Security\Csrf\CsrfToken::class)) {
throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".'); throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
} }
@ -1554,7 +1554,7 @@ class FrameworkExtension extends Extension
$chainLoader = $container->getDefinition('serializer.mapping.chain_loader'); $chainLoader = $container->getDefinition('serializer.mapping.chain_loader');
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) { if (!class_exists(PropertyAccessor::class)) {
$container->removeAlias('serializer.property_accessor'); $container->removeAlias('serializer.property_accessor');
$container->removeDefinition('serializer.normalizer.object'); $container->removeDefinition('serializer.normalizer.object');
} }
@ -1643,7 +1643,7 @@ class FrameworkExtension extends Extension
$loader->load('property_info.xml'); $loader->load('property_info.xml');
if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) { if (interface_exists(\phpDocumentor\Reflection\DocBlockFactoryInterface::class)) {
$definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor'); $definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
$definition->setPrivate(true); $definition->setPrivate(true);
$definition->addTag('property_info.description_extractor', ['priority' => -1000]); $definition->addTag('property_info.description_extractor', ['priority' => -1000]);

View File

@ -125,7 +125,7 @@ class AnnotationsCacheWarmerTest extends TestCase
*/ */
private function getReadOnlyReader() private function getReadOnlyReader()
{ {
$readerMock = $this->getMockBuilder('Doctrine\Common\Annotations\Reader')->getMock(); $readerMock = $this->getMockBuilder(Reader::class)->getMock();
$readerMock->expects($this->exactly(0))->method('getClassAnnotations'); $readerMock->expects($this->exactly(0))->method('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

@ -24,7 +24,7 @@ class TemplateFinderTest extends TestCase
public function testFindAllTemplates() public function testFindAllTemplates()
{ {
$kernel = $this $kernel = $this
->getMockBuilder('Symfony\Component\HttpKernel\Kernel') ->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock() ->getMock()
; ;

View File

@ -89,7 +89,7 @@ class CachePoolDeleteCommandTest extends TestCase
private function getKernel() private function getKernel()
{ {
$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() private function getKernel()
{ {
$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

@ -101,7 +101,7 @@ class TranslationDebugCommandTest extends TestCase
{ {
$this->fs->mkdir($this->translationDir.'/customDir/translations'); $this->fs->mkdir($this->translationDir.'/customDir/translations');
$this->fs->mkdir($this->translationDir.'/customDir/templates'); $this->fs->mkdir($this->translationDir.'/customDir/templates');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
$kernel->expects($this->once()) $kernel->expects($this->once())
->method('getBundle') ->method('getBundle')
->with($this->equalTo($this->translationDir.'/customDir')) ->with($this->equalTo($this->translationDir.'/customDir'))
@ -116,8 +116,8 @@ class TranslationDebugCommandTest extends TestCase
public function testDebugInvalidDirectory() public function testDebugInvalidDirectory()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
$kernel->expects($this->once()) $kernel->expects($this->once())
->method('getBundle') ->method('getBundle')
->with($this->equalTo('dir')) ->with($this->equalTo('dir'))
@ -142,7 +142,7 @@ class TranslationDebugCommandTest extends TestCase
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
{ {
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') $translator = $this->getMockBuilder(\Symfony\Component\Translation\Translator::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -151,7 +151,7 @@ class TranslationDebugCommandTest extends TestCase
->method('getFallbackLocales') ->method('getFallbackLocales')
->willReturn(['en']); ->willReturn(['en']);
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
$extractor $extractor
->expects($this->any()) ->expects($this->any())
->method('extract') ->method('extract')
@ -161,7 +161,7 @@ class TranslationDebugCommandTest extends TestCase
} }
); );
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock();
$loader $loader
->expects($this->any()) ->expects($this->any())
->method('read') ->method('read')
@ -182,7 +182,7 @@ class TranslationDebugCommandTest extends TestCase
['test', true, $this->getBundle('test')], ['test', true, $this->getBundle('test')],
]; ];
} }
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
@ -212,7 +212,7 @@ class TranslationDebugCommandTest extends TestCase
private function getBundle($path) private function getBundle($path)
{ {
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
$bundle $bundle
->expects($this->any()) ->expects($this->any())
->method('getPath') ->method('getPath')

View File

@ -154,7 +154,7 @@ class TranslationUpdateCommandTest extends TestCase
*/ */
private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = []) private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = [])
{ {
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') $translator = $this->getMockBuilder(\Symfony\Component\Translation\Translator::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -163,7 +163,7 @@ class TranslationUpdateCommandTest extends TestCase
->method('getFallbackLocales') ->method('getFallbackLocales')
->willReturn(['en']); ->willReturn(['en']);
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
$extractor $extractor
->expects($this->any()) ->expects($this->any())
->method('extract') ->method('extract')
@ -175,7 +175,7 @@ class TranslationUpdateCommandTest extends TestCase
} }
); );
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock();
$loader $loader
->expects($this->any()) ->expects($this->any())
->method('read') ->method('read')
@ -185,7 +185,7 @@ class TranslationUpdateCommandTest extends TestCase
} }
); );
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock(); $writer = $this->getMockBuilder(\Symfony\Component\Translation\Writer\TranslationWriter::class)->getMock();
$writer $writer
->expects($this->any()) ->expects($this->any())
->method('getFormats') ->method('getFormats')
@ -204,7 +204,7 @@ class TranslationUpdateCommandTest extends TestCase
['test', true, $this->getBundle('test')], ['test', true, $this->getBundle('test')],
]; ];
} }
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
@ -233,7 +233,7 @@ class TranslationUpdateCommandTest extends TestCase
private function getBundle($path) private function getBundle($path)
{ {
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
$bundle $bundle
->expects($this->any()) ->expects($this->any())
->method('getPath') ->method('getPath')

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

@ -30,7 +30,7 @@ class ApplicationTest extends TestCase
{ {
public function testBundleInterfaceImplementation() public function testBundleInterfaceImplementation()
{ {
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
$kernel = $this->getKernel([$bundle], true); $kernel = $this->getKernel([$bundle], true);
@ -110,7 +110,7 @@ class ApplicationTest extends TestCase
*/ */
public function testBundleCommandsHaveRightContainer() public function testBundleCommandsHaveRightContainer()
{ {
$command = $this->getMockForAbstractClass('Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand', ['foo'], '', true, true, true, ['setContainer']); $command = $this->getMockForAbstractClass(\Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand::class, ['foo'], '', true, true, true, ['setContainer']);
$command->setCode(function () {}); $command->setCode(function () {});
$command->expects($this->exactly(2))->method('setContainer'); $command->expects($this->exactly(2))->method('setContainer');
@ -259,10 +259,10 @@ class ApplicationTest extends TestCase
private function getKernel(array $bundles, $useDispatcher = false) private function getKernel(array $bundles, $useDispatcher = false)
{ {
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
if ($useDispatcher) { if ($useDispatcher) {
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
$dispatcher $dispatcher
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('dispatch') ->method('dispatch')
@ -287,7 +287,7 @@ class ApplicationTest extends TestCase
->willReturnOnConsecutiveCalls([], []) ->willReturnOnConsecutiveCalls([], [])
; ;
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
$kernel->expects($this->once())->method('boot'); $kernel->expects($this->once())->method('boot');
$kernel $kernel
->expects($this->any()) ->expects($this->any())
@ -305,7 +305,7 @@ class ApplicationTest extends TestCase
private function createBundleMock(array $commands) private function createBundleMock(array $commands)
{ {
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock();
$bundle $bundle
->expects($this->once()) ->expects($this->once())
->method('registerCommands') ->method('registerCommands')

View File

@ -68,7 +68,7 @@ class AbstractControllerTest extends ControllerTraitTest
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

@ -151,7 +151,7 @@ class ControllerNameParserTest extends TestCase
'FooBundle' => $this->getBundle('TestBundle\FooBundle', 'FooBundle'), 'FooBundle' => $this->getBundle('TestBundle\FooBundle', 'FooBundle'),
]; ];
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
@ -180,7 +180,7 @@ class ControllerNameParserTest extends TestCase
private function getBundle($namespace, $name) private function getBundle($namespace, $name)
{ {
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
$bundle->expects($this->any())->method('getName')->willReturn($name); $bundle->expects($this->any())->method('getName')->willReturn($name);
$bundle->expects($this->any())->method('getNamespace')->willReturn($namespace); $bundle->expects($this->any())->method('getNamespace')->willReturn($namespace);

View File

@ -32,8 +32,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest
$controller = $resolver->getController($request); $controller = $resolver->getController($request);
$this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller[0]); $this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller[0]->getContainer()); $this->assertInstanceOf(ContainerInterface::class, $controller[0]->getContainer());
$this->assertSame('testAction', $controller[1]); $this->assertSame('testAction', $controller[1]);
} }
@ -45,8 +45,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest
$controller = $resolver->getController($request); $controller = $resolver->getController($request);
$this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller); $this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller->getContainer()); $this->assertInstanceOf(ContainerInterface::class, $controller->getContainer());
} }
/** /**
@ -69,8 +69,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest
$controller = $resolver->getController($request); $controller = $resolver->getController($request);
$this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller[0]); $this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller[0]->getContainer()); $this->assertInstanceOf(ContainerInterface::class, $controller[0]->getContainer());
$this->assertSame('testAction', $controller[1]); $this->assertSame('testAction', $controller[1]);
} }
@ -200,12 +200,12 @@ class ControllerResolverTest extends ContainerControllerResolverTest
protected function createMockParser() protected function createMockParser()
{ {
return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser')->disableOriginalConstructor()->getMock(); return $this->getMockBuilder(ControllerNameParser::class)->disableOriginalConstructor()->getMock();
} }
protected function createMockContainer() protected function createMockContainer()
{ {
return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); return $this->getMockBuilder(ContainerInterface::class)->getMock();
} }
} }

View File

@ -43,7 +43,7 @@ abstract class ControllerTraitTest extends TestCase
$requestStack = new RequestStack(); $requestStack = new RequestStack();
$requestStack->push($request); $requestStack->push($request);
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock();
$kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
return new Response($request->getRequestFormat().'--'.$request->getLocale()); return new Response($request->getRequestFormat().'--'.$request->getLocale());
}); });
@ -90,7 +90,7 @@ abstract class ControllerTraitTest extends TestCase
public function testGetUserWithEmptyContainer() public function testGetUserWithEmptyContainer()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('The SecurityBundle is not registered in your application.'); $this->expectExceptionMessage('The SecurityBundle is not registered in your application.');
$controller = $this->createController(); $controller = $this->createController();
$controller->setContainer(new Container()); $controller->setContainer(new Container());
@ -100,7 +100,7 @@ abstract class ControllerTraitTest extends TestCase
private function getContainerWithTokenStorage($token = null): Container private function getContainerWithTokenStorage($token = null): Container
{ {
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock(); $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::class)->getMock();
$tokenStorage $tokenStorage
->expects($this->once()) ->expects($this->once())
->method('getToken') ->method('getToken')
@ -169,7 +169,7 @@ abstract class ControllerTraitTest extends TestCase
public function testFile() public function testFile()
{ {
$container = new Container(); $container = new Container();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock();
$container->set('http_kernel', $kernel); $container->set('http_kernel', $kernel);
$controller = $this->createController(); $controller = $this->createController();
@ -270,7 +270,7 @@ abstract class ControllerTraitTest extends TestCase
public function testFileWhichDoesNotExist() public function testFileWhichDoesNotExist()
{ {
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); $this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class);
$controller = $this->createController(); $controller = $this->createController();
$controller->file('some-file.txt', 'test.php'); $controller->file('some-file.txt', 'test.php');
@ -278,7 +278,7 @@ abstract class ControllerTraitTest extends TestCase
public function testIsGranted() public function testIsGranted()
{ {
$authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); $authorizationChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class)->getMock();
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true);
$container = new Container(); $container = new Container();
@ -292,8 +292,8 @@ abstract class ControllerTraitTest extends TestCase
public function testdenyAccessUnlessGranted() public function testdenyAccessUnlessGranted()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException'); $this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class);
$authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); $authorizationChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class)->getMock();
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false);
$container = new Container(); $container = new Container();
@ -307,7 +307,7 @@ abstract class ControllerTraitTest extends TestCase
public function testRenderViewTwig() public function testRenderViewTwig()
{ {
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
$twig->expects($this->once())->method('render')->willReturn('bar'); $twig->expects($this->once())->method('render')->willReturn('bar');
$container = new Container(); $container = new Container();
@ -321,7 +321,7 @@ abstract class ControllerTraitTest extends TestCase
public function testRenderTwig() public function testRenderTwig()
{ {
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
$twig->expects($this->once())->method('render')->willReturn('bar'); $twig->expects($this->once())->method('render')->willReturn('bar');
$container = new Container(); $container = new Container();
@ -335,7 +335,7 @@ abstract class ControllerTraitTest extends TestCase
public function testStreamTwig() public function testStreamTwig()
{ {
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
$container = new Container(); $container = new Container();
$container->set('twig', $twig); $container->set('twig', $twig);
@ -343,12 +343,12 @@ abstract class ControllerTraitTest extends TestCase
$controller = $this->createController(); $controller = $this->createController();
$controller->setContainer($container); $controller->setContainer($container);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo')); $this->assertInstanceOf(\Symfony\Component\HttpFoundation\StreamedResponse::class, $controller->stream('foo'));
} }
public function testRedirectToRoute() public function testRedirectToRoute()
{ {
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock();
$router->expects($this->once())->method('generate')->willReturn('/foo'); $router->expects($this->once())->method('generate')->willReturn('/foo');
$container = new Container(); $container = new Container();
@ -358,7 +358,7 @@ abstract class ControllerTraitTest extends TestCase
$controller->setContainer($container); $controller->setContainer($container);
$response = $controller->redirectToRoute('foo'); $response = $controller->redirectToRoute('foo');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response);
$this->assertSame('/foo', $response->getTargetUrl()); $this->assertSame('/foo', $response->getTargetUrl());
$this->assertSame(302, $response->getStatusCode()); $this->assertSame(302, $response->getStatusCode());
} }
@ -369,7 +369,7 @@ abstract class ControllerTraitTest extends TestCase
public function testAddFlash() public function testAddFlash()
{ {
$flashBag = new FlashBag(); $flashBag = new FlashBag();
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock(); $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class)->getMock();
$session->expects($this->once())->method('getFlashBag')->willReturn($flashBag); $session->expects($this->once())->method('getFlashBag')->willReturn($flashBag);
$container = new Container(); $container = new Container();
@ -386,12 +386,12 @@ abstract class ControllerTraitTest extends TestCase
{ {
$controller = $this->createController(); $controller = $this->createController();
$this->assertInstanceOf('Symfony\Component\Security\Core\Exception\AccessDeniedException', $controller->createAccessDeniedException()); $this->assertInstanceOf(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class, $controller->createAccessDeniedException());
} }
public function testIsCsrfTokenValid() public function testIsCsrfTokenValid()
{ {
$tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); $tokenManager = $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock();
$tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true); $tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true);
$container = new Container(); $container = new Container();
@ -405,7 +405,7 @@ abstract class ControllerTraitTest extends TestCase
public function testGenerateUrl() public function testGenerateUrl()
{ {
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock();
$router->expects($this->once())->method('generate')->willReturn('/foo'); $router->expects($this->once())->method('generate')->willReturn('/foo');
$container = new Container(); $container = new Container();
@ -422,7 +422,7 @@ abstract class ControllerTraitTest extends TestCase
$controller = $this->createController(); $controller = $this->createController();
$response = $controller->redirect('https://dunglas.fr', 301); $response = $controller->redirect('https://dunglas.fr', 301);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response);
$this->assertSame('https://dunglas.fr', $response->getTargetUrl()); $this->assertSame('https://dunglas.fr', $response->getTargetUrl());
$this->assertSame(301, $response->getStatusCode()); $this->assertSame(301, $response->getStatusCode());
} }
@ -432,7 +432,7 @@ abstract class ControllerTraitTest extends TestCase
*/ */
public function testRenderViewTemplating() public function testRenderViewTemplating()
{ {
$templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $templating = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock();
$templating->expects($this->once())->method('render')->willReturn('bar'); $templating->expects($this->once())->method('render')->willReturn('bar');
$container = new Container(); $container = new Container();
@ -449,7 +449,7 @@ abstract class ControllerTraitTest extends TestCase
*/ */
public function testRenderTemplating() public function testRenderTemplating()
{ {
$templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $templating = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock();
$templating->expects($this->once())->method('render')->willReturn('bar'); $templating->expects($this->once())->method('render')->willReturn('bar');
$container = new Container(); $container = new Container();
@ -466,7 +466,7 @@ abstract class ControllerTraitTest extends TestCase
*/ */
public function testStreamTemplating() public function testStreamTemplating()
{ {
$templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $templating = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock();
$container = new Container(); $container = new Container();
$container->set('templating', $templating); $container->set('templating', $templating);
@ -474,21 +474,21 @@ abstract class ControllerTraitTest extends TestCase
$controller = $this->createController(); $controller = $this->createController();
$controller->setContainer($container); $controller->setContainer($container);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo')); $this->assertInstanceOf(\Symfony\Component\HttpFoundation\StreamedResponse::class, $controller->stream('foo'));
} }
public function testCreateNotFoundException() public function testCreateNotFoundException()
{ {
$controller = $this->createController(); $controller = $this->createController();
$this->assertInstanceOf('Symfony\Component\HttpKernel\Exception\NotFoundHttpException', $controller->createNotFoundException()); $this->assertInstanceOf(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class, $controller->createNotFoundException());
} }
public function testCreateForm() public function testCreateForm()
{ {
$form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock()); $form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock());
$formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $formFactory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
$formFactory->expects($this->once())->method('create')->willReturn($form); $formFactory->expects($this->once())->method('create')->willReturn($form);
$container = new Container(); $container = new Container();
@ -502,9 +502,9 @@ abstract class ControllerTraitTest extends TestCase
public function testCreateFormBuilder() public function testCreateFormBuilder()
{ {
$formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilderInterface')->getMock(); $formBuilder = $this->getMockBuilder(\Symfony\Component\Form\FormBuilderInterface::class)->getMock();
$formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $formFactory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
$formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder); $formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder);
$container = new Container(); $container = new Container();

View File

@ -22,7 +22,7 @@ class TemplateControllerTest extends TestCase
{ {
public function testTwig() public function testTwig()
{ {
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
$twig->expects($this->exactly(2))->method('render')->willReturn('bar'); $twig->expects($this->exactly(2))->method('render')->willReturn('bar');
$controller = new TemplateController($twig); $controller = new TemplateController($twig);
@ -47,7 +47,7 @@ class TemplateControllerTest extends TestCase
public function testNoTwigNorTemplating() public function testNoTwigNorTemplating()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.'); $this->expectExceptionMessage('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.');
$controller = new TemplateController(); $controller = new TemplateController();

View File

@ -113,7 +113,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

@ -61,7 +61,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\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found.'); $this->expectExceptionMessage('Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\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

@ -27,7 +27,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

@ -66,7 +66,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

@ -127,7 +127,7 @@ abstract class FrameworkExtensionTest extends TestCase
public function testCsrfProtectionNeedsSessionToBeEnabled() public function testCsrfProtectionNeedsSessionToBeEnabled()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('CSRF protection needs sessions to be enabled.'); $this->expectExceptionMessage('CSRF protection needs sessions to be enabled.');
$this->createContainerFromFile('csrf_needs_session'); $this->createContainerFromFile('csrf_needs_session');
} }
@ -167,7 +167,7 @@ abstract class FrameworkExtensionTest extends TestCase
*/ */
public function testAmbiguousWhenBothTemplatingAndFragments() public function testAmbiguousWhenBothTemplatingAndFragments()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->createContainerFromFile('template_and_fragments'); $this->createContainerFromFile('template_and_fragments');
} }
@ -331,28 +331,28 @@ abstract class FrameworkExtensionTest extends TestCase
public function testWorkflowAreValidated() public function testWorkflowAreValidated()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class);
$this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "go" from place/state "first" were found on StateMachine "my_workflow".'); $this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "go" from place/state "first" were found on StateMachine "my_workflow".');
$this->createContainerFromFile('workflow_not_valid'); $this->createContainerFromFile('workflow_not_valid');
} }
public function testWorkflowCannotHaveBothTypeAndService() public function testWorkflowCannotHaveBothTypeAndService()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('"type" and "service" cannot be used together.'); $this->expectExceptionMessage('"type" and "service" cannot be used together.');
$this->createContainerFromFile('workflow_legacy_with_type_and_service'); $this->createContainerFromFile('workflow_legacy_with_type_and_service');
} }
public function testWorkflowCannotHaveBothSupportsAndSupportStrategy() public function testWorkflowCannotHaveBothSupportsAndSupportStrategy()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('"supports" and "support_strategy" cannot be used together.'); $this->expectExceptionMessage('"supports" and "support_strategy" cannot be used together.');
$this->createContainerFromFile('workflow_with_support_and_support_strategy'); $this->createContainerFromFile('workflow_with_support_and_support_strategy');
} }
public function testWorkflowShouldHaveOneOfSupportsAndSupportStrategy() public function testWorkflowShouldHaveOneOfSupportsAndSupportStrategy()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('"supports" or "support_strategy" should be configured.'); $this->expectExceptionMessage('"supports" or "support_strategy" should be configured.');
$this->createContainerFromFile('workflow_without_support_and_support_strategy'); $this->createContainerFromFile('workflow_without_support_and_support_strategy');
} }
@ -362,7 +362,7 @@ abstract class FrameworkExtensionTest extends TestCase
*/ */
public function testWorkflowCannotHaveBothArgumentsAndService() public function testWorkflowCannotHaveBothArgumentsAndService()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('"arguments" and "service" cannot be used together.'); $this->expectExceptionMessage('"arguments" and "service" cannot be used together.');
$this->createContainerFromFile('workflow_legacy_with_arguments_and_service'); $this->createContainerFromFile('workflow_legacy_with_arguments_and_service');
} }
@ -524,7 +524,7 @@ abstract class FrameworkExtensionTest extends TestCase
public function testRouterRequiresResourceOption() public function testRouterRequiresResourceOption()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$container = $this->createContainer(); $container = $this->createContainer();
$loader = new FrameworkExtension(); $loader = new FrameworkExtension();
$loader->load([['router' => true]], $container); $loader->load([['router' => true]], $container);
@ -815,14 +815,14 @@ abstract class FrameworkExtensionTest extends TestCase
public function testMessengerMiddlewareFactoryErroneousFormat() public function testMessengerMiddlewareFactoryErroneousFormat()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid middleware at path "framework.messenger": a map with a single factory id as key and its arguments as value was expected, {"foo":["qux"],"bar":["baz"]} given.'); $this->expectExceptionMessage('Invalid middleware at path "framework.messenger": a map with a single factory id as key and its arguments as value was expected, {"foo":["qux"],"bar":["baz"]} given.');
$this->createContainerFromFile('messenger_middleware_factory_erroneous_format'); $this->createContainerFromFile('messenger_middleware_factory_erroneous_format');
} }
public function testMessengerInvalidTransportRouting() public function testMessengerInvalidTransportRouting()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('Invalid Messenger routing configuration: the "Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage" class is being routed to a sender called "invalid". This is not a valid transport or service id.'); $this->expectExceptionMessage('Invalid Messenger routing configuration: the "Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage" class is being routed to a sender called "invalid". This is not a valid transport or service id.');
$this->createContainerFromFile('messenger_routing_invalid_transport'); $this->createContainerFromFile('messenger_routing_invalid_transport');
} }
@ -838,19 +838,19 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame($container->getParameter('kernel.cache_dir').'/translations', $options['cache_dir']); $this->assertSame($container->getParameter('kernel.cache_dir').'/translations', $options['cache_dir']);
$files = array_map('realpath', $options['resource_files']['en']); $files = array_map('realpath', $options['resource_files']['en']);
$ref = new \ReflectionClass('Symfony\Component\Validator\Validation'); $ref = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
$this->assertContains( $this->assertContains(
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR), strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
$files, $files,
'->registerTranslatorConfiguration() finds Validator translation resources' '->registerTranslatorConfiguration() finds Validator translation resources'
); );
$ref = new \ReflectionClass('Symfony\Component\Form\Form'); $ref = new \ReflectionClass(\Symfony\Component\Form\Form::class);
$this->assertContains( $this->assertContains(
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR), strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
$files, $files,
'->registerTranslatorConfiguration() finds Form translation resources' '->registerTranslatorConfiguration() finds Form translation resources'
); );
$ref = new \ReflectionClass('Symfony\Component\Security\Core\Security'); $ref = new \ReflectionClass(\Symfony\Component\Security\Core\Security::class);
$this->assertContains( $this->assertContains(
strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', \DIRECTORY_SEPARATOR), strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', \DIRECTORY_SEPARATOR),
$files, $files,
@ -921,7 +921,7 @@ abstract class FrameworkExtensionTest extends TestCase
*/ */
public function testTemplatingRequiresAtLeastOneEngine() public function testTemplatingRequiresAtLeastOneEngine()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$container = $this->createContainer(); $container = $this->createContainer();
$loader = new FrameworkExtension(); $loader = new FrameworkExtension();
$loader->load([['templating' => null]], $container); $loader->load([['templating' => null]], $container);
@ -932,7 +932,7 @@ abstract class FrameworkExtensionTest extends TestCase
$container = $this->createContainerFromFile('full'); $container = $this->createContainerFromFile('full');
$projectDir = $container->getParameter('kernel.project_dir'); $projectDir = $container->getParameter('kernel.project_dir');
$ref = new \ReflectionClass('Symfony\Component\Form\Form'); $ref = new \ReflectionClass(\Symfony\Component\Form\Form::class);
$xmlMappings = [ $xmlMappings = [
\dirname($ref->getFileName()).'/Resources/config/validation.xml', \dirname($ref->getFileName()).'/Resources/config/validation.xml',
strtr($projectDir.'/config/validator/foo.xml', '/', \DIRECTORY_SEPARATOR), strtr($projectDir.'/config/validator/foo.xml', '/', \DIRECTORY_SEPARATOR),
@ -969,7 +969,7 @@ abstract class FrameworkExtensionTest extends TestCase
{ {
$container = $this->createContainerFromFile('validation_annotations', ['kernel.charset' => 'UTF-8'], false); $container = $this->createContainerFromFile('validation_annotations', ['kernel.charset' => 'UTF-8'], false);
$this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator')); $this->assertInstanceOf(\Symfony\Component\Validator\Validator\ValidatorInterface::class, $container->get('validator'));
} }
public function testAnnotations() public function testAnnotations()
@ -1097,7 +1097,7 @@ abstract class FrameworkExtensionTest extends TestCase
*/ */
public function testCannotConfigureStrictEmailAndEmailValidationModeAtTheSameTime() public function testCannotConfigureStrictEmailAndEmailValidationModeAtTheSameTime()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('"strict_email" and "email_validation_mode" cannot be used together.'); $this->expectExceptionMessage('"strict_email" and "email_validation_mode" cannot be used together.');
$this->createContainerFromFile('validation_strict_email_and_validation_mode'); $this->createContainerFromFile('validation_strict_email_and_validation_mode');
} }

View File

@ -25,7 +25,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
public function testAssetsCannotHavePathAndUrl() public function testAssetsCannotHavePathAndUrl()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->createContainerFromClosure(function ($container) { $this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [ $container->loadFromExtension('framework', [
'assets' => [ 'assets' => [
@ -38,7 +38,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
public function testAssetPackageCannotHavePathAndUrl() public function testAssetPackageCannotHavePathAndUrl()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->createContainerFromClosure(function ($container) { $this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [ $container->loadFromExtension('framework', [
'assets' => [ 'assets' => [
@ -55,7 +55,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
public function testWorkflowValidationStateMachine() public function testWorkflowValidationStateMachine()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class);
$this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "a_to_b" from place/state "a" were found on StateMachine "article".'); $this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "a_to_b" from place/state "a" were found on StateMachine "article".');
$this->createContainerFromClosure(function ($container) { $this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [ $container->loadFromExtension('framework', [
@ -157,7 +157,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
*/ */
public function testWorkflowValidationSingleState() public function testWorkflowValidationSingleState()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class);
$this->expectExceptionMessage('The marking store of workflow "article" can not store many places. But the transition "a_to_b" has too many output (2). Only one is accepted.'); $this->expectExceptionMessage('The marking store of workflow "article" can not store many places. But the transition "a_to_b" has too many output (2). Only one is accepted.');
$this->createContainerFromClosure(function ($container) { $this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [ $container->loadFromExtension('framework', [

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

@ -29,7 +29,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

@ -25,7 +25,7 @@ class RouterTest extends TestCase
{ {
public function testConstructThrowsOnNonSymfonyNorPsr11Container() public function testConstructThrowsOnNonSymfonyNorPsr11Container()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('You should either pass a "Symfony\Component\DependencyInjection\ContainerInterface" instance or provide the $parameters argument of the "Symfony\Bundle\FrameworkBundle\Routing\Router::__construct" method'); $this->expectExceptionMessage('You should either pass a "Symfony\Component\DependencyInjection\ContainerInterface" instance or provide the $parameters argument of the "Symfony\Bundle\FrameworkBundle\Routing\Router::__construct" method');
new Router($this->createMock(ContainerInterface::class), 'foo'); new Router($this->createMock(ContainerInterface::class), 'foo');
} }
@ -293,7 +293,7 @@ class RouterTest extends TestCase
public function testEnvPlaceholders() public function testEnvPlaceholders()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.'); $this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.');
$routes = new RouteCollection(); $routes = new RouteCollection();
@ -305,7 +305,7 @@ class RouterTest extends TestCase
public function testEnvPlaceholdersWithSfContainer() public function testEnvPlaceholdersWithSfContainer()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.'); $this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.');
$routes = new RouteCollection(); $routes = new RouteCollection();
@ -375,7 +375,7 @@ class RouterTest extends TestCase
public function testExceptionOnNonExistentParameterWithSfContainer() public function testExceptionOnNonExistentParameterWithSfContainer()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException::class);
$this->expectExceptionMessage('You have requested a non-existent parameter "nope".'); $this->expectExceptionMessage('You have requested a non-existent parameter "nope".');
$routes = new RouteCollection(); $routes = new RouteCollection();
@ -389,7 +389,7 @@ class RouterTest extends TestCase
public function testExceptionOnNonStringParameter() public function testExceptionOnNonStringParameter()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(RuntimeException::class);
$this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".'); $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".');
$routes = new RouteCollection(); $routes = new RouteCollection();
@ -404,7 +404,7 @@ class RouterTest extends TestCase
public function testExceptionOnNonStringParameterWithSfContainer() public function testExceptionOnNonStringParameterWithSfContainer()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(RuntimeException::class);
$this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".'); $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".');
$routes = new RouteCollection(); $routes = new RouteCollection();
@ -504,7 +504,7 @@ class RouterTest extends TestCase
private function getServiceContainer(RouteCollection $routes): Container private function getServiceContainer(RouteCollection $routes): Container
{ {
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
$loader $loader
->expects($this->any()) ->expects($this->any())
@ -512,7 +512,7 @@ class RouterTest extends TestCase
->willReturn($routes) ->willReturn($routes)
; ;
$sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock(); $sc = $this->getMockBuilder(Container::class)->setMethods(['get'])->getMock();
$sc $sc
->expects($this->once()) ->expects($this->once())

View File

@ -49,7 +49,7 @@ class DelegatingEngineTest extends TestCase
public function testGetInvalidEngine() public function testGetInvalidEngine()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('No engine is able to work with the template "template.php"'); $this->expectExceptionMessage('No engine is able to work with the template "template.php"');
$firstEngine = $this->getEngineMock('template.php', false); $firstEngine = $this->getEngineMock('template.php', false);
$secondEngine = $this->getEngineMock('template.php', false); $secondEngine = $this->getEngineMock('template.php', false);
@ -83,12 +83,12 @@ class DelegatingEngineTest extends TestCase
$container = $this->getContainerMock(['engine' => $engine]); $container = $this->getContainerMock(['engine' => $engine]);
$delegatingEngine = new DelegatingEngine($container, ['engine']); $delegatingEngine = new DelegatingEngine($container, ['engine']);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $delegatingEngine->renderResponse('template.php', ['foo' => 'bar'])); $this->assertInstanceOf(Response::class, $delegatingEngine->renderResponse('template.php', ['foo' => 'bar']));
} }
private function getEngineMock($template, $supports) private function getEngineMock($template, $supports)
{ {
$engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock(); $engine = $this->getMockBuilder(\Symfony\Component\Templating\EngineInterface::class)->getMock();
$engine->expects($this->once()) $engine->expects($this->once())
->method('supports') ->method('supports')
@ -100,7 +100,7 @@ class DelegatingEngineTest extends TestCase
private function getFrameworkEngineMock($template, $supports) private function getFrameworkEngineMock($template, $supports)
{ {
$engine = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $engine = $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Templating\EngineInterface::class)->getMock();
$engine->expects($this->once()) $engine->expects($this->once())
->method('supports') ->method('supports')

View File

@ -36,14 +36,14 @@ class GlobalVariablesTest extends TestCase
public function testGetTokenNoToken() public function testGetTokenNoToken()
{ {
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
$this->container->set('security.token_storage', $tokenStorage); $this->container->set('security.token_storage', $tokenStorage);
$this->assertNull($this->globals->getToken()); $this->assertNull($this->globals->getToken());
} }
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->container->set('security.token_storage', $tokenStorage); $this->container->set('security.token_storage', $tokenStorage);
@ -62,7 +62,7 @@ class GlobalVariablesTest extends TestCase
public function testGetUserNoToken() public function testGetUserNoToken()
{ {
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
$this->container->set('security.token_storage', $tokenStorage); $this->container->set('security.token_storage', $tokenStorage);
$this->assertNull($this->globals->getUser()); $this->assertNull($this->globals->getUser());
} }
@ -72,8 +72,8 @@ class GlobalVariablesTest extends TestCase
*/ */
public function testGetUser($user, $expectedUser) public function testGetUser($user, $expectedUser)
{ {
$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();
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$this->container->set('security.token_storage', $tokenStorage); $this->container->set('security.token_storage', $tokenStorage);
@ -92,9 +92,9 @@ class GlobalVariablesTest extends TestCase
public function getUserProvider() public function getUserProvider()
{ {
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock();
$std = new \stdClass(); $std = new \stdClass();
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
return [ return [
[$user, $user], [$user, $user],

View File

@ -36,7 +36,7 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
{ {
// should be moved to the Form component once absolute file paths are supported // should be moved to the Form component once absolute file paths are supported
// by the default name parser in the Templating component // by the default name parser in the Templating component
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle'); $reflClass = new \ReflectionClass(\Symfony\Bundle\FrameworkBundle\FrameworkBundle::class);
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views'); $root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
$rootTheme = realpath(__DIR__.'/Resources'); $rootTheme = realpath(__DIR__.'/Resources');
$templateNameParser = new StubTemplateNameParser($root, $rootTheme); $templateNameParser = new StubTemplateNameParser($root, $rootTheme);

View File

@ -80,7 +80,7 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
{ {
// should be moved to the Form component once absolute file paths are supported // should be moved to the Form component once absolute file paths are supported
// by the default name parser in the Templating component // by the default name parser in the Templating component
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle'); $reflClass = new \ReflectionClass(\Symfony\Bundle\FrameworkBundle\FrameworkBundle::class);
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views'); $root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
$rootTheme = realpath(__DIR__.'/Resources'); $rootTheme = realpath(__DIR__.'/Resources');
$templateNameParser = new StubTemplateNameParser($root, $rootTheme); $templateNameParser = new StubTemplateNameParser($root, $rootTheme);

View File

@ -21,7 +21,7 @@ class StopwatchHelperTest extends TestCase
{ {
public function testDevEnvironment() public function testDevEnvironment()
{ {
$stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); $stopwatch = $this->getMockBuilder(\Symfony\Component\Stopwatch\Stopwatch::class)->getMock();
$stopwatch->expects($this->once()) $stopwatch->expects($this->once())
->method('start') ->method('start')
->with('foo'); ->with('foo');

View File

@ -82,7 +82,7 @@ class TemplateLocatorTest extends TestCase
public function testThrowsAnExceptionWhenTemplateIsNotATemplateReferenceInterface() public function testThrowsAnExceptionWhenTemplateIsNotATemplateReferenceInterface()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$locator = new TemplateLocator($this->getFileLocator()); $locator = new TemplateLocator($this->getFileLocator());
$locator->locate('template'); $locator->locate('template');
} }
@ -90,7 +90,7 @@ class TemplateLocatorTest extends TestCase
protected function getFileLocator() protected function getFileLocator()
{ {
return $this return $this
->getMockBuilder('Symfony\Component\Config\FileLocator') ->getMockBuilder(\Symfony\Component\Config\FileLocator::class)
->setMethods(['locate']) ->setMethods(['locate'])
->setConstructorArgs(['/path/to/fallback']) ->setConstructorArgs(['/path/to/fallback'])
->getMock() ->getMock()

View File

@ -29,7 +29,7 @@ class PhpEngineTest extends TestCase
public function testEvaluateAddsAppGlobal() public function testEvaluateAddsAppGlobal()
{ {
$container = $this->getContainer(); $container = $this->getContainer();
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $loader = $this->getMockForAbstractClass(\Symfony\Component\Templating\Loader\Loader::class);
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader, $app = new GlobalVariables($container)); $engine = new PhpEngine(new TemplateNameParser(), $container, $loader, $app = new GlobalVariables($container));
$globals = $engine->getGlobals(); $globals = $engine->getGlobals();
$this->assertSame($app, $globals['app']); $this->assertSame($app, $globals['app']);
@ -38,7 +38,7 @@ class PhpEngineTest extends TestCase
public function testEvaluateWithoutAvailableRequest() public function testEvaluateWithoutAvailableRequest()
{ {
$container = new Container(); $container = new Container();
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $loader = $this->getMockForAbstractClass(\Symfony\Component\Templating\Loader\Loader::class);
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader, new GlobalVariables($container)); $engine = new PhpEngine(new TemplateNameParser(), $container, $loader, new GlobalVariables($container));
$this->assertFalse($container->has('request_stack')); $this->assertFalse($container->has('request_stack'));
@ -48,9 +48,9 @@ class PhpEngineTest extends TestCase
public function testGetInvalidHelper() public function testGetInvalidHelper()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$container = $this->getContainer(); $container = $this->getContainer();
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $loader = $this->getMockForAbstractClass(\Symfony\Component\Templating\Loader\Loader::class);
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader); $engine = new PhpEngine(new TemplateNameParser(), $container, $loader);
$engine->get('non-existing-helper'); $engine->get('non-existing-helper');

View File

@ -25,7 +25,7 @@ class TemplateNameParserTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
$kernel $kernel
->expects($this->any()) ->expects($this->any())
->method('getBundle') ->method('getBundle')
@ -79,7 +79,7 @@ class TemplateNameParserTest extends TestCase
public function testParseValidNameWithNotFoundBundle() public function testParseValidNameWithNotFoundBundle()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->parser->parse('BarBundle:Post:index.html.php'); $this->parser->parse('BarBundle:Post:index.html.php');
} }
} }

View File

@ -49,13 +49,13 @@ class TimedPhpEngineTest extends TestCase
private function getContainer(): Container private function getContainer(): Container
{ {
return $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')->getMock(); return $this->getMockBuilder(Container::class)->getMock();
} }
private function getTemplateNameParser(): TemplateNameParserInterface private function getTemplateNameParser(): TemplateNameParserInterface
{ {
$templateReference = $this->getMockBuilder('Symfony\Component\Templating\TemplateReferenceInterface')->getMock(); $templateReference = $this->getMockBuilder(\Symfony\Component\Templating\TemplateReferenceInterface::class)->getMock();
$templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $templateNameParser = $this->getMockBuilder(TemplateNameParserInterface::class)->getMock();
$templateNameParser->expects($this->any()) $templateNameParser->expects($this->any())
->method('parse') ->method('parse')
->willReturn($templateReference); ->willReturn($templateReference);
@ -65,14 +65,14 @@ class TimedPhpEngineTest extends TestCase
private function getGlobalVariables(): GlobalVariables private function getGlobalVariables(): GlobalVariables
{ {
return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables') return $this->getMockBuilder(GlobalVariables::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
} }
private function getStorage(): StringStorage private function getStorage(): StringStorage
{ {
return $this->getMockBuilder('Symfony\Component\Templating\Storage\StringStorage') return $this->getMockBuilder(StringStorage::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMockForAbstractClass(); ->getMockForAbstractClass();
} }
@ -82,7 +82,7 @@ class TimedPhpEngineTest extends TestCase
*/ */
private function getLoader($storage): Loader private function getLoader($storage): Loader
{ {
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $loader = $this->getMockForAbstractClass(Loader::class);
$loader->expects($this->once()) $loader->expects($this->once())
->method('load') ->method('load')
->willReturn($storage); ->willReturn($storage);
@ -92,13 +92,13 @@ class TimedPhpEngineTest extends TestCase
private function getStopwatchEvent(): StopwatchEvent private function getStopwatchEvent(): StopwatchEvent
{ {
return $this->getMockBuilder('Symfony\Component\Stopwatch\StopwatchEvent') return $this->getMockBuilder(StopwatchEvent::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
} }
private function getStopwatch(): Stopwatch private function getStopwatch(): Stopwatch
{ {
return $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); return $this->getMockBuilder(Stopwatch::class)->getMock();
} }
} }

View File

@ -94,7 +94,7 @@ class TranslatorTest extends TestCase
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
// do it another time as the cache is primed now // do it another time as the cache is primed now
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
$loader->expects($this->never())->method('load'); $loader->expects($this->never())->method('load');
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]); $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]);
@ -124,7 +124,7 @@ class TranslatorTest extends TestCase
$this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));
// do it another time as the cache is primed now // do it another time as the cache is primed now
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
$loader->expects($this->never())->method('load'); $loader->expects($this->never())->method('load');
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]); $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]);
@ -137,9 +137,9 @@ class TranslatorTest extends TestCase
public function testTransWithCachingWithInvalidLocale() public function testTransWithCachingWithInvalidLocale()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid "invalid locale" locale.'); $this->expectExceptionMessage('Invalid "invalid locale" locale.');
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', TranslatorWithInvalidLocale::class); $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', TranslatorWithInvalidLocale::class);
$translator->trans('foo'); $translator->trans('foo');
@ -170,9 +170,9 @@ class TranslatorTest extends TestCase
public function testInvalidOptions() public function testInvalidOptions()
{ {
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('The Translator does not support the following options: \'foo\''); $this->expectExceptionMessage('The Translator does not support the following options: \'foo\'');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
(new Translator($container, new MessageFormatter(), 'en', [], ['foo' => 'bar'])); (new Translator($container, new MessageFormatter(), 'en', [], ['foo' => 'bar']));
} }
@ -182,7 +182,7 @@ class TranslatorTest extends TestCase
{ {
$someCatalogue = $this->getCatalogue('some_locale', []); $someCatalogue = $this->getCatalogue('some_locale', []);
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
$loader->expects($this->exactly(2)) $loader->expects($this->exactly(2))
->method('load') ->method('load')
@ -300,7 +300,7 @@ class TranslatorTest extends TestCase
protected function getLoader() protected function getLoader()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
$loader $loader
->expects($this->exactly(7)) ->expects($this->exactly(7))
->method('load') ->method('load')
@ -336,7 +336,7 @@ class TranslatorTest extends TestCase
protected function getContainer($loader) protected function getContainer($loader)
{ {
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
$container $container
->expects($this->any()) ->expects($this->any())
->method('get') ->method('get')
@ -377,7 +377,7 @@ class TranslatorTest extends TestCase
$translator->setFallbackLocales(['fr']); $translator->setFallbackLocales(['fr']);
$translator->warmup($this->tmpDir); $translator->warmup($this->tmpDir);
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
$loader $loader
->expects($this->never()) ->expects($this->never())
->method('load'); ->method('load');

View File

@ -115,7 +115,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
$loader->load('security_debug.xml'); $loader->load('security_debug.xml');
} }
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) {
$container->removeDefinition('security.expression_language'); $container->removeDefinition('security.expression_language');
$container->removeDefinition('security.access.expression_voter'); $container->removeDefinition('security.access.expression_voter');
} }
@ -707,7 +707,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

@ -610,7 +610,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');
} }
@ -628,14 +628,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

@ -41,7 +41,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);
@ -132,7 +132,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'],
@ -143,7 +143,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

@ -26,7 +26,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();
@ -50,7 +50,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();
@ -71,7 +71,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();
@ -190,7 +190,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', [

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