Merge branch '4.4' into 5.1

* 4.4:
  Use ::class keyword when possible
This commit is contained in:
Fabien Potencier 2021-01-11 10:50:50 +01:00
commit 83b087364b
619 changed files with 2342 additions and 2342 deletions

View File

@ -54,7 +54,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && $metadata->embeddedClasses) {
if ($metadata instanceof ClassMetadataInfo && class_exists(\Doctrine\ORM\Mapping\Embedded::class) && $metadata->embeddedClasses) {
$properties = array_filter($properties, function ($property) {
return false === strpos($property, '.');
});
@ -130,7 +130,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'])];
}

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@ class RegisterMappingsPassTest extends TestCase
{
public function testNoDriverParmeterException()
{
$this->expectException('InvalidArgumentException');
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Could not find the manager name parameter in the container. Tried the following parameter names: "manager.param.one", "manager.param.two"');
$container = $this->createBuilder();
$this->process($container, [

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -32,7 +32,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
{
$this->collection = new ArrayCollection(['test']);
$this->dispatcher = new EventDispatcher();
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
$this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
$this->form = $this->getBuilder()
->getForm();
}

View File

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

View File

@ -19,7 +19,7 @@ class ManagerRegistryTest extends TestCase
{
public static function setUpBeforeClass(): void
{
if (!class_exists('PHPUnit_Framework_TestCase')) {
if (!class_exists(\PHPUnit_Framework_TestCase::class)) {
self::markTestSkipped('proxy-manager-bridge is not yet compatible with namespaced phpunit versions.');
}
$test = new PhpDumperTest();

View File

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

View File

@ -71,7 +71,7 @@ class EntityUserProviderTest extends TestCase
->with('user1')
->willReturn($user);
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
$em = $this->getMockBuilder(\Doctrine\ORM\EntityManager::class)
->disableOriginalConstructor()
->getMock();
$em
@ -86,7 +86,7 @@ class EntityUserProviderTest extends TestCase
public function testLoadUserByUsernameWithNonUserLoaderRepositoryAndWithoutProperty()
{
$this->expectException('InvalidArgumentException');
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('You must either make the "Symfony\Bridge\Doctrine\Tests\Fixtures\User" entity Doctrine Repository ("Doctrine\ORM\EntityRepository") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.');
$em = DoctrineTestHelper::createTestEntityManager();
$this->createSchema($em);
@ -107,7 +107,7 @@ class EntityUserProviderTest extends TestCase
$user1 = new User(null, null, 'user1');
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
$this->expectException('InvalidArgumentException');
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine');
$provider->refreshUser($user1);
}
@ -125,7 +125,7 @@ class EntityUserProviderTest extends TestCase
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
$user2 = new User(1, 2, 'user2');
$this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
$this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class);
$this->expectExceptionMessage('User with id {"id1":1,"id2":2} not found');
$provider->refreshUser($user2);
@ -168,7 +168,7 @@ class EntityUserProviderTest extends TestCase
public function testLoadUserByUserNameShouldDeclineInvalidInterface()
{
$this->expectException('InvalidArgumentException');
$this->expectException(\InvalidArgumentException::class);
$repository = $this->createMock(ObjectRepository::class);
$provider = new EntityUserProvider(

View File

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

View File

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

View File

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

View File

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

View File

@ -330,7 +330,7 @@ class DeprecationErrorHandler
private static function getPhpUnitErrorHandler()
{
if (!isset(self::$isAtLeastPhpUnit83)) {
self::$isAtLeastPhpUnit83 = class_exists('PHPUnit\Util\ErrorHandler') && method_exists('PHPUnit\Util\ErrorHandler', '__invoke');
self::$isAtLeastPhpUnit83 = class_exists(ErrorHandler::class) && method_exists(ErrorHandler::class, '__invoke');
}
if (!self::$isAtLeastPhpUnit83) {
return 'PHPUnit\Util\ErrorHandler::handleError';

View File

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

View File

@ -17,7 +17,7 @@ class BarCovTest extends TestCase
{
public function testBarCov()
{
if (!class_exists('PhpUnitCoverageTest\FooCov')) {
if (!class_exists(\PhpUnitCoverageTest\FooCov::class)) {
$this->markTestSkipped('This test is not part of the main Symfony test suite. It\'s here to test the CoverageListener.');
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -65,7 +65,7 @@ class DebugCommandTest extends TestCase
public function testMalformedTemplateName()
{
$this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException');
$this->expectException(\Symfony\Component\Console\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Malformed namespaced template name "@foo" (expecting "@namespace/template_name").');
$this->createCommandTester()->execute(['name' => '@foo']);
}

View File

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

View File

@ -67,7 +67,7 @@ class DumpExtensionTest extends TestCase
public function testDump($context, $args, $expectedOutput, $debug = true)
{
$extension = new DumpExtension(new VarCloner());
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), [
'debug' => $debug,
'cache' => false,
'optimizations' => 0,
@ -124,7 +124,7 @@ class DumpExtensionTest extends TestCase
'</pre><script>Sfdump("%s")</script>'
);
$extension = new DumpExtension(new VarCloner(), $dumper);
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [
$twig = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), [
'debug' => true,
'cache' => false,
'optimizations' => 0,

View File

@ -50,7 +50,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
'bootstrap_3_horizontal_layout.html.twig',
'custom_widgets.html.twig',
], $environment);
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}

View File

@ -46,7 +46,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
'bootstrap_3_layout.html.twig',
'custom_widgets.html.twig',
], $environment);
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}
@ -88,7 +88,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
'bootstrap_3_layout.html.twig',
'custom_widgets.html.twig',
], $environment);
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
$view = $this->factory

View File

@ -52,7 +52,7 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori
'bootstrap_4_horizontal_layout.html.twig',
'custom_widgets.html.twig',
], $environment);
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}

View File

@ -50,7 +50,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
'bootstrap_4_layout.html.twig',
'custom_widgets.html.twig',
], $environment);
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}
@ -92,7 +92,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
'bootstrap_4_layout.html.twig',
'custom_widgets.html.twig',
], $environment);
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
$view = $this->factory

View File

@ -53,7 +53,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
'form_div_layout.html.twig',
'custom_widgets.html.twig',
], $environment);
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}
@ -181,7 +181,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
'form_div_layout.html.twig',
'custom_widgets.html.twig',
], $environment);
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
$view = $this->factory

View File

@ -50,7 +50,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
'form_table_layout.html.twig',
'custom_widgets.html.twig',
], $environment);
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $this->renderer);
}

View File

@ -60,7 +60,7 @@ class HttpFoundationExtensionTest extends TestCase
*/
public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected)
{
if (!class_exists('Symfony\Component\Routing\RequestContext')) {
if (!class_exists(RequestContext::class)) {
$this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.');
}
@ -75,7 +75,7 @@ class HttpFoundationExtensionTest extends TestCase
*/
public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path)
{
if (!class_exists('Symfony\Component\Routing\RequestContext')) {
if (!class_exists(RequestContext::class)) {
$this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.');
}
@ -118,7 +118,7 @@ class HttpFoundationExtensionTest extends TestCase
*/
public function testGenerateRelativePath($expected, $path, $pathinfo)
{
if (!method_exists('Symfony\Component\HttpFoundation\Request', 'getRelativeUriForPath')) {
if (!method_exists(Request::class, 'getRelativeUriForPath')) {
$this->markTestSkipped('Your version of Symfony HttpFoundation is too old.');
}

View File

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

View File

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

View File

@ -18,7 +18,7 @@ trait RuntimeLoaderProvider
{
protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer)
{
$loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock();
$loader = $this->getMockBuilder(\Twig\RuntimeLoader\RuntimeLoaderInterface::class)->getMock();
$loader->expects($this->any())->method('load')->will($this->returnValueMap([
['Symfony\Component\Form\FormRenderer', $renderer],
]));

View File

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

View File

@ -24,7 +24,7 @@ class DumpNodeTest extends TestCase
{
$node = new DumpNode('bar', null, 7);
$env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock());
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
$compiler = new Compiler($env);
$expected = <<<'EOTXT'
@ -48,7 +48,7 @@ EOTXT;
{
$node = new DumpNode('bar', null, 7);
$env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock());
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
$compiler = new Compiler($env);
$expected = <<<'EOTXT'
@ -75,7 +75,7 @@ EOTXT;
]);
$node = new DumpNode('bar', $vars, 7);
$env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock());
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
$compiler = new Compiler($env);
$expected = <<<'EOTXT'
@ -99,7 +99,7 @@ EOTXT;
]);
$node = new DumpNode('bar', $vars, 7);
$env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock());
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
$compiler = new Compiler($env);
$expected = <<<'EOTXT'

View File

@ -54,7 +54,7 @@ class FormThemeTest extends TestCase
$node = new FormThemeNode($form, $resources, 0);
$environment = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock());
$environment = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock());
$formRenderer = new FormRenderer($this->getMockBuilder(FormRendererEngineInterface::class)->getMock());
$this->registerTwigRuntimeLoader($environment, $formRenderer);
$compiler = new Compiler($environment);

View File

@ -31,7 +31,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
$this->assertEquals(
sprintf(
@ -54,7 +54,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
$this->assertEquals(
sprintf(
@ -74,7 +74,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
$this->assertEquals(
sprintf(
@ -94,7 +94,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@ -116,7 +116,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@ -137,7 +137,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
$this->assertEquals(
sprintf(
@ -161,7 +161,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@ -190,7 +190,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
$this->assertEquals(
sprintf(
@ -218,7 +218,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.
@ -255,7 +255,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
$compiler = new Compiler(new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()));
$compiler = new Compiler(new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock()));
// "label" => null must not be included in the output!
// Otherwise the default label is overwritten with null.

View File

@ -29,7 +29,7 @@ class TransNodeTest extends TestCase
$vars = new NameExpression('foo', 0);
$node = new TransNode($body, null, null, $vars);
$env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]);
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['strict_variables' => true]);
$compiler = new Compiler($env);
$this->assertEquals(

View File

@ -26,7 +26,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase
/** @dataProvider getDefaultDomainAssignmentTestData */
public function testDefaultDomainAssignment(Node $node)
{
$env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag
@ -52,7 +52,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase
/** @dataProvider getDefaultDomainAssignmentTestData */
public function testNewModuleWithoutDefaultDomainTag(Node $node)
{
$env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$visitor = new TranslationDefaultDomainNodeVisitor();
// visit trans_default_domain tag

View File

@ -25,7 +25,7 @@ class TranslationNodeVisitorTest extends TestCase
/** @dataProvider getMessagesExtractionTestData */
public function testMessagesExtraction(Node $node, array $expectedMessages)
{
$env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$visitor = new TranslationNodeVisitor();
$visitor->enable();
$visitor->enterNode($node, $env);

View File

@ -28,7 +28,7 @@ class FormThemeTokenParserTest extends TestCase
*/
public function testCompile($source, $expected)
{
$env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$env = new Environment($this->getMockBuilder(\Twig\Loader\LoaderInterface::class)->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$env->addTokenParser(new FormThemeTokenParser());
$source = new Source($source, '');
$stream = $env->tokenize($source);

View File

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

View File

@ -82,7 +82,7 @@ EOT
new TableSeparator(),
['Version', \PHP_VERSION],
['Architecture', (\PHP_INT_SIZE * 8).' bits'],
['Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'],
['Intl locale', class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'],
['Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'],
['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -82,7 +82,7 @@ class AbstractControllerTest extends TestCase
public function testMissingParameterBag()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
$this->expectExceptionMessage('TestAbstractController::getParameter()" method is missing a parameter bag');
$container = new Container();

View File

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

View File

@ -54,7 +54,7 @@ class WorkflowGuardListenerPassTest extends TestCase
public function testExceptionIfTheTokenStorageServiceIsNotPresent()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
$this->expectExceptionMessage('The "security.token_storage" service is needed to be able to use the workflow guard listener.');
$this->container->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
@ -66,7 +66,7 @@ class WorkflowGuardListenerPassTest extends TestCase
public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
$this->expectExceptionMessage('The "security.authorization_checker" service is needed to be able to use the workflow guard listener.');
$this->container->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.token_storage', TokenStorageInterface::class);
@ -78,7 +78,7 @@ class WorkflowGuardListenerPassTest extends TestCase
public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
$this->expectExceptionMessage('The "security.authentication.trust_resolver" service is needed to be able to use the workflow guard listener.');
$this->container->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.token_storage', TokenStorageInterface::class);
@ -90,7 +90,7 @@ class WorkflowGuardListenerPassTest extends TestCase
public function testExceptionIfTheRoleHierarchyServiceIsNotPresent()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
$this->expectExceptionMessage('The "security.role_hierarchy" service is needed to be able to use the workflow guard listener.');
$this->container->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.token_storage', TokenStorageInterface::class);

View File

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

View File

@ -67,7 +67,7 @@ class CachePoolClearCommandTest extends AbstractWebTestCase
public function testClearUnexistingPool()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
$this->expectExceptionMessage('You have requested a non-existent service "unknown_pool"');
$this->createCommandTester()
->execute(['pools' => ['unknown_pool']], ['decorated' => false]);

View File

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

View File

@ -39,7 +39,7 @@ class MicroKernelTraitTest extends TestCase
$this->assertEquals('halloween', $response->getContent());
$this->assertEquals('Have a great day!', $kernel->getContainer()->getParameter('halloween'));
$this->assertInstanceOf('stdClass', $kernel->getContainer()->get('halloween'));
$this->assertInstanceOf(\stdClass::class, $kernel->getContainer()->get('halloween'));
}
public function testAsEventSubscriber()

View File

@ -138,7 +138,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
$loader->load('security_debug.xml');
}
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) {
$container->removeDefinition('security.expression_language');
$container->removeDefinition('security.access.expression_voter');
}
@ -842,7 +842,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
return $this->expressions[$id];
}
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
if (!class_exists(\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) {
throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
}

View File

@ -24,7 +24,7 @@ class AddSecurityVotersPassTest extends TestCase
{
public function testNoVoters()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
$this->expectException(LogicException::class);
$this->expectExceptionMessage('No security voters found. You need to tag at least one with "security.voter".');
$container = new ContainerBuilder();
$container

View File

@ -597,7 +597,7 @@ abstract class CompleteConfigurationTest extends TestCase
public function testAccessDecisionManagerServiceAndStrategyCannotBeUsedAtTheSameTime()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('Invalid configuration for path "security.access_decision_manager": "strategy" and "service" cannot be used together.');
$this->getContainer('access_decision_manager_service_and_strategy');
}
@ -615,14 +615,14 @@ abstract class CompleteConfigurationTest extends TestCase
public function testFirewallUndefinedUserProvider()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
$this->getContainer('firewall_undefined_provider');
}
public function testFirewallListenerUndefinedProvider()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('Invalid firewall "main": user provider "undefined" not found.');
$this->getContainer('listener_undefined_provider');
}

View File

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

View File

@ -127,7 +127,7 @@ class AbstractFactoryTest extends TestCase
protected function callFactory($id, $config, $userProviderId, $defaultEntryPointId)
{
$factory = $this->getMockForAbstractClass('Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory', []);
$factory = $this->getMockForAbstractClass(\Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory::class, []);
$factory
->expects($this->once())

View File

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

View File

@ -40,7 +40,7 @@ class SecurityExtensionTest extends TestCase
{
public function testInvalidCheckPath()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('The check_path "/some_area/login_check" for login method "form_login" is not matched by the firewall pattern "/secured_area/.*".');
$container = $this->getRawContainer();
@ -64,7 +64,7 @@ class SecurityExtensionTest extends TestCase
public function testFirewallWithoutAuthenticationListener()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('No authentication listener registered for firewall "some_firewall"');
$container = $this->getRawContainer();
@ -85,7 +85,7 @@ class SecurityExtensionTest extends TestCase
public function testFirewallWithInvalidUserProvider()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('Unable to create definition for "security.user.provider.concrete.my_foo" user provider');
$container = $this->getRawContainer();
@ -204,7 +204,7 @@ class SecurityExtensionTest extends TestCase
public function testMissingProviderForListener()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('Not configuring explicitly the provider for the "http_basic" listener on "ambiguous" firewall is ambiguous as there is more than one registered provider.');
$container = $this->getRawContainer();
$container->loadFromExtension('security', [

View File

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

View File

@ -23,23 +23,23 @@ class ExtensionPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!class_exists('Symfony\Component\Asset\Packages')) {
if (!class_exists(\Symfony\Component\Asset\Packages::class)) {
$container->removeDefinition('twig.extension.assets');
}
if (!class_exists('Symfony\Component\ExpressionLanguage\Expression')) {
if (!class_exists(\Symfony\Component\ExpressionLanguage\Expression::class)) {
$container->removeDefinition('twig.extension.expression');
}
if (!interface_exists('Symfony\Component\Routing\Generator\UrlGeneratorInterface')) {
if (!interface_exists(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class)) {
$container->removeDefinition('twig.extension.routing');
}
if (!class_exists('Symfony\Component\Yaml\Yaml')) {
if (!class_exists(\Symfony\Component\Yaml\Yaml::class)) {
$container->removeDefinition('twig.extension.yaml');
}
$viewDir = \dirname((new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension'))->getFileName(), 2).'/Resources/views';
$viewDir = \dirname((new \ReflectionClass(\Symfony\Bridge\Twig\Extension\FormExtension::class))->getFileName(), 2).'/Resources/views';
$templateIterator = $container->getDefinition('twig.template_iterator');
$templatePaths = $templateIterator->getArgument(1);
$cacheWarmer = null;
@ -121,7 +121,7 @@ class ExtensionPass implements CompilerPassInterface
$container->getDefinition('twig.extension.yaml')->addTag('twig.extension');
}
if (class_exists('Symfony\Component\Stopwatch\Stopwatch')) {
if (class_exists(\Symfony\Component\Stopwatch\Stopwatch::class)) {
$container->getDefinition('twig.extension.debug.stopwatch')->addTag('twig.extension');
}

View File

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

View File

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

View File

@ -17,11 +17,11 @@ class TemplateIteratorTest extends TestCase
{
public function testGetIterator()
{
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
$bundle->expects($this->any())->method('getName')->willReturn('BarBundle');
$bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock();
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class)->disableOriginalConstructor()->getMock();
$kernel->expects($this->any())->method('getBundles')->willReturn([
$bundle,
]);

View File

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

View File

@ -210,7 +210,7 @@ class ContentSecurityPolicyHandlerTest extends TestCase
private function mockNonceGenerator($value)
{
$generator = $this->getMockBuilder('Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator')->getMock();
$generator = $this->getMockBuilder(\Symfony\Bundle\WebProfilerBundle\Csp\NonceGenerator::class)->getMock();
$generator->expects($this->any())
->method('generate')

View File

@ -51,7 +51,7 @@ class WebProfilerExtensionTest extends TestCase
{
parent::setUp();
$this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock();
$this->kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
$this->container = new ContainerBuilder();
$this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true);

View File

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

View File

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

View File

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

View File

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

View File

@ -77,7 +77,7 @@ class PathPackageTest extends TestCase
public function testVersionStrategyGivesAbsoluteURL()
{
$versionStrategy = $this->getMockBuilder('Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface')->getMock();
$versionStrategy = $this->getMockBuilder(\Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface::class)->getMock();
$versionStrategy->expects($this->any())
->method('applyVersion')
->willReturn('https://cdn.com/bar/main.css');
@ -88,7 +88,7 @@ class PathPackageTest extends TestCase
private function getContext($basePath)
{
$context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock();
$context = $this->getMockBuilder(\Symfony\Component\Asset\Context\ContextInterface::class)->getMock();
$context->expects($this->any())->method('getBasePath')->willReturn($basePath);
return $context;

View File

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

View File

@ -39,14 +39,14 @@ class JsonManifestVersionStrategyTest extends TestCase
public function testMissingManifestFileThrowsException()
{
$this->expectException('RuntimeException');
$this->expectException(\RuntimeException::class);
$strategy = $this->createStrategy('non-existent-file.json');
$strategy->getVersion('main.js');
}
public function testManifestFileWithBadJSONThrowsException()
{
$this->expectException('RuntimeException');
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Error parsing JSON');
$strategy = $this->createStrategy('manifest-invalid.json');
$strategy->getVersion('main.js');

View File

@ -77,7 +77,7 @@ class AbstractBrowserTest extends TestCase
$client->request('GET', 'http://example.com/');
$this->assertSame('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request');
$this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request');
$this->assertInstanceOf(Response::class, $client->getResponse(), '->getCrawler() returns the Response of the last request');
}
public function testGetResponseNull()
@ -285,7 +285,7 @@ class AbstractBrowserTest extends TestCase
$client->clickLink('foo');
$this->fail('->clickLink() throws a \InvalidArgumentException if the link could not be found');
} catch (\Exception $e) {
$this->assertInstanceOf('InvalidArgumentException', $e, '->clickLink() throws a \InvalidArgumentException if the link could not be found');
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->clickLink() throws a \InvalidArgumentException if the link could not be found');
}
}
@ -344,7 +344,7 @@ class AbstractBrowserTest extends TestCase
], 'POST');
$this->fail('->submitForm() throws a \InvalidArgumentException if the form could not be found');
} catch (\Exception $e) {
$this->assertInstanceOf('InvalidArgumentException', $e, '->submitForm() throws a \InvalidArgumentException if the form could not be found');
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->submitForm() throws a \InvalidArgumentException if the form could not be found');
}
}
@ -395,7 +395,7 @@ class AbstractBrowserTest extends TestCase
$client->followRedirect();
$this->fail('->followRedirect() throws a \LogicException if the request was not redirected');
} catch (\Exception $e) {
$this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected');
$this->assertInstanceOf(\LogicException::class, $e, '->followRedirect() throws a \LogicException if the request was not redirected');
}
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
@ -425,7 +425,7 @@ class AbstractBrowserTest extends TestCase
$client->followRedirect();
$this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
} catch (\Exception $e) {
$this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
$this->assertInstanceOf(\LogicException::class, $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code');
}
}
@ -455,7 +455,7 @@ class AbstractBrowserTest extends TestCase
$client->followRedirect();
$this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
} catch (\Exception $e) {
$this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
$this->assertInstanceOf(\LogicException::class, $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached');
}
$client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected']));
@ -738,7 +738,7 @@ class AbstractBrowserTest extends TestCase
$client->request('GET', 'http://www.example.com/foo/foobar');
$this->fail('->request() throws a \RuntimeException if the script has an error');
} catch (\Exception $e) {
$this->assertInstanceOf('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error');
$this->assertInstanceOf(\RuntimeException::class, $e, '->request() throws a \RuntimeException if the script has an error');
}
}
@ -826,7 +826,7 @@ class AbstractBrowserTest extends TestCase
'NEW_SERVER_KEY' => 'new-server-key-value',
]);
$this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest());
$this->assertInstanceOf(\Symfony\Component\BrowserKit\Request::class, $client->getInternalRequest());
}
public function testInternalRequestNull()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -68,7 +68,7 @@ class MaxIdLengthAdapterTest extends TestCase
public function testTooLongNamespace()
{
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Namespace must be 26 chars max, 40 given ("----------------------------------------")');
$this->getMockBuilder(MaxIdLengthAdapter::class)
->setConstructorArgs([str_repeat('-', 40)])

View File

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

View File

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

View File

@ -21,7 +21,7 @@ class RedisAdapterSentinelTest extends AbstractRedisAdapterTest
{
public static function setUpBeforeClass(): void
{
if (!class_exists('Predis\Client')) {
if (!class_exists(\Predis\Client::class)) {
self::markTestSkipped('The Predis\Client class is required.');
}
if (!$hosts = getenv('REDIS_SENTINEL_HOSTS')) {
@ -36,7 +36,7 @@ class RedisAdapterSentinelTest extends AbstractRedisAdapterTest
public function testInvalidDSNHasBothClusterAndSentinel()
{
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Cannot use both "redis_cluster" and "redis_sentinel" at the same time:');
$dsn = 'redis:?host[redis1]&host[redis2]&host[redis3]&redis_cluster=1&redis_sentinel=mymaster';
RedisAdapter::createConnection($dsn);

View File

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

View File

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

View File

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

View File

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

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