minor #39782 Use ::class keyword when possible (fabpot)

This PR was merged into the 5.1 branch.

Discussion
----------

Use ::class keyword when possible

| Q             | A
| ------------- | ---
| Branch?       | 5.1 <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | n/a

Commits
-------

1f3a29ba83 Use ::class keyword when possible
This commit is contained in:
Fabien Potencier 2021-01-11 11:43:27 +01:00
commit b2fa4053b2
97 changed files with 622 additions and 617 deletions

View File

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

View File

@ -85,7 +85,7 @@ class DoctrineExtractorTest extends TestCase
public function testTestGetPropertiesWithEmbedded() public function testTestGetPropertiesWithEmbedded()
{ {
if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { if (!class_exists(\Doctrine\ORM\Mapping\Embedded::class)) {
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
} }
@ -108,7 +108,7 @@ class DoctrineExtractorTest extends TestCase
public function testExtractWithEmbedded() public function testExtractWithEmbedded()
{ {
if (!class_exists('Doctrine\ORM\Mapping\Embedded')) { if (!class_exists(\Doctrine\ORM\Mapping\Embedded::class)) {
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
} }

View File

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

View File

@ -206,7 +206,7 @@ class FrameworkExtension extends Extension
// default in the Form and Validator component). If disabled, an identity // default in the Form and Validator component). If disabled, an identity
// translator will be used and everything will still work as expected. // translator will be used and everything will still work as expected.
if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) { if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) {
if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['translator'])) { if (!class_exists(Translator::class) && $this->isConfigEnabled($container, $config['translator'])) {
throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".'); throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".');
} }
@ -289,14 +289,14 @@ class FrameworkExtension extends Extension
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader); $this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
if ($this->isConfigEnabled($container, $config['form'])) { if ($this->isConfigEnabled($container, $config['form'])) {
if (!class_exists('Symfony\Component\Form\Form')) { if (!class_exists(\Symfony\Component\Form\Form::class)) {
throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".'); throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
} }
$this->formConfigEnabled = true; $this->formConfigEnabled = true;
$this->registerFormConfiguration($config, $container, $loader); $this->registerFormConfiguration($config, $container, $loader);
if (class_exists('Symfony\Component\Validator\Validation')) { if (class_exists(\Symfony\Component\Validator\Validation::class)) {
$config['validation']['enabled'] = true; $config['validation']['enabled'] = true;
} else { } else {
$container->setParameter('validator.translation_domain', 'validators'); $container->setParameter('validator.translation_domain', 'validators');
@ -309,7 +309,7 @@ class FrameworkExtension extends Extension
} }
if ($this->isConfigEnabled($container, $config['assets'])) { if ($this->isConfigEnabled($container, $config['assets'])) {
if (!class_exists('Symfony\Component\Asset\Package')) { if (!class_exists(\Symfony\Component\Asset\Package::class)) {
throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".'); throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".');
} }
@ -376,7 +376,7 @@ class FrameworkExtension extends Extension
$this->registerSecretsConfiguration($config['secrets'], $container, $loader); $this->registerSecretsConfiguration($config['secrets'], $container, $loader);
if ($this->isConfigEnabled($container, $config['serializer'])) { if ($this->isConfigEnabled($container, $config['serializer'])) {
if (!class_exists('Symfony\Component\Serializer\Serializer')) { if (!class_exists(\Symfony\Component\Serializer\Serializer::class)) {
throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".'); throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
} }
@ -1114,18 +1114,18 @@ class FrameworkExtension extends Extension
$dirs = []; $dirs = [];
$transPaths = []; $transPaths = [];
$nonExistingDirs = []; $nonExistingDirs = [];
if (class_exists('Symfony\Component\Validator\Validation')) { if (class_exists(\Symfony\Component\Validator\Validation::class)) {
$r = new \ReflectionClass('Symfony\Component\Validator\Validation'); $r = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
$dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations'; $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
} }
if (class_exists('Symfony\Component\Form\Form')) { if (class_exists(\Symfony\Component\Form\Form::class)) {
$r = new \ReflectionClass('Symfony\Component\Form\Form'); $r = new \ReflectionClass(\Symfony\Component\Form\Form::class);
$dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations'; $dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
} }
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { if (class_exists(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)) {
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); $r = new \ReflectionClass(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
$dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations'; $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
} }
@ -1208,7 +1208,7 @@ class FrameworkExtension extends Extension
return; return;
} }
if (!class_exists('Symfony\Component\Validator\Validation')) { if (!class_exists(\Symfony\Component\Validator\Validation::class)) {
throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".'); throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
} }
@ -1272,8 +1272,8 @@ class FrameworkExtension extends Extension
$files['yaml' === $extension ? 'yml' : $extension][] = $path; $files['yaml' === $extension ? 'yml' : $extension][] = $path;
}; };
if (interface_exists('Symfony\Component\Form\FormInterface')) { if (interface_exists(\Symfony\Component\Form\FormInterface::class)) {
$reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface'); $reflClass = new \ReflectionClass(\Symfony\Component\Form\FormInterface::class);
$fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml'); $fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
} }
@ -1334,7 +1334,7 @@ class FrameworkExtension extends Extension
return; return;
} }
if (!class_exists('Doctrine\Common\Annotations\Annotation')) { if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) {
throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.'); throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
} }
@ -1346,7 +1346,7 @@ class FrameworkExtension extends Extension
} }
if ('none' !== $config['cache']) { if ('none' !== $config['cache']) {
if (!class_exists('Doctrine\Common\Cache\CacheProvider')) { if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.'); throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
} }
@ -1452,7 +1452,7 @@ class FrameworkExtension extends Extension
return; return;
} }
if (!class_exists('Symfony\Component\Security\Csrf\CsrfToken')) { if (!class_exists(\Symfony\Component\Security\Csrf\CsrfToken::class)) {
throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".'); throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
} }
@ -1563,7 +1563,7 @@ class FrameworkExtension extends Extension
$loader->load('property_info.xml'); $loader->load('property_info.xml');
if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) { if (interface_exists(\phpDocumentor\Reflection\DocBlockFactoryInterface::class)) {
$definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor'); $definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
$definition->setPrivate(true); $definition->setPrivate(true);
$definition->addTag('property_info.description_extractor', ['priority' => -1000]); $definition->addTag('property_info.description_extractor', ['priority' => -1000]);

View File

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

View File

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

View File

@ -30,7 +30,7 @@ class ApplicationTest extends TestCase
{ {
public function testBundleInterfaceImplementation() public function testBundleInterfaceImplementation()
{ {
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
$kernel = $this->getKernel([$bundle], true); $kernel = $this->getKernel([$bundle], true);
@ -236,10 +236,10 @@ class ApplicationTest extends TestCase
private function getKernel(array $bundles, $useDispatcher = false) private function getKernel(array $bundles, $useDispatcher = false)
{ {
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
if ($useDispatcher) { if ($useDispatcher) {
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
$dispatcher $dispatcher
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('dispatch') ->method('dispatch')
@ -264,7 +264,7 @@ class ApplicationTest extends TestCase
->willReturnOnConsecutiveCalls([], []) ->willReturnOnConsecutiveCalls([], [])
; ;
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
$kernel->expects($this->once())->method('boot'); $kernel->expects($this->once())->method('boot');
$kernel $kernel
->expects($this->any()) ->expects($this->any())
@ -282,7 +282,7 @@ class ApplicationTest extends TestCase
private function createBundleMock(array $commands) private function createBundleMock(array $commands)
{ {
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock();
$bundle $bundle
->expects($this->once()) ->expects($this->once())
->method('registerCommands') ->method('registerCommands')

View File

@ -101,7 +101,7 @@ class AbstractControllerTest extends TestCase
$requestStack = new RequestStack(); $requestStack = new RequestStack();
$requestStack->push($request); $requestStack->push($request);
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock();
$kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
return new Response($request->getRequestFormat().'--'.$request->getLocale()); return new Response($request->getRequestFormat().'--'.$request->getLocale());
}); });
@ -148,7 +148,7 @@ class AbstractControllerTest extends TestCase
public function testGetUserWithEmptyContainer() public function testGetUserWithEmptyContainer()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('The SecurityBundle is not registered in your application.'); $this->expectExceptionMessage('The SecurityBundle is not registered in your application.');
$controller = $this->createController(); $controller = $this->createController();
@ -162,7 +162,7 @@ class AbstractControllerTest extends TestCase
*/ */
private function getContainerWithTokenStorage($token = null): Container private function getContainerWithTokenStorage($token = null): Container
{ {
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage')->getMock(); $tokenStorage = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::class)->getMock();
$tokenStorage $tokenStorage
->expects($this->once()) ->expects($this->once())
->method('getToken') ->method('getToken')
@ -231,7 +231,7 @@ class AbstractControllerTest extends TestCase
public function testFile() public function testFile()
{ {
$container = new Container(); $container = new Container();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock();
$container->set('http_kernel', $kernel); $container->set('http_kernel', $kernel);
$controller = $this->createController(); $controller = $this->createController();
@ -332,7 +332,7 @@ class AbstractControllerTest extends TestCase
public function testFileWhichDoesNotExist() public function testFileWhichDoesNotExist()
{ {
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); $this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class);
$controller = $this->createController(); $controller = $this->createController();
@ -341,7 +341,7 @@ class AbstractControllerTest extends TestCase
public function testIsGranted() public function testIsGranted()
{ {
$authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); $authorizationChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class)->getMock();
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(true);
$container = new Container(); $container = new Container();
@ -355,9 +355,9 @@ class AbstractControllerTest extends TestCase
public function testdenyAccessUnlessGranted() public function testdenyAccessUnlessGranted()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException'); $this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class);
$authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock(); $authorizationChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class)->getMock();
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false); $authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false);
$container = new Container(); $container = new Container();
@ -371,7 +371,7 @@ class AbstractControllerTest extends TestCase
public function testRenderViewTwig() public function testRenderViewTwig()
{ {
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
$twig->expects($this->once())->method('render')->willReturn('bar'); $twig->expects($this->once())->method('render')->willReturn('bar');
$container = new Container(); $container = new Container();
@ -385,7 +385,7 @@ class AbstractControllerTest extends TestCase
public function testRenderTwig() public function testRenderTwig()
{ {
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
$twig->expects($this->once())->method('render')->willReturn('bar'); $twig->expects($this->once())->method('render')->willReturn('bar');
$container = new Container(); $container = new Container();
@ -399,7 +399,7 @@ class AbstractControllerTest extends TestCase
public function testStreamTwig() public function testStreamTwig()
{ {
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
$container = new Container(); $container = new Container();
$container->set('twig', $twig); $container->set('twig', $twig);
@ -407,12 +407,12 @@ class AbstractControllerTest extends TestCase
$controller = $this->createController(); $controller = $this->createController();
$controller->setContainer($container); $controller->setContainer($container);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo')); $this->assertInstanceOf(\Symfony\Component\HttpFoundation\StreamedResponse::class, $controller->stream('foo'));
} }
public function testRedirectToRoute() public function testRedirectToRoute()
{ {
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock();
$router->expects($this->once())->method('generate')->willReturn('/foo'); $router->expects($this->once())->method('generate')->willReturn('/foo');
$container = new Container(); $container = new Container();
@ -422,7 +422,7 @@ class AbstractControllerTest extends TestCase
$controller->setContainer($container); $controller->setContainer($container);
$response = $controller->redirectToRoute('foo'); $response = $controller->redirectToRoute('foo');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response);
$this->assertSame('/foo', $response->getTargetUrl()); $this->assertSame('/foo', $response->getTargetUrl());
$this->assertSame(302, $response->getStatusCode()); $this->assertSame(302, $response->getStatusCode());
} }
@ -433,7 +433,7 @@ class AbstractControllerTest extends TestCase
public function testAddFlash() public function testAddFlash()
{ {
$flashBag = new FlashBag(); $flashBag = new FlashBag();
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->getMock(); $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class)->getMock();
$session->expects($this->once())->method('getFlashBag')->willReturn($flashBag); $session->expects($this->once())->method('getFlashBag')->willReturn($flashBag);
$container = new Container(); $container = new Container();
@ -450,12 +450,12 @@ class AbstractControllerTest extends TestCase
{ {
$controller = $this->createController(); $controller = $this->createController();
$this->assertInstanceOf('Symfony\Component\Security\Core\Exception\AccessDeniedException', $controller->createAccessDeniedException()); $this->assertInstanceOf(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class, $controller->createAccessDeniedException());
} }
public function testIsCsrfTokenValid() public function testIsCsrfTokenValid()
{ {
$tokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); $tokenManager = $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock();
$tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true); $tokenManager->expects($this->once())->method('isTokenValid')->willReturn(true);
$container = new Container(); $container = new Container();
@ -469,7 +469,7 @@ class AbstractControllerTest extends TestCase
public function testGenerateUrl() public function testGenerateUrl()
{ {
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock(); $router = $this->getMockBuilder(\Symfony\Component\Routing\RouterInterface::class)->getMock();
$router->expects($this->once())->method('generate')->willReturn('/foo'); $router->expects($this->once())->method('generate')->willReturn('/foo');
$container = new Container(); $container = new Container();
@ -486,7 +486,7 @@ class AbstractControllerTest extends TestCase
$controller = $this->createController(); $controller = $this->createController();
$response = $controller->redirect('http://dunglas.fr', 301); $response = $controller->redirect('http://dunglas.fr', 301);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); $this->assertInstanceOf(\Symfony\Component\HttpFoundation\RedirectResponse::class, $response);
$this->assertSame('http://dunglas.fr', $response->getTargetUrl()); $this->assertSame('http://dunglas.fr', $response->getTargetUrl());
$this->assertSame(301, $response->getStatusCode()); $this->assertSame(301, $response->getStatusCode());
} }
@ -495,14 +495,14 @@ class AbstractControllerTest extends TestCase
{ {
$controller = $this->createController(); $controller = $this->createController();
$this->assertInstanceOf('Symfony\Component\HttpKernel\Exception\NotFoundHttpException', $controller->createNotFoundException()); $this->assertInstanceOf(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class, $controller->createNotFoundException());
} }
public function testCreateForm() public function testCreateForm()
{ {
$form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock()); $form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock());
$formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $formFactory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
$formFactory->expects($this->once())->method('create')->willReturn($form); $formFactory->expects($this->once())->method('create')->willReturn($form);
$container = new Container(); $container = new Container();
@ -516,9 +516,9 @@ class AbstractControllerTest extends TestCase
public function testCreateFormBuilder() public function testCreateFormBuilder()
{ {
$formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilderInterface')->getMock(); $formBuilder = $this->getMockBuilder(\Symfony\Component\Form\FormBuilderInterface::class)->getMock();
$formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $formFactory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
$formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder); $formFactory->expects($this->once())->method('createBuilder')->willReturn($formBuilder);
$container = new Container(); $container = new Container();
@ -532,7 +532,7 @@ class AbstractControllerTest extends TestCase
public function testGetDoctrine() public function testGetDoctrine()
{ {
$doctrine = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')->getMock(); $doctrine = $this->getMockBuilder(\Doctrine\Persistence\ManagerRegistry::class)->getMock();
$container = new Container(); $container = new Container();
$container->set('doctrine', $doctrine); $container->set('doctrine', $doctrine);

View File

@ -31,8 +31,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest
$controller = $resolver->getController($request); $controller = $resolver->getController($request);
$this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller[0]); $this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller[0]);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller[0]->getContainer()); $this->assertInstanceOf(ContainerInterface::class, $controller[0]->getContainer());
$this->assertSame('testAction', $controller[1]); $this->assertSame('testAction', $controller[1]);
} }
@ -44,8 +44,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest
$controller = $resolver->getController($request); $controller = $resolver->getController($request);
$this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller); $this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller->getContainer()); $this->assertInstanceOf(ContainerInterface::class, $controller->getContainer());
} }
public function testContainerAwareControllerGetsContainerWhenNotSet() public function testContainerAwareControllerGetsContainerWhenNotSet()
@ -68,7 +68,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
public function testAbstractControllerGetsContainerWhenNotSet() public function testAbstractControllerGetsContainerWhenNotSet()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('"Symfony\\Bundle\\FrameworkBundle\\Tests\\Controller\\TestAbstractController" has no container set, did you forget to define it as a service subscriber?'); $this->expectExceptionMessage('"Symfony\\Bundle\\FrameworkBundle\\Tests\\Controller\\TestAbstractController" has no container set, did you forget to define it as a service subscriber?');
class_exists(AbstractControllerTest::class); class_exists(AbstractControllerTest::class);
@ -89,7 +89,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
public function testAbstractControllerServiceWithFqcnIdGetsContainerWhenNotSet() public function testAbstractControllerServiceWithFqcnIdGetsContainerWhenNotSet()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('"Symfony\\Bundle\\FrameworkBundle\\Tests\\Controller\\DummyController" has no container set, did you forget to define it as a service subscriber?'); $this->expectExceptionMessage('"Symfony\\Bundle\\FrameworkBundle\\Tests\\Controller\\DummyController" has no container set, did you forget to define it as a service subscriber?');
class_exists(AbstractControllerTest::class); class_exists(AbstractControllerTest::class);
@ -159,12 +159,12 @@ class ControllerResolverTest extends ContainerControllerResolverTest
protected function createMockParser() protected function createMockParser()
{ {
return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser')->disableOriginalConstructor()->getMock(); return $this->getMockBuilder(\Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser::class)->disableOriginalConstructor()->getMock();
} }
protected function createMockContainer() protected function createMockContainer()
{ {
return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); return $this->getMockBuilder(ContainerInterface::class)->getMock();
} }
} }

View File

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

View File

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

View File

@ -25,7 +25,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
public function testAssetsCannotHavePathAndUrl() public function testAssetsCannotHavePathAndUrl()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->createContainerFromClosure(function ($container) { $this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [ $container->loadFromExtension('framework', [
'assets' => [ 'assets' => [
@ -38,7 +38,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
public function testAssetPackageCannotHavePathAndUrl() public function testAssetPackageCannotHavePathAndUrl()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->createContainerFromClosure(function ($container) { $this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [ $container->loadFromExtension('framework', [
'assets' => [ 'assets' => [
@ -55,7 +55,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
public function testWorkflowValidationStateMachine() public function testWorkflowValidationStateMachine()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class);
$this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "a_to_b" from place/state "a" were found on StateMachine "article".'); $this->expectExceptionMessage('A transition from a place/state must have an unique name. Multiple transitions named "a_to_b" from place/state "a" were found on StateMachine "article".');
$this->createContainerFromClosure(function ($container) { $this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [ $container->loadFromExtension('framework', [

View File

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

View File

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

View File

@ -37,7 +37,7 @@ class TwigExtension extends Extension
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('twig.xml'); $loader->load('twig.xml');
if (class_exists('Symfony\Component\Form\Form')) { if (class_exists(\Symfony\Component\Form\Form::class)) {
$loader->load('form.xml'); $loader->load('form.xml');
} }

View File

@ -42,7 +42,7 @@ class RemoteJsonManifestVersionStrategyTest extends TestCase
public function testMissingManifestFileThrowsException() public function testMissingManifestFileThrowsException()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('HTTP 404 returned for "https://cdn.example.com/non-existent-file.json"'); $this->expectExceptionMessage('HTTP 404 returned for "https://cdn.example.com/non-existent-file.json"');
$strategy = $this->createStrategy('https://cdn.example.com/non-existent-file.json'); $strategy = $this->createStrategy('https://cdn.example.com/non-existent-file.json');
$strategy->getVersion('main.js'); $strategy->getVersion('main.js');

View File

@ -111,7 +111,7 @@ abstract class AbstractBrowser
*/ */
public function insulate(bool $insulated = true) public function insulate(bool $insulated = true)
{ {
if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) { if ($insulated && !class_exists(\Symfony\Component\Process\Process::class)) {
throw new \LogicException('Unable to isolate requests as the Symfony Process Component is not installed.'); throw new \LogicException('Unable to isolate requests as the Symfony Process Component is not installed.');
} }
@ -503,7 +503,7 @@ abstract class AbstractBrowser
*/ */
protected function createCrawlerFromContent(string $uri, string $content, string $type) protected function createCrawlerFromContent(string $uri, string $content, string $type)
{ {
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { if (!class_exists(Crawler::class)) {
return null; return null;
} }

View File

@ -45,7 +45,7 @@ class AbstractBrowserTest extends TestCase
public function testGetRequestNull() public function testGetRequestNull()
{ {
$this->expectException('Symfony\Component\BrowserKit\Exception\BadMethodCallException'); $this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getRequest()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getRequest()".');
$client = $this->getBrowser(); $client = $this->getBrowser();
@ -82,7 +82,7 @@ class AbstractBrowserTest extends TestCase
public function testGetResponseNull() public function testGetResponseNull()
{ {
$this->expectException('Symfony\Component\BrowserKit\Exception\BadMethodCallException'); $this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getResponse()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getResponse()".');
$client = $this->getBrowser(); $client = $this->getBrowser();
@ -91,7 +91,7 @@ class AbstractBrowserTest extends TestCase
public function testGetInternalResponseNull() public function testGetInternalResponseNull()
{ {
$this->expectException('Symfony\Component\BrowserKit\Exception\BadMethodCallException'); $this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalResponse()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalResponse()".');
$client = $this->getBrowser(); $client = $this->getBrowser();
@ -118,7 +118,7 @@ class AbstractBrowserTest extends TestCase
public function testGetCrawlerNull() public function testGetCrawlerNull()
{ {
$this->expectException('Symfony\Component\BrowserKit\Exception\BadMethodCallException'); $this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getCrawler()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getCrawler()".');
$client = $this->getBrowser(); $client = $this->getBrowser();
@ -831,7 +831,7 @@ class AbstractBrowserTest extends TestCase
public function testInternalRequestNull() public function testInternalRequestNull()
{ {
$this->expectException('Symfony\Component\BrowserKit\Exception\BadMethodCallException'); $this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalRequest()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalRequest()".');
$client = $this->getBrowser(); $client = $this->getBrowser();

View File

@ -82,7 +82,7 @@ class ApcuAdapter extends AbstractAdapter
*/ */
protected function doClear(string $namespace) protected function doClear(string $namespace)
{ {
return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) return isset($namespace[0]) && class_exists(\APCuIterator::class, false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))
? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY)) ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY))
: apcu_clear_cache(); : apcu_clear_cache();
} }

View File

@ -18,7 +18,7 @@ class ConfigCacheFactoryTest extends TestCase
{ {
public function testCacheWithInvalidCallback() public function testCacheWithInvalidCallback()
{ {
$this->expectException('TypeError'); $this->expectException(\TypeError::class);
$cacheFactory = new ConfigCacheFactory(true); $cacheFactory = new ConfigCacheFactory(true);
$cacheFactory->cache('file', new \stdClass()); $cacheFactory->cache('file', new \stdClass());

View File

@ -80,7 +80,7 @@ class ScalarNodeTest extends TestCase
*/ */
public function testNormalizeThrowsExceptionOnInvalidValues($value) public function testNormalizeThrowsExceptionOnInvalidValues($value)
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class);
$node = new ScalarNode('test'); $node = new ScalarNode('test');
$node->normalize($value); $node->normalize($value);
} }
@ -98,7 +98,7 @@ class ScalarNodeTest extends TestCase
{ {
$node = new ScalarNode('test'); $node = new ScalarNode('test');
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class);
$this->expectExceptionMessage('Invalid type for path "test". Expected "scalar", but got "array".'); $this->expectExceptionMessage('Invalid type for path "test". Expected "scalar", but got "array".');
$node->normalize([]); $node->normalize([]);
@ -109,7 +109,7 @@ class ScalarNodeTest extends TestCase
$node = new ScalarNode('test'); $node = new ScalarNode('test');
$node->setInfo('"the test value"'); $node->setInfo('"the test value"');
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class);
$this->expectExceptionMessage("Invalid type for path \"test\". Expected \"scalar\", but got \"array\".\nHint: \"the test value\""); $this->expectExceptionMessage("Invalid type for path \"test\". Expected \"scalar\", but got \"array\".\nHint: \"the test value\"");
$node->normalize([]); $node->normalize([]);
@ -148,7 +148,7 @@ class ScalarNodeTest extends TestCase
*/ */
public function testNotAllowedEmptyValuesThrowException($value) public function testNotAllowedEmptyValuesThrowException($value)
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$node = new ScalarNode('test'); $node = new ScalarNode('test');
$node->setAllowEmptyValue(false); $node->setAllowEmptyValue(false);
$node->finalize($value); $node->finalize($value);

View File

@ -738,7 +738,7 @@ class ApplicationTest extends TestCase
$application->add(new \FooCommand()); $application->add(new \FooCommand());
$application->add(new \FooHiddenCommand()); $application->add(new \FooHiddenCommand());
$this->assertInstanceOf('FooCommand', $application->find('foo:')); $this->assertInstanceOf(\FooCommand::class, $application->find('foo:'));
} }
public function testSetCatchExceptions() public function testSetCatchExceptions()

View File

@ -42,7 +42,7 @@ class CommandTest extends TestCase
public function testCommandNameCannotBeEmpty() public function testCommandNameCannotBeEmpty()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('The command defined in "Symfony\Component\Console\Command\Command" cannot have an empty name.'); $this->expectExceptionMessage('The command defined in "Symfony\Component\Console\Command\Command" cannot have an empty name.');
(new Application())->add(new Command()); (new Application())->add(new Command());
} }
@ -115,7 +115,7 @@ class CommandTest extends TestCase
*/ */
public function testInvalidCommandNames($name) public function testInvalidCommandNames($name)
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name)); $this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name));
$command = new \TestCommand(); $command = new \TestCommand();
@ -207,7 +207,7 @@ class CommandTest extends TestCase
public function testGetHelperWithoutHelperSet() public function testGetHelperWithoutHelperSet()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('Cannot retrieve helper "formatter" because there is no HelperSet defined.'); $this->expectExceptionMessage('Cannot retrieve helper "formatter" because there is no HelperSet defined.');
$command = new \TestCommand(); $command = new \TestCommand();
$command->getHelper('formatter'); $command->getHelper('formatter');
@ -278,7 +278,7 @@ class CommandTest extends TestCase
public function testExecuteMethodNeedsToBeOverridden() public function testExecuteMethodNeedsToBeOverridden()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('You must override the execute() method in the concrete command class.'); $this->expectExceptionMessage('You must override the execute() method in the concrete command class.');
$command = new Command('foo'); $command = new Command('foo');
$command->run(new StringInput(''), new NullOutput()); $command->run(new StringInput(''), new NullOutput());
@ -286,7 +286,7 @@ class CommandTest extends TestCase
public function testRunWithInvalidOption() public function testRunWithInvalidOption()
{ {
$this->expectException('Symfony\Component\Console\Exception\InvalidOptionException'); $this->expectException(\Symfony\Component\Console\Exception\InvalidOptionException::class);
$this->expectExceptionMessage('The "--bar" option does not exist.'); $this->expectExceptionMessage('The "--bar" option does not exist.');
$command = new \TestCommand(); $command = new \TestCommand();
$tester = new CommandTester($command); $tester = new CommandTester($command);

View File

@ -91,7 +91,7 @@ class ChildDefinitionTest extends TestCase
public function testReplaceArgumentShouldRequireIntegerIndex() public function testReplaceArgumentShouldRequireIntegerIndex()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$def = new ChildDefinition('foo'); $def = new ChildDefinition('foo');
$def->replaceArgument('0', 'foo'); $def->replaceArgument('0', 'foo');
@ -118,7 +118,7 @@ class ChildDefinitionTest extends TestCase
public function testGetArgumentShouldCheckBounds() public function testGetArgumentShouldCheckBounds()
{ {
$this->expectException('OutOfBoundsException'); $this->expectException(\OutOfBoundsException::class);
$def = new ChildDefinition('foo'); $def = new ChildDefinition('foo');
$def->setArguments([0 => 'foo']); $def->setArguments([0 => 'foo']);

View File

@ -57,7 +57,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
public function testDefaultEnvWithoutPrefixIsValidatedInConfig() public function testDefaultEnvWithoutPrefixIsValidatedInConfig()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
$this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "float" given to "env(FLOATISH)".'); $this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "float" given to "env(FLOATISH)".');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
@ -217,7 +217,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
public function testEmptyEnvWhichCannotBeEmptyForScalarNodeWithValidation() public function testEmptyEnvWhichCannotBeEmptyForScalarNodeWithValidation()
{ {
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException'); $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
$this->expectExceptionMessage('The path "env_extension.scalar_node_not_empty_validated" cannot contain an environment variable when empty values are not allowed by definition and are validated.'); $this->expectExceptionMessage('The path "env_extension.scalar_node_not_empty_validated" cannot contain an environment variable when empty values are not allowed by definition and are validated.');
$container = new ContainerBuilder(); $container = new ContainerBuilder();

View File

@ -70,7 +70,7 @@ class ExtensionTest extends TestCase
public function testInvalidConfiguration() public function testInvalidConfiguration()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class);
$this->expectExceptionMessage('The extension configuration class "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\Extension\\InvalidConfig\\Configuration" must implement "Symfony\\Component\\Config\\Definition\\ConfigurationInterface".'); $this->expectExceptionMessage('The extension configuration class "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\Extension\\InvalidConfig\\Configuration" must implement "Symfony\\Component\\Config\\Definition\\ConfigurationInterface".');
$extension = new InvalidConfigExtension(); $extension = new InvalidConfigExtension();

View File

@ -95,7 +95,7 @@ class PhpFileLoaderTest extends TestCase
public function testFactoryShortNotationNotAllowed() public function testFactoryShortNotationNotAllowed()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid factory "factory:method": the "service:method" notation is not available when using PHP-based DI configuration. Use "[service(\'factory\'), \'method\']" instead.'); $this->expectExceptionMessage('Invalid factory "factory:method": the "service:method" notation is not available when using PHP-based DI configuration. Use "[service(\'factory\'), \'method\']" instead.');
$fixtures = realpath(__DIR__.'/../Fixtures'); $fixtures = realpath(__DIR__.'/../Fixtures');
$container = new ContainerBuilder(); $container = new ContainerBuilder();

View File

@ -60,7 +60,7 @@ class XmlFileLoaderTest extends TestCase
$loader->load('foo.xml'); $loader->load('foo.xml');
$this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist'); $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not exist'); $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the loaded file does not exist');
$this->assertStringStartsWith('The file "foo.xml" does not exist (in:', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not exist'); $this->assertStringStartsWith('The file "foo.xml" does not exist (in:', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not exist');
} }
} }
@ -76,11 +76,11 @@ class XmlFileLoaderTest extends TestCase
$m->invoke($loader, self::$fixturesPath.'/ini/parameters.ini'); $m->invoke($loader, self::$fixturesPath.'/ini/parameters.ini');
$this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
$this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'parameters.ini'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'parameters.ini'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
$this->assertStringStartsWith('[ERROR 4] Start tag expected, \'<\' not found (in', $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $this->assertStringStartsWith('[ERROR 4] Start tag expected, \'<\' not found (in', $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
} }
@ -90,16 +90,16 @@ class XmlFileLoaderTest extends TestCase
$m->invoke($loader, self::$fixturesPath.'/xml/nonvalid.xml'); $m->invoke($loader, self::$fixturesPath.'/xml/nonvalid.xml');
$this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); $this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD');
$this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid.xml'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid.xml'), $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('InvalidArgumentException', $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD');
$this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD'); $this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD');
} }
$xml = $m->invoke($loader, self::$fixturesPath.'/xml/services1.xml'); $xml = $m->invoke($loader, self::$fixturesPath.'/xml/services1.xml');
$this->assertInstanceOf('DOMDocument', $xml, '->parseFileToDOM() returns an SimpleXMLElement object'); $this->assertInstanceOf(\DOMDocument::class, $xml, '->parseFileToDOM() returns an SimpleXMLElement object');
} }
public function testLoadWithExternalEntitiesDisabled() public function testLoadWithExternalEntitiesDisabled()
@ -200,11 +200,11 @@ class XmlFileLoaderTest extends TestCase
$loader->load('services4_bad_import_with_errors.xml'); $loader->load('services4_bad_import_with_errors.xml');
$this->fail('->load() throws a LoaderLoadException if the imported xml file configuration does not exist'); $this->fail('->load() throws a LoaderLoadException if the imported xml file configuration does not exist');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the imported xml file configuration does not exist'); $this->assertInstanceOf(\Symfony\Component\Config\Exception\LoaderLoadException::class, $e, '->load() throws a LoaderLoadException if the imported xml file configuration does not exist');
$this->assertMatchesRegularExpression(sprintf('#^The file "%1$s" does not exist \(in: .+\) in %1$s \(which is being imported from ".+%2$s"\)\.$#', 'foo_fake\.xml', 'services4_bad_import_with_errors\.xml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported xml file configuration does not exist'); $this->assertMatchesRegularExpression(sprintf('#^The file "%1$s" does not exist \(in: .+\) in %1$s \(which is being imported from ".+%2$s"\)\.$#', 'foo_fake\.xml', 'services4_bad_import_with_errors\.xml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported xml file configuration does not exist');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\FileLocatorFileNotFoundException', $e, '->load() throws a FileLocatorFileNotFoundException if the imported xml file configuration does not exist'); $this->assertInstanceOf(\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException::class, $e, '->load() throws a FileLocatorFileNotFoundException if the imported xml file configuration does not exist');
$this->assertMatchesRegularExpression(sprintf('#^The file "%s" does not exist \(in: .+\)\.$#', 'foo_fake\.xml'), $e->getMessage(), '->load() throws a FileLocatorFileNotFoundException if the imported xml file configuration does not exist'); $this->assertMatchesRegularExpression(sprintf('#^The file "%s" does not exist \(in: .+\)\.$#', 'foo_fake\.xml'), $e->getMessage(), '->load() throws a FileLocatorFileNotFoundException if the imported xml file configuration does not exist');
} }
@ -212,15 +212,15 @@ class XmlFileLoaderTest extends TestCase
$loader->load('services4_bad_import_nonvalid.xml'); $loader->load('services4_bad_import_nonvalid.xml');
$this->fail('->load() throws an LoaderLoadException if the imported configuration does not validate the XSD'); $this->fail('->load() throws an LoaderLoadException if the imported configuration does not validate the XSD');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the imported configuration does not validate the XSD'); $this->assertInstanceOf(\Symfony\Component\Config\Exception\LoaderLoadException::class, $e, '->load() throws a LoaderLoadException if the imported configuration does not validate the XSD');
$this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid\.xml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported configuration does not validate the XSD'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid\.xml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported configuration does not validate the XSD');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid\.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'nonvalid\.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('Symfony\\Component\\Config\\Util\\Exception\\XmlParsingException', $e, '->load() throws a XmlParsingException if the configuration does not validate the XSD'); $this->assertInstanceOf(\Symfony\Component\Config\Util\Exception\XmlParsingException::class, $e, '->load() throws a XmlParsingException if the configuration does not validate the XSD');
$this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->load() throws a XmlParsingException if the loaded file does not validate the XSD'); $this->assertStringStartsWith('[ERROR 1845] Element \'nonvalid\': No matching global declaration available for the validation root. (in', $e->getMessage(), '->load() throws a XmlParsingException if the loaded file does not validate the XSD');
} }
} }
@ -236,7 +236,7 @@ class XmlFileLoaderTest extends TestCase
// anonymous service as an argument // anonymous service as an argument
$args = $services['foo']->getArguments(); $args = $services['foo']->getArguments();
$this->assertCount(1, $args, '->load() references anonymous services as "normal" ones'); $this->assertCount(1, $args, '->load() references anonymous services as "normal" ones');
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services'); $this->assertInstanceOf(Reference::class, $args[0], '->load() converts anonymous services to references to "normal" services');
$this->assertArrayHasKey((string) $args[0], $services, '->load() makes a reference to the created ones'); $this->assertArrayHasKey((string) $args[0], $services, '->load() makes a reference to the created ones');
$inner = $services[(string) $args[0]]; $inner = $services[(string) $args[0]];
$this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); $this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
@ -245,7 +245,7 @@ class XmlFileLoaderTest extends TestCase
// inner anonymous services // inner anonymous services
$args = $inner->getArguments(); $args = $inner->getArguments();
$this->assertCount(1, $args, '->load() references anonymous services as "normal" ones'); $this->assertCount(1, $args, '->load() references anonymous services as "normal" ones');
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $args[0], '->load() converts anonymous services to references to "normal" services'); $this->assertInstanceOf(Reference::class, $args[0], '->load() converts anonymous services to references to "normal" services');
$this->assertArrayHasKey((string) $args[0], $services, '->load() makes a reference to the created ones'); $this->assertArrayHasKey((string) $args[0], $services, '->load() makes a reference to the created ones');
$inner = $services[(string) $args[0]]; $inner = $services[(string) $args[0]];
$this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); $this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
@ -254,7 +254,7 @@ class XmlFileLoaderTest extends TestCase
// anonymous service as a property // anonymous service as a property
$properties = $services['foo']->getProperties(); $properties = $services['foo']->getProperties();
$property = $properties['p']; $property = $properties['p'];
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $property, '->load() converts anonymous services to references to "normal" services'); $this->assertInstanceOf(Reference::class, $property, '->load() converts anonymous services to references to "normal" services');
$this->assertArrayHasKey((string) $property, $services, '->load() makes a reference to the created ones'); $this->assertArrayHasKey((string) $property, $services, '->load() makes a reference to the created ones');
$inner = $services[(string) $property]; $inner = $services[(string) $property];
$this->assertEquals('BuzClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); $this->assertEquals('BuzClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
@ -270,7 +270,7 @@ class XmlFileLoaderTest extends TestCase
public function testLoadAnonymousServicesWithoutId() public function testLoadAnonymousServicesWithoutId()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Top-level services must have "id" attribute, none found in'); $this->expectExceptionMessage('Top-level services must have "id" attribute, none found in');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
@ -296,7 +296,7 @@ class XmlFileLoaderTest extends TestCase
$services = $container->getDefinitions(); $services = $container->getDefinitions();
$this->assertArrayHasKey('foo', $services, '->load() parses <service> elements'); $this->assertArrayHasKey('foo', $services, '->load() parses <service> elements');
$this->assertFalse($services['not_shared']->isShared(), '->load() parses shared flag'); $this->assertFalse($services['not_shared']->isShared(), '->load() parses shared flag');
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts <service> element to Definition instances'); $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Definition::class, $services['foo'], '->load() converts <service> element to Definition instances');
$this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute');
$this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag'); $this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag');
$this->assertEquals(['foo', new Reference('foo'), [true, false]], $services['arguments']->getArguments(), '->load() parses the argument tags'); $this->assertEquals(['foo', new Reference('foo'), [true, false]], $services['arguments']->getArguments(), '->load() parses the argument tags');
@ -378,7 +378,7 @@ class XmlFileLoaderTest extends TestCase
public function testParseTagsWithoutNameThrowsException() public function testParseTagsWithoutNameThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
$loader->load('tag_without_name.xml'); $loader->load('tag_without_name.xml');
@ -386,7 +386,7 @@ class XmlFileLoaderTest extends TestCase
public function testParseTagWithEmptyNameThrowsException() public function testParseTagWithEmptyNameThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .* must be a non-empty string/'); $this->expectExceptionMessageMatches('/The tag name for service ".+" in .* must be a non-empty string/');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
@ -535,11 +535,11 @@ class XmlFileLoaderTest extends TestCase
$loader->load('extensions/services3.xml'); $loader->load('extensions/services3.xml');
$this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'services3.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'services3.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$this->assertStringContainsString('The attribute \'bar\' is not allowed', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertStringContainsString('The attribute \'bar\' is not allowed', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
} }
@ -572,11 +572,11 @@ class XmlFileLoaderTest extends TestCase
$loader->load('extensions/services7.xml'); $loader->load('extensions/services7.xml');
$this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'services7.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'services7.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
$this->assertStringContainsString('The attribute \'bar\' is not allowed', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD'); $this->assertStringContainsString('The attribute \'bar\' is not allowed', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
} }
} }
@ -623,11 +623,11 @@ class XmlFileLoaderTest extends TestCase
$loader->load('withdoctype.xml'); $loader->load('withdoctype.xml');
$this->fail('->load() throws an InvalidArgumentException if the configuration contains a document type'); $this->fail('->load() throws an InvalidArgumentException if the configuration contains a document type');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type'); $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration contains a document type');
$this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'withdoctype.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type'); $this->assertMatchesRegularExpression(sprintf('#^Unable to parse file ".+%s": .+.$#', 'withdoctype.xml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the configuration contains a document type'); $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the configuration contains a document type');
$this->assertSame('Document types are not allowed.', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type'); $this->assertSame('Document types are not allowed.', $e->getMessage(), '->load() throws an InvalidArgumentException if the configuration contains a document type');
} }
} }
@ -772,7 +772,7 @@ class XmlFileLoaderTest extends TestCase
public function testAliasDefinitionContainsUnsupportedElements() public function testAliasDefinitionContainsUnsupportedElements()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid attribute "class" defined for alias "bar" in'); $this->expectExceptionMessage('Invalid attribute "class" defined for alias "bar" in');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));

View File

@ -52,7 +52,7 @@ class YamlFileLoaderTest extends TestCase
public function testLoadUnExistFile() public function testLoadUnExistFile()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/The file ".+" does not exist./'); $this->expectExceptionMessageMatches('/The file ".+" does not exist./');
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini')); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini'));
$r = new \ReflectionObject($loader); $r = new \ReflectionObject($loader);
@ -64,7 +64,7 @@ class YamlFileLoaderTest extends TestCase
public function testLoadInvalidYamlFile() public function testLoadInvalidYamlFile()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/The file ".+" does not contain valid YAML./'); $this->expectExceptionMessageMatches('/The file ".+" does not contain valid YAML./');
$path = self::$fixturesPath.'/ini'; $path = self::$fixturesPath.'/ini';
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator($path)); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator($path));
@ -80,7 +80,7 @@ class YamlFileLoaderTest extends TestCase
*/ */
public function testLoadInvalidFile($file) public function testLoadInvalidFile($file)
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load($file.'.yml'); $loader->load($file.'.yml');
@ -146,11 +146,11 @@ class YamlFileLoaderTest extends TestCase
$loader->load('services4_bad_import_with_errors.yml'); $loader->load('services4_bad_import_with_errors.yml');
$this->fail('->load() throws a LoaderLoadException if the imported yaml file does not exist'); $this->fail('->load() throws a LoaderLoadException if the imported yaml file does not exist');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the imported yaml file does not exist'); $this->assertInstanceOf(\Symfony\Component\Config\Exception\LoaderLoadException::class, $e, '->load() throws a LoaderLoadException if the imported yaml file does not exist');
$this->assertMatchesRegularExpression(sprintf('#^The file "%1$s" does not exist \(in: .+\) in %1$s \(which is being imported from ".+%2$s"\)\.$#', 'foo_fake\.yml', 'services4_bad_import_with_errors\.yml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported yaml file does not exist'); $this->assertMatchesRegularExpression(sprintf('#^The file "%1$s" does not exist \(in: .+\) in %1$s \(which is being imported from ".+%2$s"\)\.$#', 'foo_fake\.yml', 'services4_bad_import_with_errors\.yml'), $e->getMessage(), '->load() throws a LoaderLoadException if the imported yaml file does not exist');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\FileLocatorFileNotFoundException', $e, '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist'); $this->assertInstanceOf(\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException::class, $e, '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist');
$this->assertMatchesRegularExpression(sprintf('#^The file "%s" does not exist \(in: .+\)\.$#', 'foo_fake\.yml'), $e->getMessage(), '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist'); $this->assertMatchesRegularExpression(sprintf('#^The file "%s" does not exist \(in: .+\)\.$#', 'foo_fake\.yml'), $e->getMessage(), '->load() throws a FileLocatorFileNotFoundException if the imported yaml file does not exist');
} }
@ -158,11 +158,11 @@ class YamlFileLoaderTest extends TestCase
$loader->load('services4_bad_import_nonvalid.yml'); $loader->load('services4_bad_import_nonvalid.yml');
$this->fail('->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid'); $this->fail('->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\\Component\\Config\\Exception\\LoaderLoadException', $e, '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid'); $this->assertInstanceOf(\Symfony\Component\Config\Exception\LoaderLoadException::class, $e, '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid');
$this->assertMatchesRegularExpression(sprintf('#^The service file ".+%1$s" is not valid\. It should contain an array\. Check your YAML syntax in .+%1$s \(which is being imported from ".+%2$s"\)\.$#', 'nonvalid2\.yml', 'services4_bad_import_nonvalid.yml'), $e->getMessage(), '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid'); $this->assertMatchesRegularExpression(sprintf('#^The service file ".+%1$s" is not valid\. It should contain an array\. Check your YAML syntax in .+%1$s \(which is being imported from ".+%2$s"\)\.$#', 'nonvalid2\.yml', 'services4_bad_import_nonvalid.yml'), $e->getMessage(), '->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid');
$e = $e->getPrevious(); $e = $e->getPrevious();
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Exception\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag in the imported yaml file is not valid'); $this->assertInstanceOf(InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tag in the imported yaml file is not valid');
$this->assertMatchesRegularExpression(sprintf('#^The service file ".+%s" is not valid\. It should contain an array\. Check your YAML syntax\.$#', 'nonvalid2\.yml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the tag in the imported yaml file is not valid'); $this->assertMatchesRegularExpression(sprintf('#^The service file ".+%s" is not valid\. It should contain an array\. Check your YAML syntax\.$#', 'nonvalid2\.yml'), $e->getMessage(), '->load() throws an InvalidArgumentException if the tag in the imported yaml file is not valid');
} }
} }
@ -175,7 +175,7 @@ class YamlFileLoaderTest extends TestCase
$services = $container->getDefinitions(); $services = $container->getDefinitions();
$this->assertArrayHasKey('foo', $services, '->load() parses service elements'); $this->assertArrayHasKey('foo', $services, '->load() parses service elements');
$this->assertFalse($services['not_shared']->isShared(), '->load() parses the shared flag'); $this->assertFalse($services['not_shared']->isShared(), '->load() parses the shared flag');
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts service element to Definition instances'); $this->assertInstanceOf(\Symfony\Component\DependencyInjection\Definition::class, $services['foo'], '->load() converts service element to Definition instances');
$this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute'); $this->assertEquals('FooClass', $services['foo']->getClass(), '->load() parses the class attribute');
$this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag'); $this->assertEquals('%path%/foo.php', $services['file']->getFile(), '->load() parses the file tag');
$this->assertEquals(['foo', new Reference('foo'), [true, false]], $services['arguments']->getArguments(), '->load() parses the argument tags'); $this->assertEquals(['foo', new Reference('foo'), [true, false]], $services['arguments']->getArguments(), '->load() parses the argument tags');
@ -316,7 +316,7 @@ class YamlFileLoaderTest extends TestCase
$loader->load('badtag1.yml'); $loader->load('badtag1.yml');
$this->fail('->load() should throw an exception when the tags key of a service is not an array'); $this->fail('->load() should throw an exception when the tags key of a service is not an array');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tags key is not an array'); $this->assertInstanceOf(InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tags key is not an array');
$this->assertStringStartsWith('Parameter "tags" must be an array for service', $e->getMessage(), '->load() throws an InvalidArgumentException if the tags key is not an array'); $this->assertStringStartsWith('Parameter "tags" must be an array for service', $e->getMessage(), '->load() throws an InvalidArgumentException if the tags key is not an array');
} }
} }
@ -328,7 +328,7 @@ class YamlFileLoaderTest extends TestCase
$loader->load('badtag2.yml'); $loader->load('badtag2.yml');
$this->fail('->load() should throw an exception when a tag is missing the name key'); $this->fail('->load() should throw an exception when a tag is missing the name key');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if a tag is missing the name key'); $this->assertInstanceOf(InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if a tag is missing the name key');
$this->assertStringStartsWith('A "tags" entry is missing a "name" key for service ', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag is missing the name key'); $this->assertStringStartsWith('A "tags" entry is missing a "name" key for service ', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag is missing the name key');
} }
} }
@ -369,7 +369,7 @@ class YamlFileLoaderTest extends TestCase
$loader->load('badtag3.yml'); $loader->load('badtag3.yml');
$this->fail('->load() should throw an exception when a tag-attribute is not a scalar'); $this->fail('->load() should throw an exception when a tag-attribute is not a scalar');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar'); $this->assertInstanceOf(InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar');
$this->assertStringStartsWith('A "tags" attribute must be of a scalar-type for service "foo_service", tag "foo", attribute "bar"', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar'); $this->assertStringStartsWith('A "tags" attribute must be of a scalar-type for service "foo_service", tag "foo", attribute "bar"', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar');
} }
} }
@ -388,7 +388,7 @@ class YamlFileLoaderTest extends TestCase
public function testTagWithEmptyNameThrowsException() public function testTagWithEmptyNameThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/'); $this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/');
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('tag_name_empty_string.yml'); $loader->load('tag_name_empty_string.yml');
@ -396,7 +396,7 @@ class YamlFileLoaderTest extends TestCase
public function testTagWithNonStringNameThrowsException() public function testTagWithNonStringNameThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/'); $this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/');
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('tag_name_no_string.yml'); $loader->load('tag_name_no_string.yml');
@ -496,7 +496,7 @@ class YamlFileLoaderTest extends TestCase
public function testPrototypeWithNamespaceAndNoResource() public function testPrototypeWithNamespaceAndNoResource()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/A "resource" attribute must be set when the "namespace" attribute is set for service ".+" in .+/'); $this->expectExceptionMessageMatches('/A "resource" attribute must be set when the "namespace" attribute is set for service ".+" in .+/');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
@ -600,7 +600,7 @@ class YamlFileLoaderTest extends TestCase
public function testChildDefinitionWithWrongSyntaxThrowsException() public function testChildDefinitionWithWrongSyntaxThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The value of the "parent" option for the "bar" service must be the id of the service without the "@" prefix (replace "@foo" with "foo").'); $this->expectExceptionMessage('The value of the "parent" option for the "bar" service must be the id of the service without the "@" prefix (replace "@foo" with "foo").');
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('bad_parent.yml'); $loader->load('bad_parent.yml');
@ -608,7 +608,7 @@ class YamlFileLoaderTest extends TestCase
public function testDecoratedServicesWithWrongSyntaxThrowsException() public function testDecoratedServicesWithWrongSyntaxThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The value of the "decorates" option for the "bar" service must be the id of the service without the "@" prefix (replace "@foo" with "foo").'); $this->expectExceptionMessage('The value of the "decorates" option for the "bar" service must be the id of the service without the "@" prefix (replace "@foo" with "foo").');
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('bad_decorates.yml'); $loader->load('bad_decorates.yml');
@ -616,7 +616,7 @@ class YamlFileLoaderTest extends TestCase
public function testDecoratedServicesWithWrongOnInvalidSyntaxThrowsException() public function testDecoratedServicesWithWrongOnInvalidSyntaxThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Did you mean null (without quotes)'); $this->expectExceptionMessage('Did you mean null (without quotes)');
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('bad_decoration_on_invalid_null.yml'); $loader->load('bad_decoration_on_invalid_null.yml');
@ -624,7 +624,7 @@ class YamlFileLoaderTest extends TestCase
public function testInvalidTagsWithDefaults() public function testInvalidTagsWithDefaults()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./'); $this->expectExceptionMessageMatches('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./');
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('services31_invalid_tags.yml'); $loader->load('services31_invalid_tags.yml');
@ -632,7 +632,7 @@ class YamlFileLoaderTest extends TestCase
public function testUnderscoreServiceId() public function testUnderscoreServiceId()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Service names that start with an underscore are reserved. Rename the "_foo" service or define it in XML instead.'); $this->expectExceptionMessage('Service names that start with an underscore are reserved. Rename the "_foo" service or define it in XML instead.');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
@ -714,7 +714,7 @@ class YamlFileLoaderTest extends TestCase
public function testAnonymousServicesWithAliases() public function testAnonymousServicesWithAliases()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./'); $this->expectExceptionMessageMatches('/Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
@ -723,7 +723,7 @@ class YamlFileLoaderTest extends TestCase
public function testAnonymousServicesInParameters() public function testAnonymousServicesInParameters()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./'); $this->expectExceptionMessageMatches('/Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
@ -742,7 +742,7 @@ class YamlFileLoaderTest extends TestCase
public function testEmptyDefaultsThrowsClearException() public function testEmptyDefaultsThrowsClearException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/Service "_defaults" key must be an array, "null" given in ".+bad_empty_defaults\.yml"\./'); $this->expectExceptionMessageMatches('/Service "_defaults" key must be an array, "null" given in ".+bad_empty_defaults\.yml"\./');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
@ -751,7 +751,7 @@ class YamlFileLoaderTest extends TestCase
public function testEmptyInstanceofThrowsClearException() public function testEmptyInstanceofThrowsClearException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/Service "_instanceof" key must be an array, "null" given in ".+bad_empty_instanceof\.yml"\./'); $this->expectExceptionMessageMatches('/Service "_instanceof" key must be an array, "null" given in ".+bad_empty_instanceof\.yml"\./');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
@ -760,7 +760,7 @@ class YamlFileLoaderTest extends TestCase
public function testUnsupportedKeywordThrowsException() public function testUnsupportedKeywordThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/^The configuration key "private" is unsupported for definition "bar"/'); $this->expectExceptionMessageMatches('/^The configuration key "private" is unsupported for definition "bar"/');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
@ -769,7 +769,7 @@ class YamlFileLoaderTest extends TestCase
public function testUnsupportedKeywordInServiceAliasThrowsException() public function testUnsupportedKeywordInServiceAliasThrowsException()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/^The configuration key "calls" is unsupported for the service "bar" which is defined as an alias/'); $this->expectExceptionMessageMatches('/^The configuration key "calls" is unsupported for the service "bar" which is defined as an alias/');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
@ -829,7 +829,7 @@ class YamlFileLoaderTest extends TestCase
public function testProcessNotExistingActionParam() public function testProcessNotExistingActionParam()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
$this->expectExceptionMessage('Cannot autowire service "Symfony\Component\DependencyInjection\Tests\Fixtures\ConstructNotExists": argument "$notExist" of method "__construct()" has type "Symfony\Component\DependencyInjection\Tests\Fixtures\NotExist" but this class was not found.'); $this->expectExceptionMessage('Cannot autowire service "Symfony\Component\DependencyInjection\Tests\Fixtures\ConstructNotExists": argument "$notExist" of method "__construct()" has type "Symfony\Component\DependencyInjection\Tests\Fixtures\NotExist" but this class was not found.');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));

View File

@ -18,7 +18,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
{ {
public function testGetThrowsInvalidArgumentExceptionIfEnvNameContainsNonWordCharacters() public function testGetThrowsInvalidArgumentExceptionIfEnvNameContainsNonWordCharacters()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$bag = new EnvPlaceholderParameterBag(); $bag = new EnvPlaceholderParameterBag();
$bag->get('env(%foo%)'); $bag->get('env(%foo%)');
} }
@ -111,7 +111,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
public function testResolveEnvRequiresStrings() public function testResolveEnvRequiresStrings()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
$this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, "int" given.'); $this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, "int" given.');
$bag = new EnvPlaceholderParameterBag(); $bag = new EnvPlaceholderParameterBag();
@ -122,7 +122,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
public function testGetDefaultScalarEnv() public function testGetDefaultScalarEnv()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
$this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "int" given to "env(INT_VAR)".'); $this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "int" given to "env(INT_VAR)".');
$bag = new EnvPlaceholderParameterBag(); $bag = new EnvPlaceholderParameterBag();
@ -153,7 +153,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
public function testResolveThrowsOnBadDefaultValue() public function testResolveThrowsOnBadDefaultValue()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
$this->expectExceptionMessage('The default value of env parameter "ARRAY_VAR" must be a string or null, "array" given.'); $this->expectExceptionMessage('The default value of env parameter "ARRAY_VAR" must be a string or null, "array" given.');
$bag = new EnvPlaceholderParameterBag(); $bag = new EnvPlaceholderParameterBag();
$bag->get('env(ARRAY_VAR)'); $bag->get('env(ARRAY_VAR)');
@ -173,7 +173,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
public function testGetThrowsOnBadDefaultValue() public function testGetThrowsOnBadDefaultValue()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
$this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "array" given to "env(ARRAY_VAR)".'); $this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "array" given to "env(ARRAY_VAR)".');
$bag = new EnvPlaceholderParameterBag(); $bag = new EnvPlaceholderParameterBag();
$bag->set('env(ARRAY_VAR)', []); $bag->set('env(ARRAY_VAR)', []);

View File

@ -322,7 +322,7 @@ class DotenvTest extends TestCase
public function testLoadDirectory() public function testLoadDirectory()
{ {
$this->expectException('Symfony\Component\Dotenv\Exception\PathException'); $this->expectException(\Symfony\Component\Dotenv\Exception\PathException::class);
$dotenv = new Dotenv(); $dotenv = new Dotenv();
$dotenv->load(__DIR__); $dotenv->load(__DIR__);
} }

View File

@ -187,7 +187,7 @@ class ErrorHandler
$this->bootstrappingLogger = $bootstrappingLogger; $this->bootstrappingLogger = $bootstrappingLogger;
$this->setDefaultLogger($bootstrappingLogger); $this->setDefaultLogger($bootstrappingLogger);
} }
$traceReflector = new \ReflectionProperty('Exception', 'trace'); $traceReflector = new \ReflectionProperty(\Exception::class, 'trace');
$traceReflector->setAccessible(true); $traceReflector->setAccessible(true);
$this->configureException = \Closure::bind(static function ($e, $trace, $file = null, $line = null) use ($traceReflector) { $this->configureException = \Closure::bind(static function ($e, $trace, $file = null, $line = null) use ($traceReflector) {
$traceReflector->setValue($e, $trace); $traceReflector->setValue($e, $trace);

View File

@ -17,7 +17,7 @@
); );
</script> </script>
<?php if (class_exists('Symfony\Component\HttpKernel\Kernel')) { ?> <?php if (class_exists(\Symfony\Component\HttpKernel\Kernel::class)) { ?>
<header> <header>
<div class="container"> <div class="container">
<h1 class="logo"><?= $this->include('assets/images/symfony-logo.svg'); ?> Symfony Exception</h1> <h1 class="logo"><?= $this->include('assets/images/symfony-logo.svg'); ?> Symfony Exception</h1>

View File

@ -133,8 +133,8 @@ class EventDispatcherTest extends TestCase
$this->dispatcher->dispatch(new Event(), self::preFoo); $this->dispatcher->dispatch(new Event(), self::preFoo);
$this->assertTrue($this->listener->preFooInvoked); $this->assertTrue($this->listener->preFooInvoked);
$this->assertFalse($this->listener->postFooInvoked); $this->assertFalse($this->listener->postFooInvoked);
$this->assertInstanceOf('Symfony\Contracts\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), 'noevent')); $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), 'noevent'));
$this->assertInstanceOf('Symfony\Contracts\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), self::preFoo)); $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), self::preFoo));
$event = new Event(); $event = new Event();
$return = $this->dispatcher->dispatch($event, self::preFoo); $return = $this->dispatcher->dispatch($event, self::preFoo);
$this->assertSame($event, $return); $this->assertSame($event, $return);
@ -213,7 +213,7 @@ class EventDispatcherTest extends TestCase
$listeners = $this->dispatcher->getListeners('pre.foo'); $listeners = $this->dispatcher->getListeners('pre.foo');
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
$this->assertCount(2, $listeners); $this->assertCount(2, $listeners);
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]); $this->assertInstanceOf(\Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities::class, $listeners[0][0]);
} }
public function testAddSubscriberWithMultipleListeners() public function testAddSubscriberWithMultipleListeners()

View File

@ -38,7 +38,7 @@ class CachingFactoryDecoratorTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock(); $this->decoratedFactory = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface::class)->getMock();
$this->factory = new CachingFactoryDecorator($this->decoratedFactory); $this->factory = new CachingFactoryDecorator($this->decoratedFactory);
} }
@ -238,7 +238,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateFromLoaderSameLoader() public function testCreateFromLoaderSameLoader()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
$list = new ArrayChoiceList([]); $list = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]); $list2 = new ArrayChoiceList([]);
@ -269,8 +269,8 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateFromLoaderDifferentLoader() public function testCreateFromLoaderDifferentLoader()
{ {
$loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader1 = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
$loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader2 = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
$list1 = new ArrayChoiceList([]); $list1 = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]); $list2 = new ArrayChoiceList([]);
@ -288,7 +288,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateFromLoaderSameValueClosure() public function testCreateFromLoaderSameValueClosure()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
$type = $this->createMock(FormTypeInterface::class); $type = $this->createMock(FormTypeInterface::class);
$list = new ArrayChoiceList([]); $list = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]); $list2 = new ArrayChoiceList([]);
@ -328,7 +328,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateFromLoaderDifferentValueClosure() public function testCreateFromLoaderDifferentValueClosure()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
$type = $this->createMock(FormTypeInterface::class); $type = $this->createMock(FormTypeInterface::class);
$list1 = new ArrayChoiceList([]); $list1 = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]); $list2 = new ArrayChoiceList([]);
@ -349,7 +349,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateFromLoaderSameFilterClosure() public function testCreateFromLoaderSameFilterClosure()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
$type = $this->createMock(FormTypeInterface::class); $type = $this->createMock(FormTypeInterface::class);
$list = new ArrayChoiceList([]); $list = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]); $list2 = new ArrayChoiceList([]);
@ -391,7 +391,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateFromLoaderDifferentFilterClosure() public function testCreateFromLoaderDifferentFilterClosure()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
$type = $this->createMock(FormTypeInterface::class); $type = $this->createMock(FormTypeInterface::class);
$list1 = new ArrayChoiceList([]); $list1 = new ArrayChoiceList([]);
$list2 = new ArrayChoiceList([]); $list2 = new ArrayChoiceList([]);
@ -413,7 +413,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateViewSamePreferredChoices() public function testCreateViewSamePreferredChoices()
{ {
$preferred = ['a']; $preferred = ['a'];
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view = new ChoiceListView(); $view = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -447,7 +447,7 @@ class CachingFactoryDecoratorTest extends TestCase
{ {
$preferred1 = ['a']; $preferred1 = ['a'];
$preferred2 = ['b']; $preferred2 = ['b'];
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view1 = new ChoiceListView(); $view1 = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -466,7 +466,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateViewSamePreferredChoicesClosure() public function testCreateViewSamePreferredChoicesClosure()
{ {
$preferred = function () {}; $preferred = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view = new ChoiceListView(); $view = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -500,7 +500,7 @@ class CachingFactoryDecoratorTest extends TestCase
{ {
$preferred1 = function () {}; $preferred1 = function () {};
$preferred2 = function () {}; $preferred2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view1 = new ChoiceListView(); $view1 = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -519,7 +519,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateViewSameLabelClosure() public function testCreateViewSameLabelClosure()
{ {
$labels = function () {}; $labels = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view = new ChoiceListView(); $view = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -553,7 +553,7 @@ class CachingFactoryDecoratorTest extends TestCase
{ {
$labels1 = function () {}; $labels1 = function () {};
$labels2 = function () {}; $labels2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view1 = new ChoiceListView(); $view1 = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -572,7 +572,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateViewSameIndexClosure() public function testCreateViewSameIndexClosure()
{ {
$index = function () {}; $index = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view = new ChoiceListView(); $view = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -606,7 +606,7 @@ class CachingFactoryDecoratorTest extends TestCase
{ {
$index1 = function () {}; $index1 = function () {};
$index2 = function () {}; $index2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view1 = new ChoiceListView(); $view1 = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -625,7 +625,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateViewSameGroupByClosure() public function testCreateViewSameGroupByClosure()
{ {
$groupBy = function () {}; $groupBy = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view = new ChoiceListView(); $view = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -659,7 +659,7 @@ class CachingFactoryDecoratorTest extends TestCase
{ {
$groupBy1 = function () {}; $groupBy1 = function () {};
$groupBy2 = function () {}; $groupBy2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view1 = new ChoiceListView(); $view1 = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -678,7 +678,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateViewSameAttributes() public function testCreateViewSameAttributes()
{ {
$attr = ['class' => 'foobar']; $attr = ['class' => 'foobar'];
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view = new ChoiceListView(); $view = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -711,7 +711,7 @@ class CachingFactoryDecoratorTest extends TestCase
{ {
$attr1 = ['class' => 'foobar1']; $attr1 = ['class' => 'foobar1'];
$attr2 = ['class' => 'foobar2']; $attr2 = ['class' => 'foobar2'];
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view1 = new ChoiceListView(); $view1 = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -730,7 +730,7 @@ class CachingFactoryDecoratorTest extends TestCase
public function testCreateViewSameAttributesClosure() public function testCreateViewSameAttributesClosure()
{ {
$attr = function () {}; $attr = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view = new ChoiceListView(); $view = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();
@ -763,7 +763,7 @@ class CachingFactoryDecoratorTest extends TestCase
{ {
$attr1 = function () {}; $attr1 = function () {};
$attr2 = function () {}; $attr2 = function () {};
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock(); $list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
$view1 = new ChoiceListView(); $view1 = new ChoiceListView();
$view2 = new ChoiceListView(); $view2 = new ChoiceListView();

View File

@ -266,7 +266,7 @@ class DefaultChoiceListFactoryTest extends TestCase
public function testCreateFromLoaderWithFilter() public function testCreateFromLoaderWithFilter()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
$filter = function () {}; $filter = function () {};
$list = $this->factory->createListFromLoader($loader, null, $filter); $list = $this->factory->createListFromLoader($loader, null, $filter);

View File

@ -124,7 +124,7 @@ class PropertyAccessDecoratorTest extends TestCase
public function testCreateFromLoaderFilterPropertyPath() public function testCreateFromLoaderFilterPropertyPath()
{ {
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock(); $loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
$filteredChoices = [ $filteredChoices = [
'two' => (object) ['property' => 'value 2', 'filter' => true], 'two' => (object) ['property' => 'value 2', 'filter' => true],
]; ];

View File

@ -273,7 +273,7 @@ class CompoundFormTest extends AbstractFormTest
public function testAddThrowsExceptionIfAlreadySubmitted() public function testAddThrowsExceptionIfAlreadySubmitted()
{ {
$this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException'); $this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class);
$this->form->submit([]); $this->form->submit([]);
$this->form->add($this->getBuilder('foo')->getForm()); $this->form->add($this->getBuilder('foo')->getForm());
} }
@ -290,7 +290,7 @@ class CompoundFormTest extends AbstractFormTest
public function testRemoveThrowsExceptionIfAlreadySubmitted() public function testRemoveThrowsExceptionIfAlreadySubmitted()
{ {
$this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException'); $this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class);
$this->form->add($this->getBuilder('foo')->setCompound(false)->getForm()); $this->form->add($this->getBuilder('foo')->setCompound(false)->getForm());
$this->form->submit(['foo' => 'bar']); $this->form->submit(['foo' => 'bar']);
$this->form->remove('foo'); $this->form->remove('foo');
@ -351,7 +351,7 @@ class CompoundFormTest extends AbstractFormTest
->method('mapDataToForms') ->method('mapDataToForms')
->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class)) ->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) { ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator());
$this->assertSame([$child->getName() => $child], iterator_to_array($iterator)); $this->assertSame([$child->getName() => $child], iterator_to_array($iterator));
}); });
@ -441,7 +441,7 @@ class CompoundFormTest extends AbstractFormTest
->method('mapDataToForms') ->method('mapDataToForms')
->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class)) ->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) { ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator());
$this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
}); });
@ -888,7 +888,7 @@ class CompoundFormTest extends AbstractFormTest
$this->assertSame($error1, $errorsAsArray[0]); $this->assertSame($error1, $errorsAsArray[0]);
$this->assertSame($error2, $errorsAsArray[1]); $this->assertSame($error2, $errorsAsArray[1]);
$this->assertInstanceOf('Symfony\Component\Form\FormErrorIterator', $errorsAsArray[2]); $this->assertInstanceOf(\Symfony\Component\Form\FormErrorIterator::class, $errorsAsArray[2]);
$nestedErrorsAsArray = iterator_to_array($errorsAsArray[2]); $nestedErrorsAsArray = iterator_to_array($errorsAsArray[2]);
@ -941,9 +941,9 @@ class CompoundFormTest extends AbstractFormTest
// Basic cases are covered in SimpleFormTest // Basic cases are covered in SimpleFormTest
public function testCreateViewWithChildren() public function testCreateViewWithChildren()
{ {
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
$type1 = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type1 = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
$type2 = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type2 = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
$options = ['a' => 'Foo', 'b' => 'Bar']; $options = ['a' => 'Foo', 'b' => 'Bar'];
$field1 = $this->getBuilder('foo') $field1 = $this->getBuilder('foo')
->setType($type1) ->setType($type1)
@ -997,7 +997,7 @@ class CompoundFormTest extends AbstractFormTest
public function testNoClickedButton() public function testNoClickedButton()
{ {
$button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton') $button = $this->getMockBuilder(\Symfony\Component\Form\SubmitButton::class)
->setConstructorArgs([new SubmitButtonBuilder('submit')]) ->setConstructorArgs([new SubmitButtonBuilder('submit')])
->setMethods(['isClicked']) ->setMethods(['isClicked'])
->getMock(); ->getMock();
@ -1019,7 +1019,7 @@ class CompoundFormTest extends AbstractFormTest
public function testClickedButton() public function testClickedButton()
{ {
$button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton') $button = $this->getMockBuilder(\Symfony\Component\Form\SubmitButton::class)
->setConstructorArgs([new SubmitButtonBuilder('submit')]) ->setConstructorArgs([new SubmitButtonBuilder('submit')])
->setMethods(['isClicked']) ->setMethods(['isClicked'])
->getMock(); ->getMock();
@ -1038,7 +1038,7 @@ class CompoundFormTest extends AbstractFormTest
{ {
$button = $this->getBuilder('submit')->getForm(); $button = $this->getBuilder('submit')->getForm();
$nestedForm = $this->getMockBuilder('Symfony\Component\Form\Form') $nestedForm = $this->getMockBuilder(\Symfony\Component\Form\Form::class)
->setConstructorArgs([$this->getBuilder('nested')]) ->setConstructorArgs([$this->getBuilder('nested')])
->setMethods(['getClickedButton']) ->setMethods(['getClickedButton'])
->getMock(); ->getMock();
@ -1057,7 +1057,7 @@ class CompoundFormTest extends AbstractFormTest
{ {
$button = $this->getBuilder('submit')->getForm(); $button = $this->getBuilder('submit')->getForm();
$parentForm = $this->getMockBuilder('Symfony\Component\Form\Form') $parentForm = $this->getMockBuilder(\Symfony\Component\Form\Form::class)
->setConstructorArgs([$this->getBuilder('parent')]) ->setConstructorArgs([$this->getBuilder('parent')])
->setMethods(['getClickedButton']) ->setMethods(['getClickedButton'])
->getMock(); ->getMock();

View File

@ -222,7 +222,7 @@ class FormPassTest extends TestCase
public function testAddTaggedFormTypeExtensionWithoutExtendingAnyType() public function testAddTaggedFormTypeExtensionWithoutExtendingAnyType()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The getExtendedTypes() method for service "my.type_extension" does not return any extended types.'); $this->expectExceptionMessage('The getExtendedTypes() method for service "my.type_extension" does not return any extended types.');
$container = $this->createContainerBuilder(); $container = $this->createContainerBuilder();

View File

@ -230,7 +230,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
{ {
$transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP); $transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP);
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$transformer->transform('foo'); $transformer->transform('foo');
} }
@ -239,7 +239,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
{ {
$transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP); $transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP);
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$transformer->reverseTransform(1); $transformer->reverseTransform(1);
} }
@ -262,7 +262,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
// Since we test against "de_DE", we need the full implementation // Since we test against "de_DE", we need the full implementation
IntlTestHelper::requireFullIntl($this, '4.8.1.1'); IntlTestHelper::requireFullIntl($this, '4.8.1.1');
@ -275,7 +275,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
// Since we test against "de_DE", we need the full implementation // Since we test against "de_DE", we need the full implementation
IntlTestHelper::requireFullIntl($this, '4.8.1.1'); IntlTestHelper::requireFullIntl($this, '4.8.1.1');
@ -317,7 +317,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
IntlTestHelper::requireFullIntl($this, '4.8.1.1'); IntlTestHelper::requireFullIntl($this, '4.8.1.1');
$transformer = new PercentToLocalizedStringTransformer(1, 'integer', \NumberFormatter::ROUND_HALFUP); $transformer = new PercentToLocalizedStringTransformer(1, 'integer', \NumberFormatter::ROUND_HALFUP);
@ -327,7 +327,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep() public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
IntlTestHelper::requireFullIntl($this, '4.8.1.1'); IntlTestHelper::requireFullIntl($this, '4.8.1.1');
$transformer = new PercentToLocalizedStringTransformer(1, 'integer', \NumberFormatter::ROUND_HALFUP); $transformer = new PercentToLocalizedStringTransformer(1, 'integer', \NumberFormatter::ROUND_HALFUP);
@ -341,7 +341,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, 1); $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, 1);
$formatter->setAttribute(\NumberFormatter::GROUPING_USED, false); $formatter->setAttribute(\NumberFormatter::GROUPING_USED, false);
$transformer = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer') $transformer = $this->getMockBuilder(PercentToLocalizedStringTransformer::class)
->setMethods(['getNumberFormatter']) ->setMethods(['getNumberFormatter'])
->setConstructorArgs([1, 'integer', \NumberFormatter::ROUND_HALFUP]) ->setConstructorArgs([1, 'integer', \NumberFormatter::ROUND_HALFUP])
->getMock(); ->getMock();
@ -355,7 +355,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
public function testReverseTransformDisallowsLeadingExtraCharacters() public function testReverseTransformDisallowsLeadingExtraCharacters()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP); $transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP);
$transformer->reverseTransform('foo123'); $transformer->reverseTransform('foo123');
@ -363,7 +363,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
public function testReverseTransformDisallowsCenteredExtraCharacters() public function testReverseTransformDisallowsCenteredExtraCharacters()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$this->expectExceptionMessage('The number contains unrecognized characters: "foo3"'); $this->expectExceptionMessage('The number contains unrecognized characters: "foo3"');
$transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP); $transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP);
@ -375,7 +375,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
*/ */
public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$this->expectExceptionMessage('The number contains unrecognized characters: "foo8"'); $this->expectExceptionMessage('The number contains unrecognized characters: "foo8"');
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this, false); IntlTestHelper::requireFullIntl($this, false);
@ -389,7 +389,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
public function testReverseTransformDisallowsTrailingExtraCharacters() public function testReverseTransformDisallowsTrailingExtraCharacters()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$this->expectExceptionMessage('The number contains unrecognized characters: "foo"'); $this->expectExceptionMessage('The number contains unrecognized characters: "foo"');
$transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP); $transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP);
@ -401,7 +401,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
*/ */
public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$this->expectExceptionMessage('The number contains unrecognized characters: "foo"'); $this->expectExceptionMessage('The number contains unrecognized characters: "foo"');
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this, false); IntlTestHelper::requireFullIntl($this, false);

View File

@ -343,7 +343,7 @@ class FormTypeTest extends BaseTypeTest
public function testActionCannotBeNull() public function testActionCannotBeNull()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class);
$this->factory->create(static::TESTED_TYPE, null, ['action' => null]); $this->factory->create(static::TESTED_TYPE, null, ['action' => null]);
} }

View File

@ -79,7 +79,7 @@ class NumberTypeTest extends BaseTypeTest
public function testStringInputWithFloatData() public function testStringInputWithFloatData()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$this->expectExceptionMessage('Expected a numeric string.'); $this->expectExceptionMessage('Expected a numeric string.');
$this->factory->create(static::TESTED_TYPE, 12345.6789, [ $this->factory->create(static::TESTED_TYPE, 12345.6789, [
@ -90,7 +90,7 @@ class NumberTypeTest extends BaseTypeTest
public function testStringInputWithIntData() public function testStringInputWithIntData()
{ {
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
$this->expectExceptionMessage('Expected a numeric string.'); $this->expectExceptionMessage('Expected a numeric string.');
$this->factory->create(static::TESTED_TYPE, 12345, [ $this->factory->create(static::TESTED_TYPE, 12345, [

View File

@ -476,7 +476,7 @@ class TimeTypeTest extends BaseTypeTest
public function testSetDataDifferentTimezonesWithoutReferenceDate() public function testSetDataDifferentTimezonesWithoutReferenceDate()
{ {
$this->expectException('Symfony\Component\Form\Exception\LogicException'); $this->expectException(\Symfony\Component\Form\Exception\LogicException::class);
$this->expectExceptionMessage('Using different values for the "model_timezone" and "view_timezone" options without configuring a reference date is not supported.'); $this->expectExceptionMessage('Using different values for the "model_timezone" and "view_timezone" options without configuring a reference date is not supported.');
$form = $this->factory->create(static::TESTED_TYPE, null, [ $form = $this->factory->create(static::TESTED_TYPE, null, [

View File

@ -169,7 +169,7 @@ class TimezoneTypeTest extends BaseTypeTest
public function testChoiceTranslationLocaleOptionWithoutIntl() public function testChoiceTranslationLocaleOptionWithoutIntl()
{ {
$this->expectException('Symfony\Component\Form\Exception\LogicException'); $this->expectException(\Symfony\Component\Form\Exception\LogicException::class);
$this->expectExceptionMessage('The "choice_translation_locale" option can only be used if the "intl" option is set to true.'); $this->expectExceptionMessage('The "choice_translation_locale" option can only be used if the "intl" option is set to true.');
$this->factory->create(static::TESTED_TYPE, null, [ $this->factory->create(static::TESTED_TYPE, null, [
'choice_translation_locale' => 'uk', 'choice_translation_locale' => 'uk',

View File

@ -26,8 +26,8 @@ class FormBuilderTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
$this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); $this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory);
} }
@ -51,7 +51,7 @@ class FormBuilderTest extends TestCase
public function testAddNameNoStringAndNoInteger() public function testAddNameNoStringAndNoInteger()
{ {
$this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException'); $this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class);
$this->builder->add(true); $this->builder->add(true);
} }
@ -133,7 +133,7 @@ class FormBuilderTest extends TestCase
$this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $this->builder->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType');
$this->builder->remove('foo'); $this->builder->remove('foo');
$form = $this->builder->getForm(); $form = $this->builder->getForm();
$this->assertInstanceOf('Symfony\Component\Form\Form', $form); $this->assertInstanceOf(\Symfony\Component\Form\Form::class, $form);
} }
public function testCreateNoTypeNo() public function testCreateNoTypeNo()
@ -156,7 +156,7 @@ class FormBuilderTest extends TestCase
public function testGetUnknown() public function testGetUnknown()
{ {
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('The child with the name "foo" does not exist.'); $this->expectExceptionMessage('The child with the name "foo" does not exist.');
$this->builder->get('foo'); $this->builder->get('foo');
@ -223,7 +223,7 @@ class FormBuilderTest extends TestCase
private function getFormBuilder($name = 'name') private function getFormBuilder($name = 'name')
{ {
$mock = $this->getMockBuilder('Symfony\Component\Form\FormBuilder') $mock = $this->getMockBuilder(FormBuilder::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@ -53,10 +53,10 @@ class FormFactoryTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->guesser1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); $this->guesser1 = $this->getMockBuilder(\Symfony\Component\Form\FormTypeGuesserInterface::class)->getMock();
$this->guesser2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock(); $this->guesser2 = $this->getMockBuilder(\Symfony\Component\Form\FormTypeGuesserInterface::class)->getMock();
$this->registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock(); $this->registry = $this->getMockBuilder(\Symfony\Component\Form\FormRegistryInterface::class)->getMock();
$this->builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock(); $this->builder = $this->getMockBuilder(\Symfony\Component\Form\Test\FormBuilderInterface::class)->getMock();
$this->factory = new FormFactory($this->registry); $this->factory = new FormFactory($this->registry);
$this->registry->expects($this->any()) $this->registry->expects($this->any())
@ -155,7 +155,7 @@ class FormFactoryTest extends TestCase
$resolvedOptions = ['a' => '2', 'b' => '3']; $resolvedOptions = ['a' => '2', 'b' => '3'];
// the interface does not have the method, so use the real class // the interface does not have the method, so use the real class
$resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') $resolvedType = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormType::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -225,8 +225,8 @@ class FormFactoryTest extends TestCase
public function testCreateBuilderForPropertyWithoutTypeGuesser() public function testCreateBuilderForPropertyWithoutTypeGuesser()
{ {
$registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock(); $registry = $this->getMockBuilder(\Symfony\Component\Form\FormRegistryInterface::class)->getMock();
$factory = $this->getMockBuilder('Symfony\Component\Form\FormFactory') $factory = $this->getMockBuilder(FormFactory::class)
->setMethods(['createNamedBuilder']) ->setMethods(['createNamedBuilder'])
->setConstructorArgs([$registry]) ->setConstructorArgs([$registry])
->getMock(); ->getMock();
@ -463,7 +463,7 @@ class FormFactoryTest extends TestCase
private function getMockFactory(array $methods = []) private function getMockFactory(array $methods = [])
{ {
return $this->getMockBuilder('Symfony\Component\Form\FormFactory') return $this->getMockBuilder(FormFactory::class)
->setMethods($methods) ->setMethods($methods)
->setConstructorArgs([$this->registry]) ->setConstructorArgs([$this->registry])
->getMock(); ->getMock();
@ -471,6 +471,6 @@ class FormFactoryTest extends TestCase
private function getMockResolvedType() private function getMockResolvedType()
{ {
return $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); return $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
} }
} }

View File

@ -31,14 +31,14 @@ class FormRendererTest extends TestCase
public function testRenderARenderedField() public function testRenderARenderedField()
{ {
$this->expectException('Symfony\Component\Form\Exception\BadMethodCallException'); $this->expectException(\Symfony\Component\Form\Exception\BadMethodCallException::class);
$this->expectExceptionMessage('Field "foo" has already been rendered, save the result of previous render call to a variable and output that instead.'); $this->expectExceptionMessage('Field "foo" has already been rendered, save the result of previous render call to a variable and output that instead.');
$formView = new FormView(); $formView = new FormView();
$formView->vars['name'] = 'foo'; $formView->vars['name'] = 'foo';
$formView->setRendered(); $formView->setRendered();
$engine = $this->getMockBuilder('Symfony\Component\Form\FormRendererEngineInterface')->getMock(); $engine = $this->getMockBuilder(\Symfony\Component\Form\FormRendererEngineInterface::class)->getMock();
$renderer = new FormRenderer($engine); $renderer = new FormRenderer($engine);
$renderer->searchAndRenderBlock($formView, 'row'); $renderer->searchAndRenderBlock($formView, 'row');
} }

View File

@ -73,9 +73,9 @@ class ResolvedFormTypeTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); $this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
$this->dataMapper = $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock(); $this->dataMapper = $this->getMockBuilder(\Symfony\Component\Form\DataMapperInterface::class)->getMock();
$this->parentType = $this->getMockFormType(); $this->parentType = $this->getMockFormType();
$this->type = $this->getMockFormType(); $this->type = $this->getMockFormType();
$this->extension1 = $this->getMockFormTypeExtension(); $this->extension1 = $this->getMockFormTypeExtension();
@ -129,9 +129,9 @@ class ResolvedFormTypeTest extends TestCase
{ {
$givenOptions = ['a' => 'a_custom', 'c' => 'c_custom']; $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom'];
$resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default']; $resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default'];
$optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock(); $optionsResolver = $this->getMockBuilder(OptionsResolver::class)->getMock();
$this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') $this->resolvedType = $this->getMockBuilder(ResolvedFormType::class)
->setConstructorArgs([$this->type, [$this->extension1, $this->extension2], $this->parentResolvedType]) ->setConstructorArgs([$this->type, [$this->extension1, $this->extension2], $this->parentResolvedType])
->setMethods(['getOptionsResolver']) ->setMethods(['getOptionsResolver'])
->getMock(); ->getMock();
@ -157,9 +157,9 @@ class ResolvedFormTypeTest extends TestCase
{ {
$givenOptions = ['data_class' => 'Foo']; $givenOptions = ['data_class' => 'Foo'];
$resolvedOptions = ['data_class' => \stdClass::class]; $resolvedOptions = ['data_class' => \stdClass::class];
$optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock(); $optionsResolver = $this->getMockBuilder(OptionsResolver::class)->getMock();
$this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') $this->resolvedType = $this->getMockBuilder(ResolvedFormType::class)
->setConstructorArgs([$this->type, [$this->extension1, $this->extension2], $this->parentResolvedType]) ->setConstructorArgs([$this->type, [$this->extension1, $this->extension2], $this->parentResolvedType])
->setMethods(['getOptionsResolver']) ->setMethods(['getOptionsResolver'])
->getMock(); ->getMock();
@ -183,7 +183,7 @@ class ResolvedFormTypeTest extends TestCase
public function testFailsCreateBuilderOnInvalidFormOptionsResolution() public function testFailsCreateBuilderOnInvalidFormOptionsResolution()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class);
$this->expectExceptionMessage('An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\HiddenType": The required option "foo" is missing.'); $this->expectExceptionMessage('An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\HiddenType": The required option "foo" is missing.');
$optionsResolver = (new OptionsResolver()) $optionsResolver = (new OptionsResolver())
->setRequired('foo') ->setRequired('foo')
@ -219,7 +219,7 @@ class ResolvedFormTypeTest extends TestCase
}; };
$options = ['a' => 'Foo', 'b' => 'Bar']; $options = ['a' => 'Foo', 'b' => 'Bar'];
$builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock(); $builder = $this->getMockBuilder(\Symfony\Component\Form\Test\FormBuilderInterface::class)->getMock();
// First the form is built for the super type // First the form is built for the super type
$this->parentType->expects($this->once()) $this->parentType->expects($this->once())
@ -253,18 +253,18 @@ class ResolvedFormTypeTest extends TestCase
$view = $this->resolvedType->createView($form); $view = $this->resolvedType->createView($form);
$this->assertInstanceOf('Symfony\Component\Form\FormView', $view); $this->assertInstanceOf(\Symfony\Component\Form\FormView::class, $view);
$this->assertNull($view->parent); $this->assertNull($view->parent);
} }
public function testCreateViewWithParent() public function testCreateViewWithParent()
{ {
$form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock()); $form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock());
$parentView = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $parentView = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock();
$view = $this->resolvedType->createView($form, $parentView); $view = $this->resolvedType->createView($form, $parentView);
$this->assertInstanceOf('Symfony\Component\Form\FormView', $view); $this->assertInstanceOf(\Symfony\Component\Form\FormView::class, $view);
$this->assertSame($parentView, $view->parent); $this->assertSame($parentView, $view->parent);
} }
@ -272,7 +272,7 @@ class ResolvedFormTypeTest extends TestCase
{ {
$options = ['a' => '1', 'b' => '2']; $options = ['a' => '1', 'b' => '2'];
$form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock()); $form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock());
$view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $view = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock();
$i = 0; $i = 0;
@ -314,7 +314,7 @@ class ResolvedFormTypeTest extends TestCase
{ {
$options = ['a' => '1', 'b' => '2']; $options = ['a' => '1', 'b' => '2'];
$form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock()); $form = new Form($this->getMockBuilder(FormConfigInterface::class)->getMock());
$view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock(); $view = $this->getMockBuilder(\Symfony\Component\Form\FormView::class)->getMock();
$i = 0; $i = 0;
@ -392,11 +392,11 @@ class ResolvedFormTypeTest extends TestCase
private function getMockFormTypeExtension(): MockObject private function getMockFormTypeExtension(): MockObject
{ {
return $this->getMockBuilder('Symfony\Component\Form\AbstractTypeExtension')->setMethods(['getExtendedTypes', 'configureOptions', 'finishView', 'buildView', 'buildForm'])->getMock(); return $this->getMockBuilder(\Symfony\Component\Form\AbstractTypeExtension::class)->setMethods(['getExtendedTypes', 'configureOptions', 'finishView', 'buildView', 'buildForm'])->getMock();
} }
private function getMockFormFactory(): MockObject private function getMockFormFactory(): MockObject
{ {
return $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); return $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
} }
} }

View File

@ -193,28 +193,28 @@ class HttpClientTraitTest extends TestCase
public function testInvalidAuthBearerOption() public function testInvalidAuthBearerOption()
{ {
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Option "auth_bearer" must be a string, "stdClass" given.'); $this->expectExceptionMessage('Option "auth_bearer" must be a string, "stdClass" given.');
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS); self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS);
} }
public function testInvalidAuthBearerValue() public function testInvalidAuthBearerValue()
{ {
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid character found in option "auth_bearer": "a\nb".'); $this->expectExceptionMessage('Invalid character found in option "auth_bearer": "a\nb".');
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => "a\nb"], HttpClientInterface::OPTIONS_DEFAULTS); self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => "a\nb"], HttpClientInterface::OPTIONS_DEFAULTS);
} }
public function testSetAuthBasicAndBearerOptions() public function testSetAuthBasicAndBearerOptions()
{ {
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Define either the "auth_basic" or the "auth_bearer" option, setting both is not supported.'); $this->expectExceptionMessage('Define either the "auth_basic" or the "auth_bearer" option, setting both is not supported.');
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => 'foo', 'auth_basic' => 'foo:bar'], HttpClientInterface::OPTIONS_DEFAULTS); self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => 'foo', 'auth_basic' => 'foo:bar'], HttpClientInterface::OPTIONS_DEFAULTS);
} }
public function testSetJSONAndBodyOptions() public function testSetJSONAndBodyOptions()
{ {
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Define either the "json" or the "body" option, setting both is not supported'); $this->expectExceptionMessage('Define either the "json" or the "body" option, setting both is not supported');
self::prepareRequest('POST', 'http://example.com', ['json' => ['foo' => 'bar'], 'body' => '<html/>'], HttpClientInterface::OPTIONS_DEFAULTS); self::prepareRequest('POST', 'http://example.com', ['json' => ['foo' => 'bar'], 'body' => '<html/>'], HttpClientInterface::OPTIONS_DEFAULTS);
} }
@ -256,14 +256,14 @@ class HttpClientTraitTest extends TestCase
public function testNormalizePeerFingerprintException() public function testNormalizePeerFingerprintException()
{ {
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Cannot auto-detect fingerprint algorithm for "foo".'); $this->expectExceptionMessage('Cannot auto-detect fingerprint algorithm for "foo".');
$this->normalizePeerFingerprint('foo'); $this->normalizePeerFingerprint('foo');
} }
public function testNormalizePeerFingerprintTypeException() public function testNormalizePeerFingerprintTypeException()
{ {
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Option "peer_fingerprint" must be string or array, "stdClass" given.'); $this->expectExceptionMessage('Option "peer_fingerprint" must be string or array, "stdClass" given.');
$fingerprint = new \stdClass(); $fingerprint = new \stdClass();

View File

@ -52,7 +52,7 @@ class CookieTest extends TestCase
*/ */
public function testWithRawThrowsExceptionIfCookieNameContainsSpecialCharacters($name) public function testWithRawThrowsExceptionIfCookieNameContainsSpecialCharacters($name)
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
Cookie::create($name)->withRaw(); Cookie::create($name)->withRaw();
} }

View File

@ -97,7 +97,7 @@ class JsonResponseTest extends TestCase
{ {
$response = JsonResponse::create(['foo' => 'bar'], 204); $response = JsonResponse::create(['foo' => 'bar'], 204);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); $this->assertInstanceOf(JsonResponse::class, $response);
$this->assertEquals('{"foo":"bar"}', $response->getContent()); $this->assertEquals('{"foo":"bar"}', $response->getContent());
$this->assertEquals(204, $response->getStatusCode()); $this->assertEquals(204, $response->getStatusCode());
} }
@ -108,7 +108,7 @@ class JsonResponseTest extends TestCase
public function testStaticCreateEmptyJsonObject() public function testStaticCreateEmptyJsonObject()
{ {
$response = JsonResponse::create(); $response = JsonResponse::create();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); $this->assertInstanceOf(JsonResponse::class, $response);
$this->assertSame('{}', $response->getContent()); $this->assertSame('{}', $response->getContent());
} }
@ -118,7 +118,7 @@ class JsonResponseTest extends TestCase
public function testStaticCreateJsonArray() public function testStaticCreateJsonArray()
{ {
$response = JsonResponse::create([0, 1, 2, 3]); $response = JsonResponse::create([0, 1, 2, 3]);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); $this->assertInstanceOf(JsonResponse::class, $response);
$this->assertSame('[0,1,2,3]', $response->getContent()); $this->assertSame('[0,1,2,3]', $response->getContent());
} }
@ -128,7 +128,7 @@ class JsonResponseTest extends TestCase
public function testStaticCreateJsonObject() public function testStaticCreateJsonObject()
{ {
$response = JsonResponse::create(['foo' => 'bar']); $response = JsonResponse::create(['foo' => 'bar']);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); $this->assertInstanceOf(JsonResponse::class, $response);
$this->assertSame('{"foo":"bar"}', $response->getContent()); $this->assertSame('{"foo":"bar"}', $response->getContent());
} }
@ -138,20 +138,20 @@ class JsonResponseTest extends TestCase
public function testStaticCreateWithSimpleTypes() public function testStaticCreateWithSimpleTypes()
{ {
$response = JsonResponse::create('foo'); $response = JsonResponse::create('foo');
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); $this->assertInstanceOf(JsonResponse::class, $response);
$this->assertSame('"foo"', $response->getContent()); $this->assertSame('"foo"', $response->getContent());
$response = JsonResponse::create(0); $response = JsonResponse::create(0);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); $this->assertInstanceOf(JsonResponse::class, $response);
$this->assertSame('0', $response->getContent()); $this->assertSame('0', $response->getContent());
$response = JsonResponse::create(0.1); $response = JsonResponse::create(0.1);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); $this->assertInstanceOf(JsonResponse::class, $response);
$this->assertEquals(0.1, $response->getContent()); $this->assertEquals(0.1, $response->getContent());
$this->assertIsString($response->getContent()); $this->assertIsString($response->getContent());
$response = JsonResponse::create(true); $response = JsonResponse::create(true);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); $this->assertInstanceOf(JsonResponse::class, $response);
$this->assertSame('true', $response->getContent()); $this->assertSame('true', $response->getContent());
} }
@ -236,22 +236,22 @@ class JsonResponseTest extends TestCase
public function testSetCallbackInvalidIdentifier() public function testSetCallbackInvalidIdentifier()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$response = new JsonResponse('foo'); $response = new JsonResponse('foo');
$response->setCallback('+invalid'); $response->setCallback('+invalid');
} }
public function testSetContent() public function testSetContent()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
new JsonResponse("\xB1\x31"); new JsonResponse("\xB1\x31");
} }
public function testSetContentJsonSerializeError() public function testSetContentJsonSerializeError()
{ {
$this->expectException('Exception'); $this->expectException(\Exception::class);
$this->expectExceptionMessage('This error is expected'); $this->expectExceptionMessage('This error is expected');
if (!interface_exists('JsonSerializable', false)) { if (!interface_exists(\JsonSerializable::class, false)) {
$this->markTestSkipped('JsonSerializable is required.'); $this->markTestSkipped('JsonSerializable is required.');
} }
@ -299,7 +299,7 @@ class JsonResponseTest extends TestCase
} }
} }
if (interface_exists('JsonSerializable', false)) { if (interface_exists(\JsonSerializable::class, false)) {
class JsonSerializableObject implements \JsonSerializable class JsonSerializableObject implements \JsonSerializable
{ {
public function jsonSerialize() public function jsonSerialize()

View File

@ -25,14 +25,14 @@ class RedirectResponseTest extends TestCase
public function testRedirectResponseConstructorEmptyUrl() public function testRedirectResponseConstructorEmptyUrl()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Cannot redirect to an empty URL.'); $this->expectExceptionMessage('Cannot redirect to an empty URL.');
new RedirectResponse(''); new RedirectResponse('');
} }
public function testRedirectResponseConstructorWrongStatusCode() public function testRedirectResponseConstructorWrongStatusCode()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
new RedirectResponse('foo.bar', 404); new RedirectResponse('foo.bar', 404);
} }
@ -66,7 +66,7 @@ class RedirectResponseTest extends TestCase
{ {
$response = RedirectResponse::create('foo', 301); $response = RedirectResponse::create('foo', 301);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); $this->assertInstanceOf(RedirectResponse::class, $response);
$this->assertEquals(301, $response->getStatusCode()); $this->assertEquals(301, $response->getStatusCode());
} }

View File

@ -27,7 +27,7 @@ class ResponseTest extends ResponseTestCase
{ {
$response = Response::create('foo', 301, ['Foo' => 'bar']); $response = Response::create('foo', 301, ['Foo' => 'bar']);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); $this->assertInstanceOf(Response::class, $response);
$this->assertEquals(301, $response->getStatusCode()); $this->assertEquals(301, $response->getStatusCode());
$this->assertEquals('bar', $response->headers->get('foo')); $this->assertEquals('bar', $response->headers->get('foo'));
} }
@ -614,7 +614,7 @@ class ResponseTest extends ResponseTestCase
$response->setCache(['wrong option' => 'value']); $response->setCache(['wrong option' => 'value']);
$this->fail('->setCache() throws an InvalidArgumentException if an option is not supported'); $this->fail('->setCache() throws an InvalidArgumentException if an option is not supported');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->assertInstanceOf('InvalidArgumentException', $e, '->setCache() throws an InvalidArgumentException if an option is not supported'); $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->setCache() throws an InvalidArgumentException if an option is not supported');
$this->assertStringContainsString('"wrong option"', $e->getMessage()); $this->assertStringContainsString('"wrong option"', $e->getMessage());
} }

View File

@ -71,14 +71,14 @@ class NativeSessionStorageTest extends TestCase
public function testRegisterBagException() public function testRegisterBagException()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$storage = $this->getStorage(); $storage = $this->getStorage();
$storage->getBag('non_existing'); $storage->getBag('non_existing');
} }
public function testRegisterBagForAStartedSessionThrowsException() public function testRegisterBagForAStartedSessionThrowsException()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$storage = $this->getStorage(); $storage = $this->getStorage();
$storage->start(); $storage->start();
$storage->registerBag(new AttributeBag()); $storage->registerBag(new AttributeBag());
@ -210,22 +210,22 @@ class NativeSessionStorageTest extends TestCase
$this->iniSet('session.save_handler', 'files'); $this->iniSet('session.save_handler', 'files');
$storage = $this->getStorage(); $storage = $this->getStorage();
$storage->setSaveHandler(); $storage->setSaveHandler();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(null); $storage->setSaveHandler(null);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler())); $storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler()));
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new NativeFileSessionHandler()); $storage->setSaveHandler(new NativeFileSessionHandler());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler()));
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
$storage->setSaveHandler(new NullSessionHandler()); $storage->setSaveHandler(new NullSessionHandler());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); $this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
} }
public function testStarted() public function testStarted()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$storage = $this->getStorage(); $storage = $this->getStorage();
$this->assertFalse($storage->getSaveHandler()->isActive()); $this->assertFalse($storage->getSaveHandler()->isActive());

View File

@ -18,7 +18,7 @@ class FileLocatorTest extends TestCase
{ {
public function testLocate() public function testLocate()
{ {
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
$kernel $kernel
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('locateResource') ->method('locateResource')
@ -30,7 +30,7 @@ class FileLocatorTest extends TestCase
$kernel $kernel
->expects($this->never()) ->expects($this->never())
->method('locateResource'); ->method('locateResource');
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$locator->locate('/some/path'); $locator->locate('/some/path');
} }
} }

View File

@ -27,7 +27,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
{ {
public function testInvalidClass() public function testInvalidClass()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Class "Symfony\Component\HttpKernel\Tests\DependencyInjection\NotFound" used for service "foo" cannot be found.'); $this->expectExceptionMessage('Class "Symfony\Component\HttpKernel\Tests\DependencyInjection\NotFound" used for service "foo" cannot be found.');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]); $container->register('argument_resolver.service')->addArgument([]);
@ -42,7 +42,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function testNoAction() public function testNoAction()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Missing "action" attribute on tag "controller.service_arguments" {"argument":"bar"} for service "foo".'); $this->expectExceptionMessage('Missing "action" attribute on tag "controller.service_arguments" {"argument":"bar"} for service "foo".');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]); $container->register('argument_resolver.service')->addArgument([]);
@ -57,7 +57,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function testNoArgument() public function testNoArgument()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Missing "argument" attribute on tag "controller.service_arguments" {"action":"fooAction"} for service "foo".'); $this->expectExceptionMessage('Missing "argument" attribute on tag "controller.service_arguments" {"action":"fooAction"} for service "foo".');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]); $container->register('argument_resolver.service')->addArgument([]);
@ -72,7 +72,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function testNoService() public function testNoService()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Missing "id" attribute on tag "controller.service_arguments" {"action":"fooAction","argument":"bar"} for service "foo".'); $this->expectExceptionMessage('Missing "id" attribute on tag "controller.service_arguments" {"action":"fooAction","argument":"bar"} for service "foo".');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]); $container->register('argument_resolver.service')->addArgument([]);
@ -87,7 +87,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function testInvalidMethod() public function testInvalidMethod()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid "action" attribute on tag "controller.service_arguments" for service "foo": no public "barAction()" method found on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".'); $this->expectExceptionMessage('Invalid "action" attribute on tag "controller.service_arguments" for service "foo": no public "barAction()" method found on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]); $container->register('argument_resolver.service')->addArgument([]);
@ -102,7 +102,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function testInvalidArgument() public function testInvalidArgument()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid "controller.service_arguments" tag for service "foo": method "fooAction()" has no "baz" argument on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".'); $this->expectExceptionMessage('Invalid "controller.service_arguments" tag for service "foo": method "fooAction()" has no "baz" argument on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]); $container->register('argument_resolver.service')->addArgument([]);
@ -197,7 +197,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function testExceptionOnNonExistentTypeHint() public function testExceptionOnNonExistentTypeHint()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClass". Did you forget to add a use statement?'); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClass". Did you forget to add a use statement?');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]); $container->register('argument_resolver.service')->addArgument([]);
@ -217,7 +217,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function testExceptionOnNonExistentTypeHintDifferentNamespace() public function testExceptionOnNonExistentTypeHintDifferentNamespace()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassDifferentNamespaceController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Acme\NonExistentClass".'); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassDifferentNamespaceController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Acme\NonExistentClass".');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]); $container->register('argument_resolver.service')->addArgument([]);

View File

@ -23,7 +23,7 @@ class HIncludeFragmentRendererTest extends TestCase
{ {
public function testRenderExceptionWhenControllerAndNoSigner() public function testRenderExceptionWhenControllerAndNoSigner()
{ {
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$strategy = new HIncludeFragmentRenderer(); $strategy = new HIncludeFragmentRenderer();
$strategy->render(new ControllerReference('main_controller', [], []), Request::create('/')); $strategy->render(new ControllerReference('main_controller', [], []), Request::create('/'));
} }

View File

@ -93,7 +93,7 @@ class ConnectionTest extends TestCase
public function testItThrowsATransportExceptionIfItCannotAcknowledgeMessage() public function testItThrowsATransportExceptionIfItCannotAcknowledgeMessage()
{ {
$this->expectException('Symfony\Component\Messenger\Exception\TransportException'); $this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class);
$driverConnection = $this->getDBALConnectionMock(); $driverConnection = $this->getDBALConnectionMock();
if (class_exists(Exception::class)) { if (class_exists(Exception::class)) {
@ -108,7 +108,7 @@ class ConnectionTest extends TestCase
public function testItThrowsATransportExceptionIfItCannotRejectMessage() public function testItThrowsATransportExceptionIfItCannotRejectMessage()
{ {
$this->expectException('Symfony\Component\Messenger\Exception\TransportException'); $this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class);
$driverConnection = $this->getDBALConnectionMock(); $driverConnection = $this->getDBALConnectionMock();
if (class_exists(Exception::class)) { if (class_exists(Exception::class)) {
@ -257,14 +257,14 @@ class ConnectionTest extends TestCase
public function testItThrowsAnExceptionIfAnExtraOptionsInDefined() public function testItThrowsAnExceptionIfAnExtraOptionsInDefined()
{ {
$this->expectException('Symfony\Component\Messenger\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Messenger\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Unknown option found: [new_option]. Allowed options are [table_name, queue_name, redeliver_timeout, auto_setup]'); $this->expectExceptionMessage('Unknown option found: [new_option]. Allowed options are [table_name, queue_name, redeliver_timeout, auto_setup]');
Connection::buildConfiguration('doctrine://default', ['new_option' => 'woops']); Connection::buildConfiguration('doctrine://default', ['new_option' => 'woops']);
} }
public function testItThrowsAnExceptionIfAnExtraOptionsInDefinedInDSN() public function testItThrowsAnExceptionIfAnExtraOptionsInDefinedInDSN()
{ {
$this->expectException('Symfony\Component\Messenger\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Messenger\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Unknown option found in DSN: [new_option]. Allowed options are [table_name, queue_name, redeliver_timeout, auto_setup]'); $this->expectExceptionMessage('Unknown option found in DSN: [new_option]. Allowed options are [table_name, queue_name, redeliver_timeout, auto_setup]');
Connection::buildConfiguration('doctrine://default?new_option=woops'); Connection::buildConfiguration('doctrine://default?new_option=woops');
} }

View File

@ -14,7 +14,7 @@ class HandleTraitTest extends TestCase
{ {
public function testItThrowsOnNoMessageBusInstance() public function testItThrowsOnNoMessageBusInstance()
{ {
$this->expectException('Symfony\Component\Messenger\Exception\LogicException'); $this->expectException(\Symfony\Component\Messenger\Exception\LogicException::class);
$this->expectExceptionMessage('You must provide a "Symfony\Component\Messenger\MessageBusInterface" instance in the "Symfony\Component\Messenger\Tests\TestQueryBus::$messageBus" property, "null" given.'); $this->expectExceptionMessage('You must provide a "Symfony\Component\Messenger\MessageBusInterface" instance in the "Symfony\Component\Messenger\Tests\TestQueryBus::$messageBus" property, "null" given.');
$queryBus = new TestQueryBus(null); $queryBus = new TestQueryBus(null);
$query = new DummyMessage('Hello'); $query = new DummyMessage('Hello');
@ -48,7 +48,7 @@ class HandleTraitTest extends TestCase
public function testHandleThrowsOnNoHandledStamp() public function testHandleThrowsOnNoHandledStamp()
{ {
$this->expectException('Symfony\Component\Messenger\Exception\LogicException'); $this->expectException(\Symfony\Component\Messenger\Exception\LogicException::class);
$this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled zero times. Exactly one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()".'); $this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled zero times. Exactly one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()".');
$bus = $this->createMock(MessageBus::class); $bus = $this->createMock(MessageBus::class);
$queryBus = new TestQueryBus($bus); $queryBus = new TestQueryBus($bus);
@ -61,7 +61,7 @@ class HandleTraitTest extends TestCase
public function testHandleThrowsOnMultipleHandledStamps() public function testHandleThrowsOnMultipleHandledStamps()
{ {
$this->expectException('Symfony\Component\Messenger\Exception\LogicException'); $this->expectException(\Symfony\Component\Messenger\Exception\LogicException::class);
$this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled multiple times. Only one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()", got 2: "FirstDummyHandler::__invoke", "SecondDummyHandler::__invoke".'); $this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled multiple times. Only one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()", got 2: "FirstDummyHandler::__invoke", "SecondDummyHandler::__invoke".');
$bus = $this->createMock(MessageBus::class); $bus = $this->createMock(MessageBus::class);
$queryBus = new TestQueryBus($bus); $queryBus = new TestQueryBus($bus);

View File

@ -37,7 +37,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfNonExistingOption() public function testResolveFailsIfNonExistingOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->expectExceptionMessage('The option "foo" does not exist. Defined options are: "a", "z".'); $this->expectExceptionMessage('The option "foo" does not exist. Defined options are: "a", "z".');
$this->resolver->setDefault('z', '1'); $this->resolver->setDefault('z', '1');
$this->resolver->setDefault('a', '2'); $this->resolver->setDefault('a', '2');
@ -47,7 +47,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfMultipleNonExistingOptions() public function testResolveFailsIfMultipleNonExistingOptions()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->expectExceptionMessage('The options "baz", "foo", "ping" do not exist. Defined options are: "a", "z".'); $this->expectExceptionMessage('The options "baz", "foo", "ping" do not exist. Defined options are: "a", "z".');
$this->resolver->setDefault('z', '1'); $this->resolver->setDefault('z', '1');
$this->resolver->setDefault('a', '2'); $this->resolver->setDefault('a', '2');
@ -57,7 +57,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsFromLazyOption() public function testResolveFailsFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->resolve([]); $options->resolve([]);
}); });
@ -83,7 +83,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfSetDefaultFromLazyOption() public function testFailIfSetDefaultFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('lazy', function (Options $options) { $this->resolver->setDefault('lazy', function (Options $options) {
$options->setDefault('default', 42); $options->setDefault('default', 42);
}); });
@ -225,7 +225,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfSetRequiredFromLazyOption() public function testFailIfSetRequiredFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->setRequired('bar'); $options->setRequired('bar');
}); });
@ -235,7 +235,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfRequiredOptionMissing() public function testResolveFailsIfRequiredOptionMissing()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class);
$this->resolver->setRequired('foo'); $this->resolver->setRequired('foo');
$this->resolver->resolve(); $this->resolver->resolve();
@ -349,7 +349,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfSetDefinedFromLazyOption() public function testFailIfSetDefinedFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->setDefined('bar'); $options->setDefined('bar');
}); });
@ -444,7 +444,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfSetDeprecatedFromLazyOption() public function testFailIfSetDeprecatedFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver $this->resolver
->setDefault('bar', 'baz') ->setDefault('bar', 'baz')
->setDefault('foo', function (Options $options) { ->setDefault('foo', function (Options $options) {
@ -456,13 +456,13 @@ class OptionsResolverTest extends TestCase
public function testSetDeprecatedFailsIfUnknownOption() public function testSetDeprecatedFailsIfUnknownOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->resolver->setDeprecated('foo'); $this->resolver->setDeprecated('foo');
} }
public function testSetDeprecatedFailsIfInvalidDeprecationMessageType() public function testSetDeprecatedFailsIfInvalidDeprecationMessageType()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid type for deprecation message argument, expected string or \Closure, but got "bool".'); $this->expectExceptionMessage('Invalid type for deprecation message argument, expected string or \Closure, but got "bool".');
$this->resolver $this->resolver
->setDefined('foo') ->setDefined('foo')
@ -472,7 +472,7 @@ class OptionsResolverTest extends TestCase
public function testLazyDeprecationFailsIfInvalidDeprecationMessageType() public function testLazyDeprecationFailsIfInvalidDeprecationMessageType()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid type for deprecation message, expected string but got "bool", return an empty string to ignore.'); $this->expectExceptionMessage('Invalid type for deprecation message, expected string but got "bool", return an empty string to ignore.');
$this->resolver $this->resolver
->setDefined('foo') ->setDefined('foo')
@ -485,7 +485,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfCyclicDependencyBetweenDeprecation() public function testFailsIfCyclicDependencyBetweenDeprecation()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
$this->expectExceptionMessage('The options "foo", "bar" have a cyclic dependency.'); $this->expectExceptionMessage('The options "foo", "bar" have a cyclic dependency.');
$this->resolver $this->resolver
->setDefined(['foo', 'bar']) ->setDefined(['foo', 'bar'])
@ -756,7 +756,7 @@ class OptionsResolverTest extends TestCase
public function testSetAllowedTypesFailsIfUnknownOption() public function testSetAllowedTypesFailsIfUnknownOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->resolver->setAllowedTypes('foo', 'string'); $this->resolver->setAllowedTypes('foo', 'string');
} }
@ -771,7 +771,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfSetAllowedTypesFromLazyOption() public function testFailIfSetAllowedTypesFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->setAllowedTypes('bar', 'string'); $options->setAllowedTypes('bar', 'string');
}); });
@ -783,7 +783,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidTypedArray() public function testResolveFailsIfInvalidTypedArray()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "DateTime".'); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "DateTime".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[]'); $this->resolver->setAllowedTypes('foo', 'int[]');
@ -793,7 +793,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsWithNonArray() public function testResolveFailsWithNonArray()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value "bar" is expected to be of type "int[]", but is of type "string".'); $this->expectExceptionMessage('The option "foo" with value "bar" is expected to be of type "int[]", but is of type "string".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[]'); $this->resolver->setAllowedTypes('foo', 'int[]');
@ -803,7 +803,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfTypedArrayContainsInvalidTypes() public function testResolveFailsIfTypedArrayContainsInvalidTypes()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "stdClass|array|DateTime".'); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "stdClass|array|DateTime".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[]'); $this->resolver->setAllowedTypes('foo', 'int[]');
@ -818,7 +818,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsWithCorrectLevelsButWrongScalar() public function testResolveFailsWithCorrectLevelsButWrongScalar()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "float".'); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "float".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][]'); $this->resolver->setAllowedTypes('foo', 'int[][]');
@ -838,7 +838,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefined('option'); $this->resolver->setDefined('option');
$this->resolver->setAllowedTypes('option', $allowedType); $this->resolver->setAllowedTypes('option', $allowedType);
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage($exceptionMessage); $this->expectExceptionMessage($exceptionMessage);
$this->resolver->resolve(['option' => $actualType]); $this->resolver->resolve(['option' => $actualType]);
@ -873,7 +873,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidTypeMultiple() public function testResolveFailsIfInvalidTypeMultiple()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value 42 is expected to be of type "string" or "bool", but is of type "int".'); $this->expectExceptionMessage('The option "foo" with value 42 is expected to be of type "string" or "bool", but is of type "int".');
$this->resolver->setDefault('foo', 42); $this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedTypes('foo', ['string', 'bool']); $this->resolver->setAllowedTypes('foo', ['string', 'bool']);
@ -914,7 +914,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfNotInstanceOfClass() public function testResolveFailsIfNotInstanceOfClass()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 'bar'); $this->resolver->setDefault('foo', 'bar');
$this->resolver->setAllowedTypes('foo', '\stdClass'); $this->resolver->setAllowedTypes('foo', '\stdClass');
@ -923,13 +923,13 @@ class OptionsResolverTest extends TestCase
public function testAddAllowedTypesFailsIfUnknownOption() public function testAddAllowedTypesFailsIfUnknownOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->resolver->addAllowedTypes('foo', 'string'); $this->resolver->addAllowedTypes('foo', 'string');
} }
public function testFailIfAddAllowedTypesFromLazyOption() public function testFailIfAddAllowedTypesFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->addAllowedTypes('bar', 'string'); $options->addAllowedTypes('bar', 'string');
}); });
@ -941,7 +941,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidAddedType() public function testResolveFailsIfInvalidAddedType()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 42); $this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedTypes('foo', 'string'); $this->resolver->addAllowedTypes('foo', 'string');
@ -958,7 +958,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidAddedTypeMultiple() public function testResolveFailsIfInvalidAddedTypeMultiple()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 42); $this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedTypes('foo', ['string', 'bool']); $this->resolver->addAllowedTypes('foo', ['string', 'bool']);
@ -997,13 +997,13 @@ class OptionsResolverTest extends TestCase
public function testSetAllowedValuesFailsIfUnknownOption() public function testSetAllowedValuesFailsIfUnknownOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->resolver->setAllowedValues('foo', 'bar'); $this->resolver->setAllowedValues('foo', 'bar');
} }
public function testFailIfSetAllowedValuesFromLazyOption() public function testFailIfSetAllowedValuesFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->setAllowedValues('bar', 'baz'); $options->setAllowedValues('bar', 'baz');
}); });
@ -1015,7 +1015,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidValue() public function testResolveFailsIfInvalidValue()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value 42 is invalid. Accepted values are: "bar".'); $this->expectExceptionMessage('The option "foo" with value 42 is invalid. Accepted values are: "bar".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedValues('foo', 'bar'); $this->resolver->setAllowedValues('foo', 'bar');
@ -1025,7 +1025,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidValueIsNull() public function testResolveFailsIfInvalidValueIsNull()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value null is invalid. Accepted values are: "bar".'); $this->expectExceptionMessage('The option "foo" with value null is invalid. Accepted values are: "bar".');
$this->resolver->setDefault('foo', null); $this->resolver->setDefault('foo', null);
$this->resolver->setAllowedValues('foo', 'bar'); $this->resolver->setAllowedValues('foo', 'bar');
@ -1035,7 +1035,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidValueStrict() public function testResolveFailsIfInvalidValueStrict()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 42); $this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', '42'); $this->resolver->setAllowedValues('foo', '42');
@ -1060,7 +1060,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidValueMultiple() public function testResolveFailsIfInvalidValueMultiple()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value 42 is invalid. Accepted values are: "bar", false, null.'); $this->expectExceptionMessage('The option "foo" with value 42 is invalid. Accepted values are: "bar", false, null.');
$this->resolver->setDefault('foo', 42); $this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', ['bar', false, null]); $this->resolver->setAllowedValues('foo', ['bar', false, null]);
@ -1109,7 +1109,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfAllClosuresReturnFalse() public function testResolveFailsIfAllClosuresReturnFalse()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 42); $this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', [ $this->resolver->setAllowedValues('foo', [
function () { return false; }, function () { return false; },
@ -1134,13 +1134,13 @@ class OptionsResolverTest extends TestCase
public function testAddAllowedValuesFailsIfUnknownOption() public function testAddAllowedValuesFailsIfUnknownOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->resolver->addAllowedValues('foo', 'bar'); $this->resolver->addAllowedValues('foo', 'bar');
} }
public function testFailIfAddAllowedValuesFromLazyOption() public function testFailIfAddAllowedValuesFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->addAllowedValues('bar', 'baz'); $options->addAllowedValues('bar', 'baz');
}); });
@ -1152,7 +1152,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidAddedValue() public function testResolveFailsIfInvalidAddedValue()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 42); $this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedValues('foo', 'bar'); $this->resolver->addAllowedValues('foo', 'bar');
@ -1177,7 +1177,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidAddedValueMultiple() public function testResolveFailsIfInvalidAddedValueMultiple()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 42); $this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedValues('foo', ['bar', 'baz']); $this->resolver->addAllowedValues('foo', ['bar', 'baz']);
@ -1212,7 +1212,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfAllAddedClosuresReturnFalse() public function testResolveFailsIfAllAddedClosuresReturnFalse()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 42); $this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', function () { return false; }); $this->resolver->setAllowedValues('foo', function () { return false; });
$this->resolver->addAllowedValues('foo', function () { return false; }); $this->resolver->addAllowedValues('foo', function () { return false; });
@ -1256,13 +1256,13 @@ class OptionsResolverTest extends TestCase
public function testSetNormalizerFailsIfUnknownOption() public function testSetNormalizerFailsIfUnknownOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->resolver->setNormalizer('foo', function () {}); $this->resolver->setNormalizer('foo', function () {});
} }
public function testFailIfSetNormalizerFromLazyOption() public function testFailIfSetNormalizerFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->setNormalizer('foo', function () {}); $options->setNormalizer('foo', function () {});
}); });
@ -1298,7 +1298,7 @@ class OptionsResolverTest extends TestCase
public function testValidateTypeBeforeNormalization() public function testValidateTypeBeforeNormalization()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 'bar'); $this->resolver->setDefault('foo', 'bar');
$this->resolver->setAllowedTypes('foo', 'int'); $this->resolver->setAllowedTypes('foo', 'int');
@ -1312,7 +1312,7 @@ class OptionsResolverTest extends TestCase
public function testValidateValueBeforeNormalization() public function testValidateValueBeforeNormalization()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->resolver->setDefault('foo', 'bar'); $this->resolver->setDefault('foo', 'bar');
$this->resolver->setAllowedValues('foo', 'baz'); $this->resolver->setAllowedValues('foo', 'baz');
@ -1364,7 +1364,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfCyclicDependencyBetweenNormalizers() public function testFailIfCyclicDependencyBetweenNormalizers()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
$this->resolver->setDefault('norm1', 'bar'); $this->resolver->setDefault('norm1', 'bar');
$this->resolver->setDefault('norm2', 'baz'); $this->resolver->setDefault('norm2', 'baz');
@ -1381,7 +1381,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfCyclicDependencyBetweenNormalizerAndLazyOption() public function testFailIfCyclicDependencyBetweenNormalizerAndLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
$this->resolver->setDefault('lazy', function (Options $options) { $this->resolver->setDefault('lazy', function (Options $options) {
$options['norm']; $options['norm'];
}); });
@ -1527,13 +1527,13 @@ class OptionsResolverTest extends TestCase
public function testAddNormalizerFailsIfUnknownOption() public function testAddNormalizerFailsIfUnknownOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->resolver->addNormalizer('foo', function () {}); $this->resolver->addNormalizer('foo', function () {});
} }
public function testFailIfAddNormalizerFromLazyOption() public function testFailIfAddNormalizerFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->addNormalizer('foo', function () {}); $options->addNormalizer('foo', function () {});
}); });
@ -1565,7 +1565,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfSetDefaultsFromLazyOption() public function testFailIfSetDefaultsFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->setDefaults(['two' => '2']); $options->setDefaults(['two' => '2']);
}); });
@ -1644,7 +1644,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfRemoveFromLazyOption() public function testFailIfRemoveFromLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->remove('bar'); $options->remove('bar');
}); });
@ -1718,7 +1718,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfClearFromLazyption() public function testFailIfClearFromLazyption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', function (Options $options) { $this->resolver->setDefault('foo', function (Options $options) {
$options->clear(); $options->clear();
}); });
@ -1775,7 +1775,7 @@ class OptionsResolverTest extends TestCase
public function testArrayAccessGetFailsOutsideResolve() public function testArrayAccessGetFailsOutsideResolve()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('default', 0); $this->resolver->setDefault('default', 0);
$this->resolver['default']; $this->resolver['default'];
@ -1783,7 +1783,7 @@ class OptionsResolverTest extends TestCase
public function testArrayAccessExistsFailsOutsideResolve() public function testArrayAccessExistsFailsOutsideResolve()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('default', 0); $this->resolver->setDefault('default', 0);
isset($this->resolver['default']); isset($this->resolver['default']);
@ -1791,13 +1791,13 @@ class OptionsResolverTest extends TestCase
public function testArrayAccessSetNotSupported() public function testArrayAccessSetNotSupported()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver['default'] = 0; $this->resolver['default'] = 0;
} }
public function testArrayAccessUnsetNotSupported() public function testArrayAccessUnsetNotSupported()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('default', 0); $this->resolver->setDefault('default', 0);
unset($this->resolver['default']); unset($this->resolver['default']);
@ -1805,7 +1805,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfGetNonExisting() public function testFailIfGetNonExisting()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\NoSuchOptionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoSuchOptionException::class);
$this->expectExceptionMessage('The option "undefined" does not exist. Defined options are: "foo", "lazy".'); $this->expectExceptionMessage('The option "undefined" does not exist. Defined options are: "foo", "lazy".');
$this->resolver->setDefault('foo', 'bar'); $this->resolver->setDefault('foo', 'bar');
@ -1818,7 +1818,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfGetDefinedButUnset() public function testFailIfGetDefinedButUnset()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\NoSuchOptionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\NoSuchOptionException::class);
$this->expectExceptionMessage('The optional option "defined" has no value set. You should make sure it is set with "isset" before reading it.'); $this->expectExceptionMessage('The optional option "defined" has no value set. You should make sure it is set with "isset" before reading it.');
$this->resolver->setDefined('defined'); $this->resolver->setDefined('defined');
@ -1831,7 +1831,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfCyclicDependency() public function testFailIfCyclicDependency()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
$this->resolver->setDefault('lazy1', function (Options $options) { $this->resolver->setDefault('lazy1', function (Options $options) {
$options['lazy2']; $options['lazy2'];
}); });
@ -1864,7 +1864,7 @@ class OptionsResolverTest extends TestCase
*/ */
public function testCountFailsOutsideResolve() public function testCountFailsOutsideResolve()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException'); $this->expectException(AccessException::class);
$this->resolver->setDefault('foo', 0); $this->resolver->setDefault('foo', 0);
$this->resolver->setRequired('bar'); $this->resolver->setRequired('bar');
$this->resolver->setDefined('bar'); $this->resolver->setDefined('bar');
@ -1921,7 +1921,7 @@ class OptionsResolverTest extends TestCase
public function testNestedArraysException() public function testNestedArraysException()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "int".'); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "int".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'float[][][][]'); $this->resolver->setAllowedTypes('foo', 'float[][][][]');
@ -1939,7 +1939,7 @@ class OptionsResolverTest extends TestCase
public function testNestedArrayException1() public function testNestedArrayException1()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "bool|string|array".'); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "bool|string|array".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][]'); $this->resolver->setAllowedTypes('foo', 'int[][]');
@ -1952,7 +1952,7 @@ class OptionsResolverTest extends TestCase
public function testNestedArrayException2() public function testNestedArrayException2()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "bool|string|array".'); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "bool|string|array".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][]'); $this->resolver->setAllowedTypes('foo', 'int[][]');
@ -1965,7 +1965,7 @@ class OptionsResolverTest extends TestCase
public function testNestedArrayException3() public function testNestedArrayException3()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string|int".'); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string|int".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[][][]'); $this->resolver->setAllowedTypes('foo', 'string[][][]');
@ -1978,7 +1978,7 @@ class OptionsResolverTest extends TestCase
public function testNestedArrayException4() public function testNestedArrayException4()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "int".'); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "int".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[][][]'); $this->resolver->setAllowedTypes('foo', 'string[][][]');
@ -1992,7 +1992,7 @@ class OptionsResolverTest extends TestCase
public function testNestedArrayException5() public function testNestedArrayException5()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[]", but one of the elements is of type "array".'); $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[]", but one of the elements is of type "array".');
$this->resolver->setDefined('foo'); $this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[]'); $this->resolver->setAllowedTypes('foo', 'string[]');
@ -2016,7 +2016,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfUndefinedNestedOption() public function testFailsIfUndefinedNestedOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException'); $this->expectException(UndefinedOptionsException::class);
$this->expectExceptionMessage('The option "database[foo]" does not exist. Defined options are: "host", "port".'); $this->expectExceptionMessage('The option "database[foo]" does not exist. Defined options are: "host", "port".');
$this->resolver->setDefaults([ $this->resolver->setDefaults([
'name' => 'default', 'name' => 'default',
@ -2031,7 +2031,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfMissingRequiredNestedOption() public function testFailsIfMissingRequiredNestedOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class);
$this->expectExceptionMessage('The required option "database[host]" is missing.'); $this->expectExceptionMessage('The required option "database[host]" is missing.');
$this->resolver->setDefaults([ $this->resolver->setDefaults([
'name' => 'default', 'name' => 'default',
@ -2046,7 +2046,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfInvalidTypeNestedOption() public function testFailsIfInvalidTypeNestedOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The option "database[logging]" with value null is expected to be of type "bool", but is of type "null".'); $this->expectExceptionMessage('The option "database[logging]" with value null is expected to be of type "bool", but is of type "null".');
$this->resolver->setDefaults([ $this->resolver->setDefaults([
'name' => 'default', 'name' => 'default',
@ -2063,7 +2063,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfNotArrayIsGivenForNestedOptions() public function testFailsIfNotArrayIsGivenForNestedOptions()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); $this->expectException(InvalidOptionsException::class);
$this->expectExceptionMessage('The nested option "database" with value null is expected to be of type array, but is of type "null".'); $this->expectExceptionMessage('The nested option "database" with value null is expected to be of type array, but is of type "null".');
$this->resolver->setDefaults([ $this->resolver->setDefaults([
'name' => 'default', 'name' => 'default',
@ -2270,7 +2270,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfCyclicDependencyBetweenSameNestedOption() public function testFailsIfCyclicDependencyBetweenSameNestedOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
$this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) { $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) {
$resolver->setDefault('replicas', $parent['database']); $resolver->setDefault('replicas', $parent['database']);
}); });
@ -2279,7 +2279,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfCyclicDependencyBetweenNestedOptionAndParentLazyOption() public function testFailsIfCyclicDependencyBetweenNestedOptionAndParentLazyOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
$this->resolver->setDefaults([ $this->resolver->setDefaults([
'version' => function (Options $options) { 'version' => function (Options $options) {
return $options['database']['server_version']; return $options['database']['server_version'];
@ -2293,7 +2293,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfCyclicDependencyBetweenNormalizerAndNestedOption() public function testFailsIfCyclicDependencyBetweenNormalizerAndNestedOption()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
$this->resolver $this->resolver
->setDefault('name', 'default') ->setDefault('name', 'default')
->setDefault('database', function (OptionsResolver $resolver, Options $parent) { ->setDefault('database', function (OptionsResolver $resolver, Options $parent) {
@ -2307,7 +2307,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfCyclicDependencyBetweenNestedOptions() public function testFailsIfCyclicDependencyBetweenNestedOptions()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
$this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) { $this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) {
$resolver->setDefault('host', $parent['replica']['host']); $resolver->setDefault('host', $parent['replica']['host']);
}); });
@ -2400,7 +2400,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfOptionIsAlreadyDefined() public function testFailsIfOptionIsAlreadyDefined()
{ {
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException'); $this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
$this->expectExceptionMessage('The option "foo" is already defined.'); $this->expectExceptionMessage('The option "foo" is already defined.');
$this->resolver->define('foo'); $this->resolver->define('foo');
$this->resolver->define('foo'); $this->resolver->define('foo');

View File

@ -667,7 +667,7 @@ class PropertyAccessor implements PropertyAccessorInterface
*/ */
public static function createCache(string $namespace, int $defaultLifetime, string $version, LoggerInterface $logger = null) public static function createCache(string $namespace, int $defaultLifetime, string $version, LoggerInterface $logger = null)
{ {
if (!class_exists('Symfony\Component\Cache\Adapter\ApcuAdapter')) { if (!class_exists(ApcuAdapter::class)) {
throw new \LogicException(sprintf('The Symfony Cache component must be installed to use "%s()".', __METHOD__)); throw new \LogicException(sprintf('The Symfony Cache component must be installed to use "%s()".', __METHOD__));
} }

View File

@ -148,7 +148,7 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
public function testSetValueFailsIfNoAdderNorRemoverFound() public function testSetValueFailsIfNoAdderNorRemoverFound()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover_[^"]*"./'); $this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover_[^"]*"./');
$car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock(); $car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock();
$axesBefore = $this->getContainer([1 => 'second', 3 => 'fourth']); $axesBefore = $this->getContainer([1 => 'second', 3 => 'fourth']);
@ -187,7 +187,7 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable() public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->expectExceptionMessageMatches('/The property "axes" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\PropertyAccessorCollectionTest_Car" can be defined with the methods "addAxis\(\)", "removeAxis\(\)" but the new value must be an array or an instance of \\\Traversable\./'); $this->expectExceptionMessageMatches('/The property "axes" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\PropertyAccessorCollectionTest_Car" can be defined with the methods "addAxis\(\)", "removeAxis\(\)" but the new value must be an array or an instance of \\\Traversable\./');
$car = new PropertyAccessorCollectionTest_Car(); $car = new PropertyAccessorCollectionTest_Car();

View File

@ -102,7 +102,7 @@ class PropertyAccessorTest extends TestCase
*/ */
public function testGetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path) public function testGetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path)
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->propertyAccessor->getValue($objectOrArray, $path); $this->propertyAccessor->getValue($objectOrArray, $path);
} }
@ -129,7 +129,7 @@ class PropertyAccessorTest extends TestCase
*/ */
public function testGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnabled($objectOrArray, $path) public function testGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnabled($objectOrArray, $path)
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException'); $this->expectException(NoSuchIndexException::class);
$this->propertyAccessor = new PropertyAccessor(false, true); $this->propertyAccessor = new PropertyAccessor(false, true);
$this->propertyAccessor->getValue($objectOrArray, $path); $this->propertyAccessor->getValue($objectOrArray, $path);
} }
@ -158,7 +158,7 @@ class PropertyAccessorTest extends TestCase
*/ */
public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetterOfAnonymousClass() public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetterOfAnonymousClass()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\AccessException::class);
$this->expectExceptionMessage('The method "class@anonymous::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?'); $this->expectExceptionMessage('The method "class@anonymous::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?');
$object = eval('return new class() { $object = eval('return new class() {
@ -178,7 +178,7 @@ class PropertyAccessorTest extends TestCase
*/ */
public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetterOfAnonymousStdClass() public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetterOfAnonymousStdClass()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\AccessException::class);
$this->expectExceptionMessage('The method "stdClass@anonymous::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?'); $this->expectExceptionMessage('The method "stdClass@anonymous::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?');
$object = eval('return new class() extends \stdClass { $object = eval('return new class() extends \stdClass {
@ -198,7 +198,7 @@ class PropertyAccessorTest extends TestCase
*/ */
public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetterOfAnonymousChildClass() public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetterOfAnonymousChildClass()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\AccessException::class);
$this->expectExceptionMessage('The method "Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedPrivateProperty@anonymous::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?'); $this->expectExceptionMessage('The method "Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedPrivateProperty@anonymous::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?');
$object = eval('return new class() extends \Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedPrivateProperty {};'); $object = eval('return new class() extends \Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedPrivateProperty {};');
@ -208,7 +208,7 @@ class PropertyAccessorTest extends TestCase
public function testGetValueThrowsExceptionIfNotArrayAccess() public function testGetValueThrowsExceptionIfNotArrayAccess()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException'); $this->expectException(NoSuchIndexException::class);
$this->propertyAccessor->getValue(new \stdClass(), '[index]'); $this->propertyAccessor->getValue(new \stdClass(), '[index]');
} }
@ -257,7 +257,7 @@ class PropertyAccessorTest extends TestCase
public function testGetValueDoesNotReadMagicCallByDefault() public function testGetValueDoesNotReadMagicCallByDefault()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->propertyAccessor->getValue(new TestClassMagicCall('Bernhard'), 'magicCallProperty'); $this->propertyAccessor->getValue(new TestClassMagicCall('Bernhard'), 'magicCallProperty');
} }
@ -281,7 +281,7 @@ class PropertyAccessorTest extends TestCase
*/ */
public function testGetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path) public function testGetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path)
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException::class);
$this->expectExceptionMessage('PropertyAccessor requires a graph of objects or arrays to operate on'); $this->expectExceptionMessage('PropertyAccessor requires a graph of objects or arrays to operate on');
$this->propertyAccessor->getValue($objectOrArray, $path); $this->propertyAccessor->getValue($objectOrArray, $path);
} }
@ -301,7 +301,7 @@ class PropertyAccessorTest extends TestCase
*/ */
public function testSetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path) public function testSetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path)
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->propertyAccessor->setValue($objectOrArray, $path, 'Updated'); $this->propertyAccessor->setValue($objectOrArray, $path, 'Updated');
} }
@ -328,7 +328,7 @@ class PropertyAccessorTest extends TestCase
public function testSetValueThrowsExceptionIfNotArrayAccess() public function testSetValueThrowsExceptionIfNotArrayAccess()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException'); $this->expectException(NoSuchIndexException::class);
$object = new \stdClass(); $object = new \stdClass();
$this->propertyAccessor->setValue($object, '[index]', 'Updated'); $this->propertyAccessor->setValue($object, '[index]', 'Updated');
@ -345,7 +345,7 @@ class PropertyAccessorTest extends TestCase
public function testSetValueThrowsExceptionIfThereAreMissingParameters() public function testSetValueThrowsExceptionIfThereAreMissingParameters()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$object = new TestClass('Bernhard'); $object = new TestClass('Bernhard');
$this->propertyAccessor->setValue($object, 'publicAccessorWithMoreRequiredParameters', 'Updated'); $this->propertyAccessor->setValue($object, 'publicAccessorWithMoreRequiredParameters', 'Updated');
@ -353,7 +353,7 @@ class PropertyAccessorTest extends TestCase
public function testSetValueDoesNotUpdateMagicCallByDefault() public function testSetValueDoesNotUpdateMagicCallByDefault()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$author = new TestClassMagicCall('Bernhard'); $author = new TestClassMagicCall('Bernhard');
$this->propertyAccessor->setValue($author, 'magicCallProperty', 'Updated'); $this->propertyAccessor->setValue($author, 'magicCallProperty', 'Updated');
@ -375,7 +375,7 @@ class PropertyAccessorTest extends TestCase
*/ */
public function testSetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path) public function testSetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path)
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException::class);
$this->expectExceptionMessage('PropertyAccessor requires a graph of objects or arrays to operate on'); $this->expectExceptionMessage('PropertyAccessor requires a graph of objects or arrays to operate on');
$this->propertyAccessor->setValue($objectOrArray, $path, 'value'); $this->propertyAccessor->setValue($objectOrArray, $path, 'value');
} }
@ -611,7 +611,7 @@ class PropertyAccessorTest extends TestCase
public function testThrowTypeError() public function testThrowTypeError()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Expected argument of type "DateTime", "string" given at property path "date"'); $this->expectExceptionMessage('Expected argument of type "DateTime", "string" given at property path "date"');
$object = new TypeHinted(); $object = new TypeHinted();
@ -620,7 +620,7 @@ class PropertyAccessorTest extends TestCase
public function testThrowTypeErrorWithNullArgument() public function testThrowTypeErrorWithNullArgument()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Expected argument of type "DateTime", "null" given'); $this->expectExceptionMessage('Expected argument of type "DateTime", "null" given');
$object = new TypeHinted(); $object = new TypeHinted();
@ -672,7 +672,7 @@ class PropertyAccessorTest extends TestCase
public function testThrowTypeErrorWithInterface() public function testThrowTypeErrorWithInterface()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Expected argument of type "Countable", "string" given'); $this->expectExceptionMessage('Expected argument of type "Countable", "string" given');
$object = new TypeHinted(); $object = new TypeHinted();
@ -692,7 +692,7 @@ class PropertyAccessorTest extends TestCase
public function testAnonymousClassReadThrowExceptionOnInvalidPropertyPath() public function testAnonymousClassReadThrowExceptionOnInvalidPropertyPath()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$obj = $this->generateAnonymousClass('bar'); $obj = $this->generateAnonymousClass('bar');
$this->propertyAccessor->getValue($obj, 'invalid_property'); $this->propertyAccessor->getValue($obj, 'invalid_property');
@ -752,7 +752,7 @@ class PropertyAccessorTest extends TestCase
public function testThrowTypeErrorInsideSetterCall() public function testThrowTypeErrorInsideSetterCall()
{ {
$this->expectException('TypeError'); $this->expectException(\TypeError::class);
$object = new TestClassTypeErrorInsideCall(); $object = new TestClassTypeErrorInsideCall();
$this->propertyAccessor->setValue($object, 'property', 'foo'); $this->propertyAccessor->setValue($object, 'property', 'foo');
@ -760,7 +760,7 @@ class PropertyAccessorTest extends TestCase
public function testDoNotDiscardReturnTypeError() public function testDoNotDiscardReturnTypeError()
{ {
$this->expectException('TypeError'); $this->expectException(\TypeError::class);
$object = new ReturnTyped(); $object = new ReturnTyped();
$this->propertyAccessor->setValue($object, 'foos', [new \DateTime()]); $this->propertyAccessor->setValue($object, 'foos', [new \DateTime()]);
@ -768,7 +768,7 @@ class PropertyAccessorTest extends TestCase
public function testDoNotDiscardReturnTypeErrorWhenWriterMethodIsMisconfigured() public function testDoNotDiscardReturnTypeErrorWhenWriterMethodIsMisconfigured()
{ {
$this->expectException('TypeError'); $this->expectException(\TypeError::class);
$object = new ReturnTyped(); $object = new ReturnTyped();
$this->propertyAccessor->setValue($object, 'name', 'foo'); $this->propertyAccessor->setValue($object, 'name', 'foo');
@ -818,7 +818,7 @@ class PropertyAccessorTest extends TestCase
public function testAdderWithoutRemover() public function testAdderWithoutRemover()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->expectExceptionMessageMatches('/.*The add method "addFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidMethods" was found, but the corresponding remove method "removeFoo" was not found\./'); $this->expectExceptionMessageMatches('/.*The add method "addFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidMethods" was found, but the corresponding remove method "removeFoo" was not found\./');
$object = new TestAdderRemoverInvalidMethods(); $object = new TestAdderRemoverInvalidMethods();
$this->propertyAccessor->setValue($object, 'foos', [1, 2]); $this->propertyAccessor->setValue($object, 'foos', [1, 2]);
@ -826,7 +826,7 @@ class PropertyAccessorTest extends TestCase
public function testRemoverWithoutAdder() public function testRemoverWithoutAdder()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->expectExceptionMessageMatches('/.*The remove method "removeBar" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidMethods" was found, but the corresponding add method "addBar" was not found\./'); $this->expectExceptionMessageMatches('/.*The remove method "removeBar" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidMethods" was found, but the corresponding add method "addBar" was not found\./');
$object = new TestAdderRemoverInvalidMethods(); $object = new TestAdderRemoverInvalidMethods();
$this->propertyAccessor->setValue($object, 'bars', [1, 2]); $this->propertyAccessor->setValue($object, 'bars', [1, 2]);
@ -834,7 +834,7 @@ class PropertyAccessorTest extends TestCase
public function testAdderAndRemoveNeedsTheExactParametersDefined() public function testAdderAndRemoveNeedsTheExactParametersDefined()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->expectExceptionMessageMatches('/.*The method "addFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 0 arguments, but should accept only 1\./'); $this->expectExceptionMessageMatches('/.*The method "addFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 0 arguments, but should accept only 1\./');
$object = new TestAdderRemoverInvalidArgumentLength(); $object = new TestAdderRemoverInvalidArgumentLength();
$this->propertyAccessor->setValue($object, 'foo', [1, 2]); $this->propertyAccessor->setValue($object, 'foo', [1, 2]);
@ -842,7 +842,7 @@ class PropertyAccessorTest extends TestCase
public function testSetterNeedsTheExactParametersDefined() public function testSetterNeedsTheExactParametersDefined()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->expectExceptionMessageMatches('/.*The method "setBar" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 2 arguments, but should accept only 1\./'); $this->expectExceptionMessageMatches('/.*The method "setBar" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 2 arguments, but should accept only 1\./');
$object = new TestAdderRemoverInvalidArgumentLength(); $object = new TestAdderRemoverInvalidArgumentLength();
$this->propertyAccessor->setValue($object, 'bar', [1, 2]); $this->propertyAccessor->setValue($object, 'bar', [1, 2]);
@ -850,7 +850,7 @@ class PropertyAccessorTest extends TestCase
public function testSetterNeedsPublicAccess() public function testSetterNeedsPublicAccess()
{ {
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); $this->expectException(\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException::class);
$this->expectExceptionMessageMatches('/.*The method "setFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestClassSetValue" was found but does not have public access./'); $this->expectExceptionMessageMatches('/.*The method "setFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestClassSetValue" was found but does not have public access./');
$object = new TestClassSetValue(0); $object = new TestClassSetValue(0);
$this->propertyAccessor->setValue($object, 'foo', 1); $this->propertyAccessor->setValue($object, 'foo', 1);

View File

@ -26,7 +26,7 @@ class RouterTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $this->loader = $this->getMockBuilder(\Symfony\Component\Config\Loader\LoaderInterface::class)->getMock();
$this->router = new Router($this->loader, 'routing.yml'); $this->router = new Router($this->loader, 'routing.yml');
$this->cacheDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('router_', true); $this->cacheDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('router_', true);
@ -59,7 +59,7 @@ class RouterTest extends TestCase
public function testSetOptionsWithUnsupportedOptions() public function testSetOptionsWithUnsupportedOptions()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The Router does not support the following options: "option_foo", "option_bar"'); $this->expectExceptionMessage('The Router does not support the following options: "option_foo", "option_bar"');
$this->router->setOptions([ $this->router->setOptions([
'cache_dir' => './cache', 'cache_dir' => './cache',
@ -78,14 +78,14 @@ class RouterTest extends TestCase
public function testSetOptionWithUnsupportedOption() public function testSetOptionWithUnsupportedOption()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The Router does not support the "option_foo" option'); $this->expectExceptionMessage('The Router does not support the "option_foo" option');
$this->router->setOption('option_foo', true); $this->router->setOption('option_foo', true);
} }
public function testGetOptionWithUnsupportedOption() public function testGetOptionWithUnsupportedOption()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The Router does not support the "option_foo" option'); $this->expectExceptionMessage('The Router does not support the "option_foo" option');
$this->router->getOption('option_foo', true); $this->router->getOption('option_foo', true);
} }
@ -111,7 +111,7 @@ class RouterTest extends TestCase
->method('load')->with('routing.yml', null) ->method('load')->with('routing.yml', null)
->willReturn(new RouteCollection()); ->willReturn(new RouteCollection());
$this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher()); $this->assertInstanceOf(\Symfony\Component\Routing\Matcher\UrlMatcher::class, $this->router->getMatcher());
} }
public function testGeneratorIsCreatedIfCacheIsNotConfigured() public function testGeneratorIsCreatedIfCacheIsNotConfigured()
@ -122,12 +122,12 @@ class RouterTest extends TestCase
->method('load')->with('routing.yml', null) ->method('load')->with('routing.yml', null)
->willReturn(new RouteCollection()); ->willReturn(new RouteCollection());
$this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator()); $this->assertInstanceOf(\Symfony\Component\Routing\Generator\UrlGenerator::class, $this->router->getGenerator());
} }
public function testMatchRequestWithUrlMatcherInterface() public function testMatchRequestWithUrlMatcherInterface()
{ {
$matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); $matcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\UrlMatcherInterface::class)->getMock();
$matcher->expects($this->once())->method('match'); $matcher->expects($this->once())->method('match');
$p = new \ReflectionProperty($this->router, 'matcher'); $p = new \ReflectionProperty($this->router, 'matcher');
@ -139,7 +139,7 @@ class RouterTest extends TestCase
public function testMatchRequestWithRequestMatcherInterface() public function testMatchRequestWithRequestMatcherInterface()
{ {
$matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $matcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock();
$matcher->expects($this->once())->method('matchRequest'); $matcher->expects($this->once())->method('matchRequest');
$p = new \ReflectionProperty($this->router, 'matcher'); $p = new \ReflectionProperty($this->router, 'matcher');
@ -161,7 +161,7 @@ class RouterTest extends TestCase
$generator = $router->getGenerator(); $generator = $router->getGenerator();
$this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGeneratorInterface', $generator); $this->assertInstanceOf(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class, $generator);
$p = new \ReflectionProperty($generator, 'defaultLocale'); $p = new \ReflectionProperty($generator, 'defaultLocale');
$p->setAccessible(true); $p->setAccessible(true);
@ -181,7 +181,7 @@ class RouterTest extends TestCase
$generator = $router->getGenerator(); $generator = $router->getGenerator();
$this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGeneratorInterface', $generator); $this->assertInstanceOf(\Symfony\Component\Routing\Generator\UrlGeneratorInterface::class, $generator);
$p = new \ReflectionProperty($generator, 'defaultLocale'); $p = new \ReflectionProperty($generator, 'defaultLocale');
$p->setAccessible(true); $p->setAccessible(true);

View File

@ -25,7 +25,7 @@ class DaoAuthenticationProviderTest extends TestCase
{ {
public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface() public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException'); $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationServiceException::class);
$provider = $this->getProvider('fabien'); $provider = $this->getProvider('fabien');
$method = new \ReflectionMethod($provider, 'retrieveUser'); $method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true); $method->setAccessible(true);
@ -35,14 +35,14 @@ class DaoAuthenticationProviderTest extends TestCase
public function testRetrieveUserWhenUsernameIsNotFound() public function testRetrieveUserWhenUsernameIsNotFound()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); $this->expectException(UsernameNotFoundException::class);
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
$userProvider->expects($this->once()) $userProvider->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->willThrowException(new UsernameNotFoundException()) ->willThrowException(new UsernameNotFoundException())
; ;
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(), 'key', $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock());
$method = new \ReflectionMethod($provider, 'retrieveUser'); $method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true); $method->setAccessible(true);
@ -51,14 +51,14 @@ class DaoAuthenticationProviderTest extends TestCase
public function testRetrieveUserWhenAnExceptionOccurs() public function testRetrieveUserWhenAnExceptionOccurs()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException'); $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationServiceException::class);
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
$userProvider->expects($this->once()) $userProvider->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->willThrowException(new \RuntimeException()) ->willThrowException(new \RuntimeException())
; ;
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(), 'key', $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock());
$method = new \ReflectionMethod($provider, 'retrieveUser'); $method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true); $method->setAccessible(true);
@ -67,7 +67,7 @@ class DaoAuthenticationProviderTest extends TestCase
public function testRetrieveUserReturnsUserFromTokenOnReauthentication() public function testRetrieveUserReturnsUserFromTokenOnReauthentication()
{ {
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
$userProvider->expects($this->never()) $userProvider->expects($this->never())
->method('loadUserByUsername') ->method('loadUserByUsername')
; ;
@ -79,7 +79,7 @@ class DaoAuthenticationProviderTest extends TestCase
->willReturn($user) ->willReturn($user)
; ;
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(), 'key', $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock());
$reflection = new \ReflectionMethod($provider, 'retrieveUser'); $reflection = new \ReflectionMethod($provider, 'retrieveUser');
$reflection->setAccessible(true); $reflection->setAccessible(true);
$result = $reflection->invoke($provider, 'someUser', $token); $result = $reflection->invoke($provider, 'someUser', $token);
@ -91,13 +91,13 @@ class DaoAuthenticationProviderTest extends TestCase
{ {
$user = new TestUser(); $user = new TestUser();
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
$userProvider->expects($this->once()) $userProvider->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->willReturn($user) ->willReturn($user)
; ;
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock(), 'key', $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock());
$method = new \ReflectionMethod($provider, 'retrieveUser'); $method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true); $method->setAccessible(true);
@ -106,8 +106,8 @@ class DaoAuthenticationProviderTest extends TestCase
public function testCheckAuthenticationWhenCredentialsAreEmpty() public function testCheckAuthenticationWhenCredentialsAreEmpty()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock();
$encoder $encoder
->expects($this->never()) ->expects($this->never())
->method('isPasswordValid') ->method('isPasswordValid')
@ -129,7 +129,7 @@ class DaoAuthenticationProviderTest extends TestCase
public function testCheckAuthenticationWhenCredentialsAre0() public function testCheckAuthenticationWhenCredentialsAre0()
{ {
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock();
$encoder $encoder
->expects($this->once()) ->expects($this->once())
->method('isPasswordValid') ->method('isPasswordValid')
@ -156,8 +156,8 @@ class DaoAuthenticationProviderTest extends TestCase
public function testCheckAuthenticationWhenCredentialsAreNotValid() public function testCheckAuthenticationWhenCredentialsAreNotValid()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock();
$encoder->expects($this->once()) $encoder->expects($this->once())
->method('isPasswordValid') ->method('isPasswordValid')
->willReturn(false) ->willReturn(false)
@ -178,8 +178,8 @@ class DaoAuthenticationProviderTest extends TestCase
public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged() public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); $this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
$user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $user = $this->getMockBuilder(UserInterface::class)->getMock();
$user->expects($this->once()) $user->expects($this->once())
->method('getPassword') ->method('getPassword')
->willReturn('foo') ->willReturn('foo')
@ -190,7 +190,7 @@ class DaoAuthenticationProviderTest extends TestCase
->method('getUser') ->method('getUser')
->willReturn($user); ->willReturn($user);
$dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $dbUser = $this->getMockBuilder(UserInterface::class)->getMock();
$dbUser->expects($this->once()) $dbUser->expects($this->once())
->method('getPassword') ->method('getPassword')
->willReturn('newFoo') ->willReturn('newFoo')
@ -204,7 +204,7 @@ class DaoAuthenticationProviderTest extends TestCase
public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithoutOriginalCredentials() public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithoutOriginalCredentials()
{ {
$user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $user = $this->getMockBuilder(UserInterface::class)->getMock();
$user->expects($this->once()) $user->expects($this->once())
->method('getPassword') ->method('getPassword')
->willReturn('foo') ->willReturn('foo')
@ -215,7 +215,7 @@ class DaoAuthenticationProviderTest extends TestCase
->method('getUser') ->method('getUser')
->willReturn($user); ->willReturn($user);
$dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $dbUser = $this->getMockBuilder(UserInterface::class)->getMock();
$dbUser->expects($this->once()) $dbUser->expects($this->once())
->method('getPassword') ->method('getPassword')
->willReturn('foo') ->willReturn('foo')
@ -229,7 +229,7 @@ class DaoAuthenticationProviderTest extends TestCase
public function testCheckAuthentication() public function testCheckAuthentication()
{ {
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock();
$encoder->expects($this->once()) $encoder->expects($this->once())
->method('isPasswordValid') ->method('isPasswordValid')
->willReturn(true) ->willReturn(true)
@ -288,7 +288,7 @@ class DaoAuthenticationProviderTest extends TestCase
protected function getSupportedToken() protected function getSupportedToken()
{ {
$mock = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken')->setMethods(['getCredentials', 'getUser', 'getProviderKey'])->disableOriginalConstructor()->getMock(); $mock = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::class)->setMethods(['getCredentials', 'getUser', 'getProviderKey'])->disableOriginalConstructor()->getMock();
$mock $mock
->expects($this->any()) ->expects($this->any())
->method('getProviderKey') ->method('getProviderKey')
@ -309,14 +309,14 @@ class DaoAuthenticationProviderTest extends TestCase
} }
if (null === $userChecker) { if (null === $userChecker) {
$userChecker = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock();
} }
if (null === $passwordEncoder) { if (null === $passwordEncoder) {
$passwordEncoder = new PlaintextPasswordEncoder(); $passwordEncoder = new PlaintextPasswordEncoder();
} }
$encoderFactory = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock(); $encoderFactory = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface::class)->getMock();
$encoderFactory $encoderFactory
->expects($this->any()) ->expects($this->any())
->method('getEncoder') ->method('getEncoder')

View File

@ -25,21 +25,21 @@ class UserAuthenticationProviderTest extends TestCase
$provider = $this->getProvider(); $provider = $this->getProvider();
$this->assertTrue($provider->supports($this->getSupportedToken())); $this->assertTrue($provider->supports($this->getSupportedToken()));
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); $this->assertFalse($provider->supports($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()));
} }
public function testAuthenticateWhenTokenIsNotSupported() public function testAuthenticateWhenTokenIsNotSupported()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException'); $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
$this->expectExceptionMessage('The token is not supported by this authentication provider.'); $this->expectExceptionMessage('The token is not supported by this authentication provider.');
$provider = $this->getProvider(); $provider = $this->getProvider();
$provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $provider->authenticate($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock());
} }
public function testAuthenticateWhenUsernameIsNotFound() public function testAuthenticateWhenUsernameIsNotFound()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException'); $this->expectException(UsernameNotFoundException::class);
$provider = $this->getProvider(false, false); $provider = $this->getProvider(false, false);
$provider->expects($this->once()) $provider->expects($this->once())
->method('retrieveUser') ->method('retrieveUser')
@ -51,7 +51,7 @@ class UserAuthenticationProviderTest extends TestCase
public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue() public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); $this->expectException(BadCredentialsException::class);
$provider = $this->getProvider(false, true); $provider = $this->getProvider(false, true);
$provider->expects($this->once()) $provider->expects($this->once())
->method('retrieveUser') ->method('retrieveUser')
@ -63,7 +63,7 @@ class UserAuthenticationProviderTest extends TestCase
public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface() public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException'); $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationServiceException::class);
$provider = $this->getProvider(false, true); $provider = $this->getProvider(false, true);
$provider->expects($this->once()) $provider->expects($this->once())
->method('retrieveUser') ->method('retrieveUser')
@ -75,8 +75,8 @@ class UserAuthenticationProviderTest extends TestCase
public function testAuthenticateWhenPreChecksFails() public function testAuthenticateWhenPreChecksFails()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\CredentialsExpiredException'); $this->expectException(CredentialsExpiredException::class);
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock();
$userChecker->expects($this->once()) $userChecker->expects($this->once())
->method('checkPreAuth') ->method('checkPreAuth')
->willThrowException(new CredentialsExpiredException()) ->willThrowException(new CredentialsExpiredException())
@ -85,7 +85,7 @@ class UserAuthenticationProviderTest extends TestCase
$provider = $this->getProvider($userChecker); $provider = $this->getProvider($userChecker);
$provider->expects($this->once()) $provider->expects($this->once())
->method('retrieveUser') ->method('retrieveUser')
->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock())
; ;
$provider->authenticate($this->getSupportedToken()); $provider->authenticate($this->getSupportedToken());
@ -93,8 +93,8 @@ class UserAuthenticationProviderTest extends TestCase
public function testAuthenticateWhenPostChecksFails() public function testAuthenticateWhenPostChecksFails()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AccountExpiredException'); $this->expectException(AccountExpiredException::class);
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock();
$userChecker->expects($this->once()) $userChecker->expects($this->once())
->method('checkPostAuth') ->method('checkPostAuth')
->willThrowException(new AccountExpiredException()) ->willThrowException(new AccountExpiredException())
@ -103,7 +103,7 @@ class UserAuthenticationProviderTest extends TestCase
$provider = $this->getProvider($userChecker); $provider = $this->getProvider($userChecker);
$provider->expects($this->once()) $provider->expects($this->once())
->method('retrieveUser') ->method('retrieveUser')
->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock())
; ;
$provider->authenticate($this->getSupportedToken()); $provider->authenticate($this->getSupportedToken());
@ -111,12 +111,12 @@ class UserAuthenticationProviderTest extends TestCase
public function testAuthenticateWhenPostCheckAuthenticationFails() public function testAuthenticateWhenPostCheckAuthenticationFails()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); $this->expectException(BadCredentialsException::class);
$this->expectExceptionMessage('Bad credentials'); $this->expectExceptionMessage('Bad credentials');
$provider = $this->getProvider(); $provider = $this->getProvider();
$provider->expects($this->once()) $provider->expects($this->once())
->method('retrieveUser') ->method('retrieveUser')
->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock())
; ;
$provider->expects($this->once()) $provider->expects($this->once())
->method('checkAuthentication') ->method('checkAuthentication')
@ -128,12 +128,12 @@ class UserAuthenticationProviderTest extends TestCase
public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse() public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException'); $this->expectException(BadCredentialsException::class);
$this->expectExceptionMessage('Foo'); $this->expectExceptionMessage('Foo');
$provider = $this->getProvider(false, false); $provider = $this->getProvider(false, false);
$provider->expects($this->once()) $provider->expects($this->once())
->method('retrieveUser') ->method('retrieveUser')
->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ->willReturn($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock())
; ;
$provider->expects($this->once()) $provider->expects($this->once())
->method('checkAuthentication') ->method('checkAuthentication')
@ -145,7 +145,7 @@ class UserAuthenticationProviderTest extends TestCase
public function testAuthenticate() public function testAuthenticate()
{ {
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock();
$user->expects($this->once()) $user->expects($this->once())
->method('getRoles') ->method('getRoles')
->willReturn(['ROLE_FOO']) ->willReturn(['ROLE_FOO'])
@ -165,7 +165,7 @@ class UserAuthenticationProviderTest extends TestCase
$authToken = $provider->authenticate($token); $authToken = $provider->authenticate($token);
$this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $authToken); $this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::class, $authToken);
$this->assertSame($user, $authToken->getUser()); $this->assertSame($user, $authToken->getUser());
$this->assertEquals(['ROLE_FOO'], $authToken->getRoleNames()); $this->assertEquals(['ROLE_FOO'], $authToken->getRoleNames());
$this->assertEquals('foo', $authToken->getCredentials()); $this->assertEquals('foo', $authToken->getCredentials());
@ -174,7 +174,7 @@ class UserAuthenticationProviderTest extends TestCase
public function testAuthenticatePreservesOriginalToken() public function testAuthenticatePreservesOriginalToken()
{ {
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock();
$user->expects($this->once()) $user->expects($this->once())
->method('getRoles') ->method('getRoles')
->willReturn(['ROLE_FOO']) ->willReturn(['ROLE_FOO'])
@ -186,8 +186,8 @@ class UserAuthenticationProviderTest extends TestCase
->willReturn($user) ->willReturn($user)
; ;
$originalToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $originalToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$token = new SwitchUserToken($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(), 'foo', 'key', [], $originalToken); $token = new SwitchUserToken($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock(), 'foo', 'key', [], $originalToken);
$token->setAttributes(['foo' => 'bar']); $token->setAttributes(['foo' => 'bar']);
$authToken = $provider->authenticate($token); $authToken = $provider->authenticate($token);
@ -202,7 +202,7 @@ class UserAuthenticationProviderTest extends TestCase
protected function getSupportedToken() protected function getSupportedToken()
{ {
$mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken')->setMethods(['getCredentials', 'getProviderKey', 'getRoles'])->disableOriginalConstructor()->getMock(); $mock = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::class)->setMethods(['getCredentials', 'getProviderKey', 'getRoles'])->disableOriginalConstructor()->getMock();
$mock $mock
->expects($this->any()) ->expects($this->any())
->method('getProviderKey') ->method('getProviderKey')
@ -217,9 +217,9 @@ class UserAuthenticationProviderTest extends TestCase
protected function getProvider($userChecker = false, $hide = true) protected function getProvider($userChecker = false, $hide = true)
{ {
if (false === $userChecker) { if (false === $userChecker) {
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock();
} }
return $this->getMockForAbstractClass('Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider', [$userChecker, 'key', $hide]); return $this->getMockForAbstractClass(\Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider::class, [$userChecker, 'key', $hide]);
} }
} }

View File

@ -26,7 +26,7 @@ class AbstractTokenTest extends TestCase
$token->setUser(new TestUser('fabien')); $token->setUser(new TestUser('fabien'));
$this->assertEquals('fabien', $token->getUsername()); $this->assertEquals('fabien', $token->getUsername());
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user = $this->getMockBuilder(UserInterface::class)->getMock();
$user->expects($this->once())->method('getUsername')->willReturn('fabien'); $user->expects($this->once())->method('getUsername')->willReturn('fabien');
$token->setUser($user); $token->setUser($user);
$this->assertEquals('fabien', $token->getUsername()); $this->assertEquals('fabien', $token->getUsername());
@ -36,7 +36,7 @@ class AbstractTokenTest extends TestCase
{ {
$token = new ConcreteToken(['ROLE_FOO']); $token = new ConcreteToken(['ROLE_FOO']);
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user = $this->getMockBuilder(UserInterface::class)->getMock();
$user->expects($this->once())->method('eraseCredentials'); $user->expects($this->once())->method('eraseCredentials');
$token->setUser($user); $token->setUser($user);
@ -106,7 +106,7 @@ class AbstractTokenTest extends TestCase
public function getUsers() public function getUsers()
{ {
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user = $this->getMockBuilder(UserInterface::class)->getMock();
return [ return [
[$user], [$user],
@ -133,7 +133,7 @@ class AbstractTokenTest extends TestCase
public function getUserChanges() public function getUserChanges()
{ {
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user = $this->getMockBuilder(UserInterface::class)->getMock();
return [ return [
['foo', 'bar'], ['foo', 'bar'],

View File

@ -19,7 +19,7 @@ class AccessDecisionManagerTest extends TestCase
{ {
public function testSetUnsupportedStrategy() public function testSetUnsupportedStrategy()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
new AccessDecisionManager([$this->getVoter(VoterInterface::ACCESS_GRANTED)], 'fooBar'); new AccessDecisionManager([$this->getVoter(VoterInterface::ACCESS_GRANTED)], 'fooBar');
} }
@ -28,7 +28,7 @@ class AccessDecisionManagerTest extends TestCase
*/ */
public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions, $expected) public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions, $expected)
{ {
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$manager = new AccessDecisionManager($voters, $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions); $manager = new AccessDecisionManager($voters, $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions);
$this->assertSame($expected, $manager->decide($token, ['ROLE_FOO'])); $this->assertSame($expected, $manager->decide($token, ['ROLE_FOO']));
@ -112,7 +112,7 @@ class AccessDecisionManagerTest extends TestCase
protected function getVoter($vote) protected function getVoter($vote)
{ {
$voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock(); $voter = $this->getMockBuilder(VoterInterface::class)->getMock();
$voter->expects($this->any()) $voter->expects($this->any())
->method('vote') ->method('vote')
->willReturn($vote); ->willReturn($vote);

View File

@ -64,13 +64,13 @@ class AuthenticatedVoterTest extends TestCase
protected function getToken($authenticated) protected function getToken($authenticated)
{ {
if ('fully' === $authenticated) { if ('fully' === $authenticated) {
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
} elseif ('remembered' === $authenticated) { } elseif ('remembered' === $authenticated) {
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock(); return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::class)->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock();
} elseif ('impersonated' === $authenticated) { } elseif ('impersonated' === $authenticated) {
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken')->disableOriginalConstructor()->getMock(); return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken::class)->disableOriginalConstructor()->getMock();
} else { } else {
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(['', ''])->getMock(); return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\AnonymousToken::class)->setConstructorArgs(['', ''])->getMock();
} }
} }
} }

View File

@ -57,7 +57,7 @@ class ExpressionVoterTest extends TestCase
protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = true) protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = true)
{ {
$mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\ExpressionLanguage')->getMock(); $mock = $this->getMockBuilder(\Symfony\Component\Security\Core\Authorization\ExpressionLanguage::class)->getMock();
if ($expressionLanguageExpectsEvaluate) { if ($expressionLanguageExpectsEvaluate) {
$mock->expects($this->once()) $mock->expects($this->once())
@ -70,7 +70,7 @@ class ExpressionVoterTest extends TestCase
protected function createTrustResolver() protected function createTrustResolver()
{ {
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(); return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface::class)->getMock();
} }
protected function createAuthorizationChecker() protected function createAuthorizationChecker()
@ -80,7 +80,7 @@ class ExpressionVoterTest extends TestCase
protected function createExpression() protected function createExpression()
{ {
return $this->getMockBuilder('Symfony\Component\ExpressionLanguage\Expression') return $this->getMockBuilder(\Symfony\Component\ExpressionLanguage\Expression::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
} }

View File

@ -65,7 +65,7 @@ class VoterTest extends TestCase
public function testVoteWithTypeError() public function testVoteWithTypeError()
{ {
$this->expectException('TypeError'); $this->expectException(\TypeError::class);
$this->expectExceptionMessage('Should error'); $this->expectExceptionMessage('Should error');
$voter = new TypeErrorVoterTest_Voter(); $voter = new TypeErrorVoterTest_Voter();
$voter->vote($this->token, new \stdClass(), ['EDIT']); $voter->vote($this->token, new \stdClass(), ['EDIT']);

View File

@ -21,7 +21,7 @@ class UserCheckerTest extends TestCase
{ {
$checker = new UserChecker(); $checker = new UserChecker();
$this->assertNull($checker->checkPostAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())); $this->assertNull($checker->checkPostAuth($this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock()));
} }
public function testCheckPostAuthPass() public function testCheckPostAuthPass()
@ -32,28 +32,28 @@ class UserCheckerTest extends TestCase
public function testCheckPostAuthCredentialsExpired() public function testCheckPostAuthCredentialsExpired()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\CredentialsExpiredException'); $this->expectException(\Symfony\Component\Security\Core\Exception\CredentialsExpiredException::class);
$checker = new UserChecker(); $checker = new UserChecker();
$checker->checkPostAuth(new User('John', 'password', [], true, true, false, true)); $checker->checkPostAuth(new User('John', 'password', [], true, true, false, true));
} }
public function testCheckPreAuthAccountLocked() public function testCheckPreAuthAccountLocked()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\LockedException'); $this->expectException(\Symfony\Component\Security\Core\Exception\LockedException::class);
$checker = new UserChecker(); $checker = new UserChecker();
$checker->checkPreAuth(new User('John', 'password', [], true, true, false, false)); $checker->checkPreAuth(new User('John', 'password', [], true, true, false, false));
} }
public function testCheckPreAuthDisabled() public function testCheckPreAuthDisabled()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\DisabledException'); $this->expectException(\Symfony\Component\Security\Core\Exception\DisabledException::class);
$checker = new UserChecker(); $checker = new UserChecker();
$checker->checkPreAuth(new User('John', 'password', [], false, true, false, true)); $checker->checkPreAuth(new User('John', 'password', [], false, true, false, true));
} }
public function testCheckPreAuthAccountExpired() public function testCheckPreAuthAccountExpired()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AccountExpiredException'); $this->expectException(\Symfony\Component\Security\Core\Exception\AccountExpiredException::class);
$checker = new UserChecker(); $checker = new UserChecker();
$checker->checkPreAuth(new User('John', 'password', [], true, false, true, true)); $checker->checkPreAuth(new User('John', 'password', [], true, false, true, true));
} }

View File

@ -42,7 +42,7 @@ class CsrfTokenManagerTest extends TestCase
$token = $manager->getToken('token_id'); $token = $manager->getToken('token_id');
$this->assertInstanceOf('Symfony\Component\Security\Csrf\CsrfToken', $token); $this->assertInstanceOf(CsrfToken::class, $token);
$this->assertSame('token_id', $token->getId()); $this->assertSame('token_id', $token->getId());
$this->assertSame('TOKEN', $token->getValue()); $this->assertSame('TOKEN', $token->getValue());
} }
@ -64,7 +64,7 @@ class CsrfTokenManagerTest extends TestCase
$token = $manager->getToken('token_id'); $token = $manager->getToken('token_id');
$this->assertInstanceOf('Symfony\Component\Security\Csrf\CsrfToken', $token); $this->assertInstanceOf(CsrfToken::class, $token);
$this->assertSame('token_id', $token->getId()); $this->assertSame('token_id', $token->getId());
$this->assertSame('TOKEN', $token->getValue()); $this->assertSame('TOKEN', $token->getValue());
} }
@ -87,7 +87,7 @@ class CsrfTokenManagerTest extends TestCase
$token = $manager->refreshToken('token_id'); $token = $manager->refreshToken('token_id');
$this->assertInstanceOf('Symfony\Component\Security\Csrf\CsrfToken', $token); $this->assertInstanceOf(CsrfToken::class, $token);
$this->assertSame('token_id', $token->getId()); $this->assertSame('token_id', $token->getId());
$this->assertSame('TOKEN', $token->getValue()); $this->assertSame('TOKEN', $token->getValue());
} }
@ -159,9 +159,9 @@ class CsrfTokenManagerTest extends TestCase
public function testNamespaced() public function testNamespaced()
{ {
$generator = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface')->getMock(); $generator = $this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface::class)->getMock();
$generator->expects($this->once())->method('generateToken')->willReturn('random'); $generator->expects($this->once())->method('generateToken')->willReturn('random');
$storage = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface')->getMock(); $storage = $this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface::class)->getMock();
$requestStack = new RequestStack(); $requestStack = new RequestStack();
$requestStack->push(new Request([], [], [], [], [], ['HTTPS' => 'on'])); $requestStack->push(new Request([], [], [], [], [], ['HTTPS' => 'on']));
@ -207,8 +207,8 @@ class CsrfTokenManagerTest extends TestCase
private function getGeneratorAndStorage(): array private function getGeneratorAndStorage(): array
{ {
return [ return [
$this->getMockBuilder('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface')->getMock(), $this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface::class)->getMock(),
$this->getMockBuilder('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface')->getMock(), $this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface::class)->getMock(),
]; ];
} }

View File

@ -121,12 +121,12 @@ class GuardAuthenticationProviderTest extends TestCase
public function testGuardWithNoLongerAuthenticatedTriggersLogout() public function testGuardWithNoLongerAuthenticatedTriggersLogout()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationExpiredException'); $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationExpiredException::class);
$providerKey = 'my_firewall_abc'; $providerKey = 'my_firewall_abc';
// create a token and mark it as NOT authenticated anymore // create a token and mark it as NOT authenticated anymore
// this mimics what would happen if a user "changed" between request // this mimics what would happen if a user "changed" between request
$mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock();
$token = new PostAuthenticationGuardToken($mockedUser, $providerKey, ['ROLE_USER']); $token = new PostAuthenticationGuardToken($mockedUser, $providerKey, ['ROLE_USER']);
$token->setAuthenticated(false); $token->setAuthenticated(false);
@ -140,7 +140,7 @@ class GuardAuthenticationProviderTest extends TestCase
$authenticatorB = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); $authenticatorB = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
$authenticators = [$authenticatorA, $authenticatorB]; $authenticators = [$authenticatorA, $authenticatorB];
$mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock();
$provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker); $provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker);
$token = new PreAuthenticationGuardToken($mockedUser, 'first_firewall_1'); $token = new PreAuthenticationGuardToken($mockedUser, 'first_firewall_1');
@ -154,12 +154,12 @@ class GuardAuthenticationProviderTest extends TestCase
public function testAuthenticateFailsOnNonOriginatingToken() public function testAuthenticateFailsOnNonOriginatingToken()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException'); $this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
$this->expectExceptionMessageMatches('/second_firewall_0/'); $this->expectExceptionMessageMatches('/second_firewall_0/');
$authenticatorA = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); $authenticatorA = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
$authenticators = [$authenticatorA]; $authenticators = [$authenticatorA];
$mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $mockedUser = $this->getMockBuilder(UserInterface::class)->getMock();
$provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker); $provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, 'first_firewall', $this->userChecker);
$token = new PreAuthenticationGuardToken($mockedUser, 'second_firewall_0'); $token = new PreAuthenticationGuardToken($mockedUser, 'second_firewall_0');
@ -168,9 +168,9 @@ class GuardAuthenticationProviderTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $this->userProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock();
$this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $this->userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock();
$this->preAuthenticationToken = $this->getMockBuilder('Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken') $this->preAuthenticationToken = $this->getMockBuilder(PreAuthenticationGuardToken::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
} }

View File

@ -67,7 +67,7 @@ class SessionStrategyListenerTest extends TestCase
private function configurePreviousSession() private function configurePreviousSession()
{ {
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock();
$session->expects($this->any()) $session->expects($this->any())
->method('getName') ->method('getName')
->willReturn('test_session_name'); ->willReturn('test_session_name');

View File

@ -247,9 +247,9 @@ class AccessListenerTest extends TestCase
$listener = new AccessListener( $listener = new AccessListener(
$tokenStorage, $tokenStorage,
$this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(), $this->getMockBuilder(AccessDecisionManagerInterface::class)->getMock(),
$accessMap, $accessMap,
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock(),
false false
); );
@ -270,9 +270,9 @@ class AccessListenerTest extends TestCase
$listener = new AccessListener( $listener = new AccessListener(
$tokenStorage, $tokenStorage,
$this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(), $this->getMockBuilder(AccessDecisionManagerInterface::class)->getMock(),
$accessMap, $accessMap,
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock(),
false false
); );
@ -297,9 +297,9 @@ class AccessListenerTest extends TestCase
$listener = new AccessListener( $listener = new AccessListener(
$tokenStorage, $tokenStorage,
$this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(), $this->getMockBuilder(AccessDecisionManagerInterface::class)->getMock(),
$accessMap, $accessMap,
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock(),
false false
); );

View File

@ -121,7 +121,7 @@ class LogoutListenerTest extends TestCase
public function testNoResponseSet() public function testNoResponseSet()
{ {
$this->expectException('RuntimeException'); $this->expectException(\RuntimeException::class);
[$listener, , $httpUtils, $options] = $this->getListener(); [$listener, , $httpUtils, $options] = $this->getListener();
@ -137,7 +137,7 @@ class LogoutListenerTest extends TestCase
public function testCsrfValidationFails() public function testCsrfValidationFails()
{ {
$this->expectException('Symfony\Component\Security\Core\Exception\LogoutException'); $this->expectException(\Symfony\Component\Security\Core\Exception\LogoutException::class);
$tokenManager = $this->getTokenManager(); $tokenManager = $this->getTokenManager();
[$listener, , $httpUtils, $options] = $this->getListener(null, $tokenManager); [$listener, , $httpUtils, $options] = $this->getListener(null, $tokenManager);
@ -194,12 +194,12 @@ class LogoutListenerTest extends TestCase
private function getTokenManager() private function getTokenManager()
{ {
return $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); return $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock();
} }
private function getTokenStorage() private function getTokenStorage()
{ {
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock();
} }
private function getGetResponseEvent() private function getGetResponseEvent()
@ -217,7 +217,7 @@ class LogoutListenerTest extends TestCase
private function getHttpUtils() private function getHttpUtils()
{ {
return $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils') return $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
} }
@ -247,6 +247,6 @@ class LogoutListenerTest extends TestCase
private function getToken() private function getToken()
{ {
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
} }
} }

View File

@ -33,9 +33,9 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
public function testHandleWhenUsernameLength($username, $ok) public function testHandleWhenUsernameLength($username, $ok)
{ {
$request = Request::create('/login_check', 'POST', ['_username' => $username]); $request = Request::create('/login_check', 'POST', ['_username' => $username]);
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock());
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils = $this->getMockBuilder(HttpUtils::class)->getMock();
$httpUtils $httpUtils
->expects($this->any()) ->expects($this->any())
->method('checkRequestPath') ->method('checkRequestPath')
@ -46,14 +46,14 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
->willReturn(new RedirectResponse('/hello')) ->willReturn(new RedirectResponse('/hello'))
; ;
$failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); $failureHandler = $this->getMockBuilder(\Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface::class)->getMock();
$failureHandler $failureHandler
->expects($ok ? $this->never() : $this->once()) ->expects($ok ? $this->never() : $this->once())
->method('onAuthenticationFailure') ->method('onAuthenticationFailure')
->willReturn(new Response()) ->willReturn(new Response())
; ;
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')->disableOriginalConstructor()->getMock(); $authenticationManager = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager::class)->disableOriginalConstructor()->getMock();
$authenticationManager $authenticationManager
->expects($ok ? $this->once() : $this->never()) ->expects($ok ? $this->once() : $this->never())
->method('authenticate') ->method('authenticate')
@ -61,9 +61,9 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
; ;
$listener = new UsernamePasswordFormAuthenticationListener( $listener = new UsernamePasswordFormAuthenticationListener(
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)->getMock(),
$authenticationManager, $authenticationManager,
$this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(), $this->getMockBuilder(\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface::class)->getMock(),
$httpUtils, $httpUtils,
'TheProviderKey', 'TheProviderKey',
new DefaultAuthenticationSuccessHandler($httpUtils), new DefaultAuthenticationSuccessHandler($httpUtils),
@ -86,18 +86,18 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
*/ */
public function testHandleNonStringUsernameWithArray($postOnly) public function testHandleNonStringUsernameWithArray($postOnly)
{ {
$this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class);
$this->expectExceptionMessage('The key "_username" must be a string, "array" given.'); $this->expectExceptionMessage('The key "_username" must be a string, "array" given.');
$request = Request::create('/login_check', 'POST', ['_username' => []]); $request = Request::create('/login_check', 'POST', ['_username' => []]);
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock());
$listener = new UsernamePasswordFormAuthenticationListener( $listener = new UsernamePasswordFormAuthenticationListener(
new TokenStorage(), new TokenStorage(),
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(),
new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE), new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE),
$httpUtils = new HttpUtils(), $httpUtils = new HttpUtils(),
'foo', 'foo',
new DefaultAuthenticationSuccessHandler($httpUtils), new DefaultAuthenticationSuccessHandler($httpUtils),
new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils), new DefaultAuthenticationFailureHandler($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $httpUtils),
['require_previous_session' => false, 'post_only' => $postOnly] ['require_previous_session' => false, 'post_only' => $postOnly]
); );
$event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
@ -109,18 +109,18 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
*/ */
public function testHandleNonStringUsernameWithInt($postOnly) public function testHandleNonStringUsernameWithInt($postOnly)
{ {
$this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class);
$this->expectExceptionMessage('The key "_username" must be a string, "int" given.'); $this->expectExceptionMessage('The key "_username" must be a string, "int" given.');
$request = Request::create('/login_check', 'POST', ['_username' => 42]); $request = Request::create('/login_check', 'POST', ['_username' => 42]);
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock());
$listener = new UsernamePasswordFormAuthenticationListener( $listener = new UsernamePasswordFormAuthenticationListener(
new TokenStorage(), new TokenStorage(),
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(),
new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE), new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE),
$httpUtils = new HttpUtils(), $httpUtils = new HttpUtils(),
'foo', 'foo',
new DefaultAuthenticationSuccessHandler($httpUtils), new DefaultAuthenticationSuccessHandler($httpUtils),
new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils), new DefaultAuthenticationFailureHandler($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $httpUtils),
['require_previous_session' => false, 'post_only' => $postOnly] ['require_previous_session' => false, 'post_only' => $postOnly]
); );
$event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
@ -132,18 +132,18 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
*/ */
public function testHandleNonStringUsernameWithObject($postOnly) public function testHandleNonStringUsernameWithObject($postOnly)
{ {
$this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class);
$this->expectExceptionMessage('The key "_username" must be a string, "stdClass" given.'); $this->expectExceptionMessage('The key "_username" must be a string, "stdClass" given.');
$request = Request::create('/login_check', 'POST', ['_username' => new \stdClass()]); $request = Request::create('/login_check', 'POST', ['_username' => new \stdClass()]);
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock());
$listener = new UsernamePasswordFormAuthenticationListener( $listener = new UsernamePasswordFormAuthenticationListener(
new TokenStorage(), new TokenStorage(),
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(),
new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE), new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE),
$httpUtils = new HttpUtils(), $httpUtils = new HttpUtils(),
'foo', 'foo',
new DefaultAuthenticationSuccessHandler($httpUtils), new DefaultAuthenticationSuccessHandler($httpUtils),
new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils), new DefaultAuthenticationFailureHandler($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $httpUtils),
['require_previous_session' => false, 'post_only' => $postOnly] ['require_previous_session' => false, 'post_only' => $postOnly]
); );
$event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
@ -162,15 +162,15 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
->willReturn('someUsername'); ->willReturn('someUsername');
$request = Request::create('/login_check', 'POST', ['_username' => $usernameClass]); $request = Request::create('/login_check', 'POST', ['_username' => $usernameClass]);
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $request->setSession($this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock());
$listener = new UsernamePasswordFormAuthenticationListener( $listener = new UsernamePasswordFormAuthenticationListener(
new TokenStorage(), new TokenStorage(),
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface::class)->getMock(),
new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE), new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE),
$httpUtils = new HttpUtils(), $httpUtils = new HttpUtils(),
'foo', 'foo',
new DefaultAuthenticationSuccessHandler($httpUtils), new DefaultAuthenticationSuccessHandler($httpUtils),
new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils), new DefaultAuthenticationFailureHandler($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $httpUtils),
['require_previous_session' => false, 'post_only' => $postOnly] ['require_previous_session' => false, 'post_only' => $postOnly]
); );
$event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);

View File

@ -12,9 +12,13 @@
namespace Symfony\Component\Security\Http\Tests; namespace Symfony\Component\Security\Http\Tests;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Http\Firewall; use Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
use Symfony\Component\Security\Http\FirewallMapInterface;
class FirewallTest extends TestCase class FirewallTest extends TestCase
{ {

View File

@ -62,7 +62,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$tokenValue = 'foovalue', $tokenValue = 'foovalue',
])); ]));
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
$tokenProvider $tokenProvider
->expects($this->once()) ->expects($this->once())
->method('loadTokenBySeries') ->method('loadTokenBySeries')
@ -81,7 +81,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$request = new Request(); $request = new Request();
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
$tokenProvider $tokenProvider
->expects($this->once()) ->expects($this->once())
->method('loadTokenBySeries') ->method('loadTokenBySeries')
@ -106,7 +106,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$request = new Request(); $request = new Request();
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
$service->setTokenProvider($tokenProvider); $service->setTokenProvider($tokenProvider);
$tokenProvider $tokenProvider
@ -137,7 +137,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$request = new Request(); $request = new Request();
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
$tokenProvider $tokenProvider
->expects($this->once()) ->expects($this->once())
->method('loadTokenBySeries') ->method('loadTokenBySeries')
@ -156,7 +156,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
*/ */
public function testAutoLogin(bool $hashTokenValue) public function testAutoLogin(bool $hashTokenValue)
{ {
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock();
$user $user
->expects($this->once()) ->expects($this->once())
->method('getRoles') ->method('getRoles')
@ -175,7 +175,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$request = new Request(); $request = new Request();
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
$tokenValue = $hashTokenValue ? $this->generateHash('foovalue') : 'foovalue'; $tokenValue = $hashTokenValue ? $this->generateHash('foovalue') : 'foovalue';
$tokenProvider $tokenProvider
->expects($this->once()) ->expects($this->once())
@ -187,7 +187,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$returnedToken = $service->autoLogin($request); $returnedToken = $service->autoLogin($request);
$this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', $returnedToken); $this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::class, $returnedToken);
$this->assertSame($user, $returnedToken->getUser()); $this->assertSame($user, $returnedToken->getUser());
$this->assertEquals('foosecret', $returnedToken->getSecret()); $this->assertEquals('foosecret', $returnedToken->getSecret());
$this->assertTrue($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME)); $this->assertTrue($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME));
@ -199,9 +199,9 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$request = new Request(); $request = new Request();
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue'])); $request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
$response = new Response(); $response = new Response();
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
$tokenProvider $tokenProvider
->expects($this->once()) ->expects($this->once())
->method('deleteTokenBySeries') ->method('deleteTokenBySeries')
@ -225,9 +225,9 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$service = $this->getService(null, ['name' => 'foo', 'path' => null, 'domain' => null]); $service = $this->getService(null, ['name' => 'foo', 'path' => null, 'domain' => null]);
$request = new Request(); $request = new Request();
$response = new Response(); $response = new Response();
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
$tokenProvider $tokenProvider
->expects($this->never()) ->expects($this->never())
->method('deleteTokenBySeries') ->method('deleteTokenBySeries')
@ -248,9 +248,9 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$request = new Request(); $request = new Request();
$request->cookies->set('foo', 'somefoovalue'); $request->cookies->set('foo', 'somefoovalue');
$response = new Response(); $response = new Response();
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
$tokenProvider $tokenProvider
->expects($this->never()) ->expects($this->never())
->method('deleteTokenBySeries') ->method('deleteTokenBySeries')
@ -278,20 +278,20 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$request = new Request(); $request = new Request();
$response = new Response(); $response = new Response();
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $account = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserInterface::class)->getMock();
$account $account
->expects($this->once()) ->expects($this->once())
->method('getUsername') ->method('getUsername')
->willReturn('foo') ->willReturn('foo')
; ;
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$token $token
->expects($this->any()) ->expects($this->any())
->method('getUser') ->method('getUser')
->willReturn($account) ->willReturn($account)
; ;
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
$tokenProvider $tokenProvider
->expects($this->once()) ->expects($this->once())
->method('createNewToken') ->method('createNewToken')
@ -334,7 +334,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
protected function getProvider() protected function getProvider()
{ {
$provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $provider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock();
$provider $provider
->expects($this->any()) ->expects($this->any())
->method('supportsClass') ->method('supportsClass')

View File

@ -68,7 +68,7 @@ class JsonSerializableNormalizerTest extends TestCase
public function testCircularNormalize() public function testCircularNormalize()
{ {
$this->expectException('Symfony\Component\Serializer\Exception\CircularReferenceException'); $this->expectException(\Symfony\Component\Serializer\Exception\CircularReferenceException::class);
$this->createNormalizer([JsonSerializableNormalizer::CIRCULAR_REFERENCE_LIMIT => 1]); $this->createNormalizer([JsonSerializableNormalizer::CIRCULAR_REFERENCE_LIMIT => 1]);
$this->serializer $this->serializer
@ -86,7 +86,7 @@ class JsonSerializableNormalizerTest extends TestCase
public function testInvalidDataThrowException() public function testInvalidDataThrowException()
{ {
$this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Serializer\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('The object must implement "JsonSerializable".'); $this->expectExceptionMessage('The object must implement "JsonSerializable".');
$this->normalizer->normalize(new \stdClass()); $this->normalizer->normalize(new \stdClass());
} }

View File

@ -26,7 +26,7 @@ class UnwrappinDenormalizerTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')->getMock(); $this->serializer = $this->getMockBuilder(\Symfony\Component\Serializer\Serializer::class)->getMock();
$this->denormalizer = new UnwrappingDenormalizer(); $this->denormalizer = new UnwrappingDenormalizer();
$this->denormalizer->setSerializer($this->serializer); $this->denormalizer->setSerializer($this->serializer);
} }

View File

@ -66,7 +66,7 @@ class SerializerTest extends TestCase
public function testItThrowsExceptionOnInvalidNormalizer() public function testItThrowsExceptionOnInvalidNormalizer()
{ {
$this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The class "stdClass" neither implements "Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface" nor "Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface".'); $this->expectExceptionMessage('The class "stdClass" neither implements "Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface" nor "Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface".');
new Serializer([new \stdClass()]); new Serializer([new \stdClass()]);
@ -74,7 +74,7 @@ class SerializerTest extends TestCase
public function testItThrowsExceptionOnInvalidEncoder() public function testItThrowsExceptionOnInvalidEncoder()
{ {
$this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException'); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The class "stdClass" neither implements "Symfony\\Component\\Serializer\\Encoder\\EncoderInterface" nor "Symfony\\Component\\Serializer\\Encoder\\DecoderInterface"'); $this->expectExceptionMessage('The class "stdClass" neither implements "Symfony\\Component\\Serializer\\Encoder\\EncoderInterface" nor "Symfony\\Component\\Serializer\\Encoder\\DecoderInterface"');
new Serializer([], [new \stdClass()]); new Serializer([], [new \stdClass()]);

View File

@ -19,7 +19,7 @@ class LoggingTranslatorTest extends TestCase
{ {
public function testTransWithNoTranslationIsLogged() public function testTransWithNoTranslationIsLogged()
{ {
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
$logger->expects($this->exactly(1)) $logger->expects($this->exactly(1))
->method('warning') ->method('warning')
->with('Translation not found.') ->with('Translation not found.')

View File

@ -37,7 +37,7 @@ class TranslatorTest extends TestCase
*/ */
public function testConstructorInvalidLocale($locale) public function testConstructorInvalidLocale($locale)
{ {
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
new Translator($locale); new Translator($locale);
} }
@ -66,7 +66,7 @@ class TranslatorTest extends TestCase
*/ */
public function testSetInvalidLocale($locale) public function testSetInvalidLocale($locale)
{ {
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
$translator = new Translator('fr'); $translator = new Translator('fr');
$translator->setLocale($locale); $translator->setLocale($locale);
} }
@ -149,7 +149,7 @@ class TranslatorTest extends TestCase
*/ */
public function testSetFallbackInvalidLocales($locale) public function testSetFallbackInvalidLocales($locale)
{ {
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
$translator = new Translator('fr'); $translator = new Translator('fr');
$translator->setFallbackLocales(['fr', $locale]); $translator->setFallbackLocales(['fr', $locale]);
} }
@ -181,7 +181,7 @@ class TranslatorTest extends TestCase
*/ */
public function testAddResourceInvalidLocales($locale) public function testAddResourceInvalidLocales($locale)
{ {
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
$translator = new Translator('fr'); $translator = new Translator('fr');
$translator->addResource('array', ['foo' => 'foofoo'], $locale); $translator->addResource('array', ['foo' => 'foofoo'], $locale);
} }
@ -216,7 +216,7 @@ class TranslatorTest extends TestCase
*/ */
public function testTransWithoutFallbackLocaleFile($format, $loader) public function testTransWithoutFallbackLocaleFile($format, $loader)
{ {
$this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException'); $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class);
$loaderClass = 'Symfony\\Component\\Translation\\Loader\\'.$loader; $loaderClass = 'Symfony\\Component\\Translation\\Loader\\'.$loader;
$translator = new Translator('en'); $translator = new Translator('en');
$translator->addLoader($format, new $loaderClass()); $translator->addLoader($format, new $loaderClass());
@ -332,7 +332,7 @@ class TranslatorTest extends TestCase
public function testWhenAResourceHasNoRegisteredLoader() public function testWhenAResourceHasNoRegisteredLoader()
{ {
$this->expectException('Symfony\Component\Translation\Exception\RuntimeException'); $this->expectException(RuntimeException::class);
$translator = new Translator('en'); $translator = new Translator('en');
$translator->addResource('array', ['foo' => 'foofoo'], 'en'); $translator->addResource('array', ['foo' => 'foofoo'], 'en');
@ -386,7 +386,7 @@ class TranslatorTest extends TestCase
*/ */
public function testTransInvalidLocale($locale) public function testTransInvalidLocale($locale)
{ {
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
$translator = new Translator('en'); $translator = new Translator('en');
$translator->addLoader('array', new ArrayLoader()); $translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', ['foo' => 'foofoo'], 'en'); $translator->addResource('array', ['foo' => 'foofoo'], 'en');

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Translation\Tests\Writer; namespace Symfony\Component\Translation\Tests\Writer;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Dumper\DumperInterface;
use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Writer\TranslationWriter; use Symfony\Component\Translation\Writer\TranslationWriter;

View File

@ -112,7 +112,7 @@ abstract class ConstraintValidatorTestCase extends TestCase
{ {
$translator = $this->getMockBuilder(TranslatorInterface::class)->getMock(); $translator = $this->getMockBuilder(TranslatorInterface::class)->getMock();
$translator->expects($this->any())->method('trans')->willReturnArgument(0); $translator->expects($this->any())->method('trans')->willReturnArgument(0);
$validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock(); $validator = $this->getMockBuilder(\Symfony\Component\Validator\Validator\ValidatorInterface::class)->getMock();
$validator->expects($this->any()) $validator->expects($this->any())
->method('validate') ->method('validate')
->willReturnCallback(function () { ->willReturnCallback(function () {

View File

@ -22,7 +22,7 @@ class AtLeastOneOfTest extends TestCase
{ {
public function testRejectNonConstraints() public function testRejectNonConstraints()
{ {
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
new AtLeastOneOf([ new AtLeastOneOf([
'foo', 'foo',
]); ]);
@ -30,7 +30,7 @@ class AtLeastOneOfTest extends TestCase
public function testRejectValidConstraint() public function testRejectValidConstraint()
{ {
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); $this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
new AtLeastOneOf([ new AtLeastOneOf([
new Valid(), new Valid(),
]); ]);

View File

@ -54,7 +54,7 @@ class LengthValidatorTest extends ConstraintValidatorTestCase
public function testExpectsStringCompatibleType() public function testExpectsStringCompatibleType()
{ {
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
$this->validator->validate(new \stdClass(), new Length(['value' => 5])); $this->validator->validate(new \stdClass(), new Length(['value' => 5]));
} }

View File

@ -38,7 +38,7 @@ class LocaleValidatorTest extends ConstraintValidatorTestCase
public function testExpectsStringCompatibleType() public function testExpectsStringCompatibleType()
{ {
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
$this->validator->validate(new \stdClass(), new Locale()); $this->validator->validate(new \stdClass(), new Locale());
} }

View File

@ -45,7 +45,7 @@ class UrlValidatorTest extends ConstraintValidatorTestCase
public function testExpectsStringCompatibleType() public function testExpectsStringCompatibleType()
{ {
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException'); $this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
$this->validator->validate(new \stdClass(), new Url()); $this->validator->validate(new \stdClass(), new Url());
} }

View File

@ -106,9 +106,9 @@ class LazyLoadingMetadataFactoryTest extends TestCase
public function testNonClassNameStringValues() public function testNonClassNameStringValues()
{ {
$this->expectException('Symfony\Component\Validator\Exception\NoSuchMetadataException'); $this->expectException(\Symfony\Component\Validator\Exception\NoSuchMetadataException::class);
$testedValue = 'error@example.com'; $testedValue = 'error@example.com';
$loader = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
$cache = $this->createMock(CacheItemPoolInterface::class); $cache = $this->createMock(CacheItemPoolInterface::class);
$factory = new LazyLoadingMetadataFactory($loader, $cache); $factory = new LazyLoadingMetadataFactory($loader, $cache);
$cache $cache

View File

@ -35,7 +35,7 @@ class ValidatorBuilderTest extends TestCase
public function testAddObjectInitializer() public function testAddObjectInitializer()
{ {
$this->assertSame($this->builder, $this->builder->addObjectInitializer( $this->assertSame($this->builder, $this->builder->addObjectInitializer(
$this->getMockBuilder('Symfony\Component\Validator\ObjectInitializerInterface')->getMock() $this->getMockBuilder(\Symfony\Component\Validator\ObjectInitializerInterface::class)->getMock()
)); ));
} }
@ -92,14 +92,14 @@ class ValidatorBuilderTest extends TestCase
public function testSetConstraintValidatorFactory() public function testSetConstraintValidatorFactory()
{ {
$this->assertSame($this->builder, $this->builder->setConstraintValidatorFactory( $this->assertSame($this->builder, $this->builder->setConstraintValidatorFactory(
$this->getMockBuilder('Symfony\Component\Validator\ConstraintValidatorFactoryInterface')->getMock()) $this->getMockBuilder(\Symfony\Component\Validator\ConstraintValidatorFactoryInterface::class)->getMock())
); );
} }
public function testSetTranslator() public function testSetTranslator()
{ {
$this->assertSame($this->builder, $this->builder->setTranslator( $this->assertSame($this->builder, $this->builder->setTranslator(
$this->getMockBuilder('Symfony\Contracts\Translation\TranslatorInterface')->getMock()) $this->getMockBuilder(\Symfony\Contracts\Translation\TranslatorInterface::class)->getMock())
); );
} }
@ -110,6 +110,6 @@ class ValidatorBuilderTest extends TestCase
public function testGetValidator() public function testGetValidator()
{ {
$this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator()); $this->assertInstanceOf(\Symfony\Component\Validator\Validator\RecursiveValidator::class, $this->builder->getValidator());
} }
} }

View File

@ -77,7 +77,7 @@ class InMemoryMetadataStoreTest extends TestCase
public function testGetMetadataWithUnknownType() public function testGetMetadataWithUnknownType()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException'); $this->expectException(\Symfony\Component\Workflow\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('Could not find a MetadataBag for the subject of type "bool".'); $this->expectExceptionMessage('Could not find a MetadataBag for the subject of type "bool".');
$this->store->getMetadata('title', true); $this->store->getMetadata('title', true);
} }

View File

@ -14,7 +14,7 @@ class WorkflowValidatorTest extends TestCase
public function testWorkflowWithInvalidNames() public function testWorkflowWithInvalidNames()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException'); $this->expectException(\Symfony\Component\Workflow\Exception\InvalidDefinitionException::class);
$this->expectExceptionMessage('All transitions for a place must have an unique name. Multiple transitions named "t1" where found for place "a" in workflow "foo".'); $this->expectExceptionMessage('All transitions for a place must have an unique name. Multiple transitions named "t1" where found for place "a" in workflow "foo".');
$places = range('a', 'c'); $places = range('a', 'c');

View File

@ -23,7 +23,7 @@ class WorkflowTest extends TestCase
public function testGetMarkingWithInvalidStoreReturn() public function testGetMarkingWithInvalidStoreReturn()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\LogicException'); $this->expectException(\Symfony\Component\Workflow\Exception\LogicException::class);
$this->expectExceptionMessage('The value returned by the MarkingStore is not an instance of "Symfony\Component\Workflow\Marking" for workflow "unnamed".'); $this->expectExceptionMessage('The value returned by the MarkingStore is not an instance of "Symfony\Component\Workflow\Marking" for workflow "unnamed".');
$subject = new Subject(); $subject = new Subject();
$workflow = new Workflow(new Definition([], []), $this->getMockBuilder(MarkingStoreInterface::class)->getMock()); $workflow = new Workflow(new Definition([], []), $this->getMockBuilder(MarkingStoreInterface::class)->getMock());
@ -33,7 +33,7 @@ class WorkflowTest extends TestCase
public function testGetMarkingWithEmptyDefinition() public function testGetMarkingWithEmptyDefinition()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\LogicException'); $this->expectException(\Symfony\Component\Workflow\Exception\LogicException::class);
$this->expectExceptionMessage('The Marking is empty and there is no initial place for workflow "unnamed".'); $this->expectExceptionMessage('The Marking is empty and there is no initial place for workflow "unnamed".');
$subject = new Subject(); $subject = new Subject();
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore()); $workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
@ -43,7 +43,7 @@ class WorkflowTest extends TestCase
public function testGetMarkingWithImpossiblePlace() public function testGetMarkingWithImpossiblePlace()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\LogicException'); $this->expectException(\Symfony\Component\Workflow\Exception\LogicException::class);
$this->expectExceptionMessage('Place "nope" is not valid for workflow "unnamed".'); $this->expectExceptionMessage('Place "nope" is not valid for workflow "unnamed".');
$subject = new Subject(); $subject = new Subject();
$subject->setMarking(['nope' => 1]); $subject->setMarking(['nope' => 1]);
@ -170,7 +170,7 @@ class WorkflowTest extends TestCase
public function testBuildTransitionBlockerListReturnsUndefinedTransition() public function testBuildTransitionBlockerListReturnsUndefinedTransition()
{ {
$this->expectException('Symfony\Component\Workflow\Exception\UndefinedTransitionException'); $this->expectException(UndefinedTransitionException::class);
$this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".'); $this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".');
$definition = $this->createSimpleWorkflowDefinition(); $definition = $this->createSimpleWorkflowDefinition();
$subject = new Subject(); $subject = new Subject();

View File

@ -525,7 +525,7 @@ EOF;
public function testMappingKeyInMultiLineStringTriggersDeprecationNotice() public function testMappingKeyInMultiLineStringTriggersDeprecationNotice()
{ {
$this->expectException('Symfony\Component\Yaml\Exception\ParseException'); $this->expectException(ParseException::class);
$this->expectExceptionMessage('Mapping values are not allowed in multi-line blocks at line 2 (near "dbal:wrong").'); $this->expectExceptionMessage('Mapping values are not allowed in multi-line blocks at line 2 (near "dbal:wrong").');
$yaml = <<<'EOF' $yaml = <<<'EOF'