Merge branch '5.2' into 5.x
* 5.2: Use ::class keyword when possible
This commit is contained in:
commit
742dd1326a
@ -118,13 +118,13 @@ class EntityTypeTest extends BaseTypeTest
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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, [
|
||||
'class' => 'foo',
|
||||
]);
|
||||
@ -219,7 +219,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
|
||||
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, [
|
||||
'em' => 'default',
|
||||
'class' => self::SINGLE_IDENT_CLASS,
|
||||
@ -229,7 +229,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
|
||||
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, [
|
||||
'em' => 'default',
|
||||
'class' => self::SINGLE_IDENT_CLASS,
|
||||
@ -1242,7 +1242,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
$choiceList2 = $form->get('property2')->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, $choiceList3);
|
||||
}
|
||||
@ -1302,7 +1302,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
$choiceList2 = $form->get('property2')->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, $choiceList3);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class DoctrineExtractorTest extends TestCase
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ class DoctrineExtractorTest extends TestCase
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
|
@ -49,14 +49,14 @@ class TranslationExtensionTest extends TestCase
|
||||
|
||||
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->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render();
|
||||
}
|
||||
|
||||
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->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ class FrameworkExtension extends Extension
|
||||
// default in the Form and Validator component). If disabled, an identity
|
||||
// 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 (!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".');
|
||||
}
|
||||
|
||||
@ -320,14 +320,14 @@ class FrameworkExtension extends Extension
|
||||
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
|
||||
|
||||
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".');
|
||||
}
|
||||
|
||||
$this->formConfigEnabled = true;
|
||||
$this->registerFormConfiguration($config, $container, $loader);
|
||||
|
||||
if (class_exists('Symfony\Component\Validator\Validation')) {
|
||||
if (class_exists(\Symfony\Component\Validator\Validation::class)) {
|
||||
$config['validation']['enabled'] = true;
|
||||
} else {
|
||||
$container->setParameter('validator.translation_domain', 'validators');
|
||||
@ -340,7 +340,7 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
|
||||
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".');
|
||||
}
|
||||
|
||||
@ -408,7 +408,7 @@ class FrameworkExtension extends Extension
|
||||
$this->registerSecretsConfiguration($config['secrets'], $container, $loader);
|
||||
|
||||
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".');
|
||||
}
|
||||
|
||||
@ -1170,18 +1170,18 @@ class FrameworkExtension extends Extension
|
||||
$dirs = [];
|
||||
$transPaths = [];
|
||||
$nonExistingDirs = [];
|
||||
if (class_exists('Symfony\Component\Validator\Validation')) {
|
||||
$r = new \ReflectionClass('Symfony\Component\Validator\Validation');
|
||||
if (class_exists(\Symfony\Component\Validator\Validation::class)) {
|
||||
$r = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
|
||||
|
||||
$dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
|
||||
}
|
||||
if (class_exists('Symfony\Component\Form\Form')) {
|
||||
$r = new \ReflectionClass('Symfony\Component\Form\Form');
|
||||
if (class_exists(\Symfony\Component\Form\Form::class)) {
|
||||
$r = new \ReflectionClass(\Symfony\Component\Form\Form::class);
|
||||
|
||||
$dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
|
||||
}
|
||||
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
|
||||
$r = new \ReflectionClass('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::class);
|
||||
|
||||
$dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
|
||||
}
|
||||
@ -1279,7 +1279,7 @@ class FrameworkExtension extends Extension
|
||||
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".');
|
||||
}
|
||||
|
||||
@ -1346,8 +1346,8 @@ class FrameworkExtension extends Extension
|
||||
$files['yaml' === $extension ? 'yml' : $extension][] = $path;
|
||||
};
|
||||
|
||||
if (interface_exists('Symfony\Component\Form\FormInterface')) {
|
||||
$reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface');
|
||||
if (interface_exists(\Symfony\Component\Form\FormInterface::class)) {
|
||||
$reflClass = new \ReflectionClass(\Symfony\Component\Form\FormInterface::class);
|
||||
$fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
|
||||
}
|
||||
|
||||
@ -1408,7 +1408,7 @@ class FrameworkExtension extends Extension
|
||||
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.');
|
||||
}
|
||||
|
||||
@ -1420,7 +1420,7 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
@ -1531,7 +1531,7 @@ class FrameworkExtension extends Extension
|
||||
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".');
|
||||
}
|
||||
|
||||
@ -1646,7 +1646,7 @@ class FrameworkExtension extends Extension
|
||||
|
||||
$loader->load('property_info.php');
|
||||
|
||||
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->addTag('property_info.description_extractor', ['priority' => -1000]);
|
||||
$definition->addTag('property_info.type_extractor', ['priority' => -1001]);
|
||||
|
@ -92,7 +92,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
{
|
||||
$this->fs->mkdir($this->translationDir.'/customDir/translations');
|
||||
$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())
|
||||
->method('getBundle')
|
||||
->with($this->equalTo($this->translationDir.'/customDir'))
|
||||
@ -110,8 +110,8 @@ class TranslationDebugCommandTest extends TestCase
|
||||
|
||||
public function testDebugInvalidDirectory()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
||||
$kernel->expects($this->once())
|
||||
->method('getBundle')
|
||||
->with($this->equalTo('dir'))
|
||||
@ -136,7 +136,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
|
||||
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()
|
||||
->getMock();
|
||||
|
||||
@ -145,7 +145,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
->method('getFallbackLocales')
|
||||
->willReturn(['en']);
|
||||
|
||||
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
|
||||
$extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
|
||||
$extractor
|
||||
->expects($this->any())
|
||||
->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
|
||||
->expects($this->any())
|
||||
->method('read')
|
||||
@ -170,7 +170,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
['foo', $this->getBundle($this->translationDir)],
|
||||
['test', $this->getBundle('test')],
|
||||
];
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
@ -198,7 +198,7 @@ class TranslationDebugCommandTest extends TestCase
|
||||
|
||||
private function getBundle($path)
|
||||
{
|
||||
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
|
||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
||||
$bundle
|
||||
->expects($this->any())
|
||||
->method('getPath')
|
||||
|
@ -145,7 +145,7 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
*/
|
||||
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()
|
||||
->getMock();
|
||||
|
||||
@ -154,7 +154,7 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
->method('getFallbackLocales')
|
||||
->willReturn(['en']);
|
||||
|
||||
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
|
||||
$extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
|
||||
$extractor
|
||||
->expects($this->any())
|
||||
->method('extract')
|
||||
@ -166,7 +166,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
|
||||
->expects($this->any())
|
||||
->method('read')
|
||||
@ -176,7 +176,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
|
||||
->expects($this->any())
|
||||
->method('getFormats')
|
||||
@ -189,7 +189,7 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
['foo', $this->getBundle($this->translationDir)],
|
||||
['test', $this->getBundle('test')],
|
||||
];
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
@ -217,7 +217,7 @@ class TranslationUpdateCommandTest extends TestCase
|
||||
|
||||
private function getBundle($path)
|
||||
{
|
||||
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
|
||||
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
|
||||
$bundle
|
||||
->expects($this->any())
|
||||
->method('getPath')
|
||||
|
@ -30,7 +30,7 @@ class ApplicationTest extends TestCase
|
||||
{
|
||||
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);
|
||||
|
||||
@ -236,10 +236,10 @@ class ApplicationTest extends TestCase
|
||||
|
||||
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) {
|
||||
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
|
||||
$dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
|
||||
$dispatcher
|
||||
->expects($this->atLeastOnce())
|
||||
->method('dispatch')
|
||||
@ -264,7 +264,7 @@ class ApplicationTest extends TestCase
|
||||
->willReturnOnConsecutiveCalls([], [])
|
||||
;
|
||||
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
|
||||
$kernel->expects($this->once())->method('boot');
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
@ -282,7 +282,7 @@ class ApplicationTest extends TestCase
|
||||
|
||||
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
|
||||
->expects($this->once())
|
||||
->method('registerCommands')
|
||||
|
@ -101,7 +101,7 @@ class AbstractControllerTest extends TestCase
|
||||
$requestStack = new RequestStack();
|
||||
$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) {
|
||||
return new Response($request->getRequestFormat().'--'.$request->getLocale());
|
||||
});
|
||||
@ -148,7 +148,7 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
public function testGetUserWithEmptyContainer()
|
||||
{
|
||||
$this->expectException('LogicException');
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('The SecurityBundle is not registered in your application.');
|
||||
|
||||
$controller = $this->createController();
|
||||
@ -162,7 +162,7 @@ class AbstractControllerTest extends TestCase
|
||||
*/
|
||||
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
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
@ -231,7 +231,7 @@ class AbstractControllerTest extends TestCase
|
||||
public function testFile()
|
||||
{
|
||||
$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);
|
||||
|
||||
$controller = $this->createController();
|
||||
@ -332,7 +332,7 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
public function testFileWhichDoesNotExist()
|
||||
{
|
||||
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||
$this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class);
|
||||
|
||||
$controller = $this->createController();
|
||||
|
||||
@ -341,7 +341,7 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
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);
|
||||
|
||||
$container = new Container();
|
||||
@ -355,9 +355,9 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
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);
|
||||
|
||||
$container = new Container();
|
||||
@ -371,7 +371,7 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
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');
|
||||
|
||||
$container = new Container();
|
||||
@ -385,7 +385,7 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
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');
|
||||
|
||||
$container = new Container();
|
||||
@ -399,7 +399,7 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
public function testStreamTwig()
|
||||
{
|
||||
$twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock();
|
||||
$twig = $this->getMockBuilder(\Twig\Environment::class)->disableOriginalConstructor()->getMock();
|
||||
|
||||
$container = new Container();
|
||||
$container->set('twig', $twig);
|
||||
@ -407,12 +407,12 @@ class AbstractControllerTest extends TestCase
|
||||
$controller = $this->createController();
|
||||
$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()
|
||||
{
|
||||
$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');
|
||||
|
||||
$container = new Container();
|
||||
@ -422,7 +422,7 @@ class AbstractControllerTest extends TestCase
|
||||
$controller->setContainer($container);
|
||||
$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(302, $response->getStatusCode());
|
||||
}
|
||||
@ -433,7 +433,7 @@ class AbstractControllerTest extends TestCase
|
||||
public function testAddFlash()
|
||||
{
|
||||
$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);
|
||||
|
||||
$container = new Container();
|
||||
@ -450,12 +450,12 @@ class AbstractControllerTest extends TestCase
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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);
|
||||
|
||||
$container = new Container();
|
||||
@ -469,7 +469,7 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
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');
|
||||
|
||||
$container = new Container();
|
||||
@ -486,7 +486,7 @@ class AbstractControllerTest extends TestCase
|
||||
$controller = $this->createController();
|
||||
$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(301, $response->getStatusCode());
|
||||
}
|
||||
@ -495,14 +495,14 @@ class AbstractControllerTest extends TestCase
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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);
|
||||
|
||||
$container = new Container();
|
||||
@ -516,9 +516,9 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
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);
|
||||
|
||||
$container = new Container();
|
||||
@ -532,7 +532,7 @@ class AbstractControllerTest extends TestCase
|
||||
|
||||
public function testGetDoctrine()
|
||||
{
|
||||
$doctrine = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')->getMock();
|
||||
$doctrine = $this->getMockBuilder(\Doctrine\Persistence\ManagerRegistry::class)->getMock();
|
||||
|
||||
$container = new Container();
|
||||
$container->set('doctrine', $doctrine);
|
||||
|
@ -31,8 +31,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
||||
|
||||
$controller = $resolver->getController($request);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller[0]);
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller[0]->getContainer());
|
||||
$this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller[0]);
|
||||
$this->assertInstanceOf(ContainerInterface::class, $controller[0]->getContainer());
|
||||
$this->assertSame('testAction', $controller[1]);
|
||||
}
|
||||
|
||||
@ -44,8 +44,8 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
||||
|
||||
$controller = $resolver->getController($request);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller);
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller->getContainer());
|
||||
$this->assertInstanceOf(\Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::class, $controller);
|
||||
$this->assertInstanceOf(ContainerInterface::class, $controller->getContainer());
|
||||
}
|
||||
|
||||
public function testContainerAwareControllerGetsContainerWhenNotSet()
|
||||
@ -68,7 +68,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
||||
|
||||
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?');
|
||||
|
||||
class_exists(AbstractControllerTest::class);
|
||||
@ -89,7 +89,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
||||
|
||||
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?');
|
||||
|
||||
class_exists(AbstractControllerTest::class);
|
||||
@ -159,12 +159,12 @@ class ControllerResolverTest extends ContainerControllerResolverTest
|
||||
|
||||
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()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||
return $this->getMockBuilder(ContainerInterface::class)->getMock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ class TemplateControllerTest extends TestCase
|
||||
{
|
||||
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');
|
||||
|
||||
$controller = new TemplateController($twig);
|
||||
@ -34,7 +34,7 @@ class TemplateControllerTest extends TestCase
|
||||
|
||||
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.');
|
||||
$controller = new TemplateController();
|
||||
|
||||
|
@ -25,7 +25,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
||||
|
||||
public function testAssetsCannotHavePathAndUrl()
|
||||
{
|
||||
$this->expectException('LogicException');
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->createContainerFromClosure(function ($container) {
|
||||
$container->loadFromExtension('framework', [
|
||||
'assets' => [
|
||||
@ -38,7 +38,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
||||
|
||||
public function testAssetPackageCannotHavePathAndUrl()
|
||||
{
|
||||
$this->expectException('LogicException');
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->createContainerFromClosure(function ($container) {
|
||||
$container->loadFromExtension('framework', [
|
||||
'assets' => [
|
||||
@ -55,7 +55,7 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
||||
|
||||
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->createContainerFromClosure(function ($container) {
|
||||
$container->loadFromExtension('framework', [
|
||||
|
@ -25,7 +25,7 @@ class RouterTest extends TestCase
|
||||
{
|
||||
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');
|
||||
new Router($this->createMock(ContainerInterface::class), 'foo');
|
||||
}
|
||||
@ -293,7 +293,7 @@ class RouterTest extends TestCase
|
||||
|
||||
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.');
|
||||
$routes = new RouteCollection();
|
||||
|
||||
@ -305,7 +305,7 @@ class RouterTest extends TestCase
|
||||
|
||||
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.');
|
||||
$routes = new RouteCollection();
|
||||
|
||||
@ -375,7 +375,7 @@ class RouterTest extends TestCase
|
||||
|
||||
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".');
|
||||
$routes = new RouteCollection();
|
||||
|
||||
@ -389,7 +389,7 @@ class RouterTest extends TestCase
|
||||
|
||||
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".');
|
||||
$routes = new RouteCollection();
|
||||
|
||||
@ -404,7 +404,7 @@ class RouterTest extends TestCase
|
||||
|
||||
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".');
|
||||
$routes = new RouteCollection();
|
||||
|
||||
@ -504,7 +504,7 @@ class RouterTest extends TestCase
|
||||
|
||||
private function getServiceContainer(RouteCollection $routes): Container
|
||||
{
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
|
||||
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
|
||||
|
||||
$loader
|
||||
->expects($this->any())
|
||||
@ -512,7 +512,7 @@ class RouterTest extends TestCase
|
||||
->willReturn($routes)
|
||||
;
|
||||
|
||||
$sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock();
|
||||
$sc = $this->getMockBuilder(Container::class)->setMethods(['get'])->getMock();
|
||||
|
||||
$sc
|
||||
->expects($this->once())
|
||||
|
@ -81,7 +81,7 @@ class TranslatorTest extends TestCase
|
||||
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
|
||||
|
||||
// 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');
|
||||
|
||||
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]);
|
||||
@ -99,9 +99,9 @@ class TranslatorTest extends TestCase
|
||||
|
||||
public function testTransWithCachingWithInvalidLocale()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$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->trans('foo');
|
||||
@ -132,9 +132,9 @@ class TranslatorTest extends TestCase
|
||||
|
||||
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\'');
|
||||
$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']));
|
||||
}
|
||||
@ -144,7 +144,7 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$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))
|
||||
->method('load')
|
||||
@ -262,7 +262,7 @@ class TranslatorTest extends TestCase
|
||||
|
||||
protected function getLoader()
|
||||
{
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
|
||||
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Loader\LoaderInterface::class)->getMock();
|
||||
$loader
|
||||
->expects($this->exactly(7))
|
||||
->method('load')
|
||||
@ -298,7 +298,7 @@ class TranslatorTest extends TestCase
|
||||
|
||||
protected function getContainer($loader)
|
||||
{
|
||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
|
||||
$container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
@ -339,7 +339,7 @@ class TranslatorTest extends TestCase
|
||||
$translator->setFallbackLocales(['fr']);
|
||||
$translator->warmup($this->tmpDir);
|
||||
|
||||
$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');
|
||||
|
@ -45,7 +45,7 @@ class RemoteJsonManifestVersionStrategyTest extends TestCase
|
||||
|
||||
public function testMissingManifestFileThrowsException()
|
||||
{
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$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->getVersion('main.js');
|
||||
|
@ -111,7 +111,7 @@ abstract class AbstractBrowser
|
||||
*/
|
||||
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.');
|
||||
}
|
||||
|
||||
@ -521,7 +521,7 @@ abstract class AbstractBrowser
|
||||
*/
|
||||
protected function createCrawlerFromContent(string $uri, string $content, string $type)
|
||||
{
|
||||
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
|
||||
if (!class_exists(Crawler::class)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class AbstractBrowserTest extends TestCase
|
||||
|
||||
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()".');
|
||||
|
||||
$client = $this->getBrowser();
|
||||
@ -93,7 +93,7 @@ class AbstractBrowserTest extends TestCase
|
||||
|
||||
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()".');
|
||||
|
||||
$client = $this->getBrowser();
|
||||
@ -102,7 +102,7 @@ class AbstractBrowserTest extends TestCase
|
||||
|
||||
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()".');
|
||||
|
||||
$client = $this->getBrowser();
|
||||
@ -129,7 +129,7 @@ class AbstractBrowserTest extends TestCase
|
||||
|
||||
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()".');
|
||||
|
||||
$client = $this->getBrowser();
|
||||
@ -842,7 +842,7 @@ class AbstractBrowserTest extends TestCase
|
||||
|
||||
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()".');
|
||||
|
||||
$client = $this->getBrowser();
|
||||
|
@ -82,7 +82,7 @@ class ApcuAdapter extends AbstractAdapter
|
||||
*/
|
||||
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_clear_cache();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class ConfigCacheFactoryTest extends TestCase
|
||||
{
|
||||
public function testCacheWithInvalidCallback()
|
||||
{
|
||||
$this->expectException('TypeError');
|
||||
$this->expectException(\TypeError::class);
|
||||
$cacheFactory = new ConfigCacheFactory(true);
|
||||
|
||||
$cacheFactory->cache('file', new \stdClass());
|
||||
|
@ -80,7 +80,7 @@ class ScalarNodeTest extends TestCase
|
||||
*/
|
||||
public function testNormalizeThrowsExceptionOnInvalidValues($value)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
||||
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class);
|
||||
$node = new ScalarNode('test');
|
||||
$node->normalize($value);
|
||||
}
|
||||
@ -98,7 +98,7 @@ class ScalarNodeTest extends TestCase
|
||||
{
|
||||
$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".');
|
||||
|
||||
$node->normalize([]);
|
||||
@ -109,7 +109,7 @@ class ScalarNodeTest extends TestCase
|
||||
$node = new ScalarNode('test');
|
||||
$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\"");
|
||||
|
||||
$node->normalize([]);
|
||||
@ -148,7 +148,7 @@ class ScalarNodeTest extends TestCase
|
||||
*/
|
||||
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->setAllowEmptyValue(false);
|
||||
$node->finalize($value);
|
||||
|
@ -739,7 +739,7 @@ class ApplicationTest extends TestCase
|
||||
$application->add(new \FooCommand());
|
||||
$application->add(new \FooHiddenCommand());
|
||||
|
||||
$this->assertInstanceOf('FooCommand', $application->find('foo:'));
|
||||
$this->assertInstanceOf(\FooCommand::class, $application->find('foo:'));
|
||||
}
|
||||
|
||||
public function testSetCatchExceptions()
|
||||
|
@ -42,7 +42,7 @@ class CommandTest extends TestCase
|
||||
|
||||
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.');
|
||||
(new Application())->add(new Command());
|
||||
}
|
||||
@ -115,7 +115,7 @@ class CommandTest extends TestCase
|
||||
*/
|
||||
public function testInvalidCommandNames($name)
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name));
|
||||
|
||||
$command = new \TestCommand();
|
||||
@ -207,7 +207,7 @@ class CommandTest extends TestCase
|
||||
|
||||
public function testGetHelperWithoutHelperSet()
|
||||
{
|
||||
$this->expectException('LogicException');
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Cannot retrieve helper "formatter" because there is no HelperSet defined.');
|
||||
$command = new \TestCommand();
|
||||
$command->getHelper('formatter');
|
||||
@ -278,7 +278,7 @@ class CommandTest extends TestCase
|
||||
|
||||
public function testExecuteMethodNeedsToBeOverridden()
|
||||
{
|
||||
$this->expectException('LogicException');
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('You must override the execute() method in the concrete command class.');
|
||||
$command = new Command('foo');
|
||||
$command->run(new StringInput(''), new NullOutput());
|
||||
@ -286,7 +286,7 @@ class CommandTest extends TestCase
|
||||
|
||||
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.');
|
||||
$command = new \TestCommand();
|
||||
$tester = new CommandTester($command);
|
||||
|
@ -91,7 +91,7 @@ class ChildDefinitionTest extends TestCase
|
||||
|
||||
public function testReplaceArgumentShouldRequireIntegerIndex()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$def = new ChildDefinition('foo');
|
||||
|
||||
$def->replaceArgument('0', 'foo');
|
||||
@ -118,7 +118,7 @@ class ChildDefinitionTest extends TestCase
|
||||
|
||||
public function testGetArgumentShouldCheckBounds()
|
||||
{
|
||||
$this->expectException('OutOfBoundsException');
|
||||
$this->expectException(\OutOfBoundsException::class);
|
||||
$def = new ChildDefinition('foo');
|
||||
|
||||
$def->setArguments([0 => 'foo']);
|
||||
|
@ -57,7 +57,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
|
||||
|
||||
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)".');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
@ -217,7 +217,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
|
||||
|
||||
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.');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
|
@ -70,7 +70,7 @@ class ExtensionTest extends TestCase
|
||||
|
||||
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".');
|
||||
|
||||
$extension = new InvalidConfigExtension();
|
||||
|
@ -95,7 +95,7 @@ class PhpFileLoaderTest extends TestCase
|
||||
|
||||
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.');
|
||||
$fixtures = realpath(__DIR__.'/../Fixtures');
|
||||
$container = new ContainerBuilder();
|
||||
|
@ -60,7 +60,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
$loader->load('foo.xml');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
|
||||
} 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');
|
||||
}
|
||||
}
|
||||
@ -76,11 +76,11 @@ class XmlFileLoaderTest extends TestCase
|
||||
$m->invoke($loader, self::$fixturesPath.'/ini/parameters.ini');
|
||||
$this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file is not a valid XML file');
|
||||
} 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');
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
@ -90,16 +90,16 @@ class XmlFileLoaderTest extends TestCase
|
||||
$m->invoke($loader, self::$fixturesPath.'/xml/nonvalid.xml');
|
||||
$this->fail('->parseFileToDOM() throws an InvalidArgumentException if the loaded file does not validate the XSD');
|
||||
} 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');
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
$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()
|
||||
@ -200,11 +200,11 @@ class XmlFileLoaderTest extends TestCase
|
||||
$loader->load('services4_bad_import_with_errors.xml');
|
||||
$this->fail('->load() throws a LoaderLoadException if the imported xml file configuration does not exist');
|
||||
} 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');
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
@ -212,15 +212,15 @@ class XmlFileLoaderTest extends TestCase
|
||||
$loader->load('services4_bad_import_nonvalid.xml');
|
||||
$this->fail('->load() throws an LoaderLoadException if the imported configuration does not validate the XSD');
|
||||
} 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');
|
||||
|
||||
$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');
|
||||
|
||||
$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');
|
||||
}
|
||||
}
|
||||
@ -236,7 +236,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
// anonymous service as an argument
|
||||
$args = $services['foo']->getArguments();
|
||||
$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');
|
||||
$inner = $services[(string) $args[0]];
|
||||
$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
|
||||
$args = $inner->getArguments();
|
||||
$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');
|
||||
$inner = $services[(string) $args[0]];
|
||||
$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
|
||||
$properties = $services['foo']->getProperties();
|
||||
$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');
|
||||
$inner = $services[(string) $property];
|
||||
$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()
|
||||
{
|
||||
$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');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
@ -296,7 +296,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
$services = $container->getDefinitions();
|
||||
$this->assertArrayHasKey('foo', $services, '->load() parses <service> elements');
|
||||
$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('%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');
|
||||
@ -378,7 +378,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testParseTagsWithoutNameThrowsException()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
$loader->load('tag_without_name.xml');
|
||||
@ -386,7 +386,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
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/');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
@ -535,11 +535,11 @@ class XmlFileLoaderTest extends TestCase
|
||||
$loader->load('extensions/services3.xml');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
|
||||
} 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');
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
@ -572,11 +572,11 @@ class XmlFileLoaderTest extends TestCase
|
||||
$loader->load('extensions/services7.xml');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the configuration does not validate the XSD');
|
||||
} 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');
|
||||
|
||||
$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');
|
||||
}
|
||||
}
|
||||
@ -623,11 +623,11 @@ class XmlFileLoaderTest extends TestCase
|
||||
$loader->load('withdoctype.xml');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the configuration contains a document type');
|
||||
} 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');
|
||||
|
||||
$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');
|
||||
}
|
||||
}
|
||||
@ -772,7 +772,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
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');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
|
@ -52,7 +52,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadUnExistFile()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessageMatches('/The file ".+" does not exist./');
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini'));
|
||||
$r = new \ReflectionObject($loader);
|
||||
@ -64,7 +64,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadInvalidYamlFile()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessageMatches('/The file ".+" does not contain valid YAML./');
|
||||
$path = self::$fixturesPath.'/ini';
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator($path));
|
||||
@ -80,7 +80,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
*/
|
||||
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->load($file.'.yml');
|
||||
@ -146,11 +146,11 @@ class YamlFileLoaderTest extends TestCase
|
||||
$loader->load('services4_bad_import_with_errors.yml');
|
||||
$this->fail('->load() throws a LoaderLoadException if the imported yaml file does not exist');
|
||||
} 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');
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
@ -158,11 +158,11 @@ class YamlFileLoaderTest extends TestCase
|
||||
$loader->load('services4_bad_import_nonvalid.yml');
|
||||
$this->fail('->load() throws a LoaderLoadException if the tag in the imported yaml file is not valid');
|
||||
} 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');
|
||||
|
||||
$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');
|
||||
}
|
||||
}
|
||||
@ -175,7 +175,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
$services = $container->getDefinitions();
|
||||
$this->assertArrayHasKey('foo', $services, '->load() parses service elements');
|
||||
$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('%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');
|
||||
@ -313,7 +313,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
$loader->load('badtag1.yml');
|
||||
$this->fail('->load() should throw an exception when the tags key of a service is not an array');
|
||||
} 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');
|
||||
}
|
||||
}
|
||||
@ -325,7 +325,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
$loader->load('badtag2.yml');
|
||||
$this->fail('->load() should throw an exception when a tag is missing the name key');
|
||||
} 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');
|
||||
}
|
||||
}
|
||||
@ -366,7 +366,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
$loader->load('badtag3.yml');
|
||||
$this->fail('->load() should throw an exception when a tag-attribute is not a scalar');
|
||||
} 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');
|
||||
}
|
||||
}
|
||||
@ -385,7 +385,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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/');
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('tag_name_empty_string.yml');
|
||||
@ -393,7 +393,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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/');
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('tag_name_no_string.yml');
|
||||
@ -493,7 +493,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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 .+/');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
@ -597,7 +597,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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").');
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('bad_parent.yml');
|
||||
@ -605,7 +605,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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").');
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('bad_decorates.yml');
|
||||
@ -613,7 +613,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testDecoratedServicesWithWrongOnInvalidSyntaxThrowsException()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Did you mean null (without quotes)');
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('bad_decoration_on_invalid_null.yml');
|
||||
@ -621,7 +621,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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./');
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('services31_invalid_tags.yml');
|
||||
@ -629,7 +629,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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.');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
@ -711,7 +711,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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"\./');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
@ -720,7 +720,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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"\./');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
@ -739,7 +739,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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"\./');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
@ -748,7 +748,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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"\./');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
@ -757,7 +757,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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"/');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
@ -766,7 +766,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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/');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
@ -826,7 +826,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
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.');
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
|
@ -18,7 +18,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
||||
{
|
||||
public function testGetThrowsInvalidArgumentExceptionIfEnvNameContainsNonWordCharacters()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
|
||||
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
|
||||
$bag = new EnvPlaceholderParameterBag();
|
||||
$bag->get('env(%foo%)');
|
||||
}
|
||||
@ -111,7 +111,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
||||
|
||||
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.');
|
||||
|
||||
$bag = new EnvPlaceholderParameterBag();
|
||||
@ -122,7 +122,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
||||
|
||||
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)".');
|
||||
|
||||
$bag = new EnvPlaceholderParameterBag();
|
||||
@ -153,7 +153,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
||||
|
||||
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.');
|
||||
$bag = new EnvPlaceholderParameterBag();
|
||||
$bag->get('env(ARRAY_VAR)');
|
||||
@ -173,7 +173,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
||||
|
||||
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)".');
|
||||
$bag = new EnvPlaceholderParameterBag();
|
||||
$bag->set('env(ARRAY_VAR)', []);
|
||||
|
@ -322,7 +322,7 @@ class DotenvTest extends TestCase
|
||||
|
||||
public function testLoadDirectory()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Dotenv\Exception\PathException');
|
||||
$this->expectException(\Symfony\Component\Dotenv\Exception\PathException::class);
|
||||
$dotenv = new Dotenv();
|
||||
$dotenv->load(__DIR__);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ class ErrorHandler
|
||||
$this->bootstrappingLogger = $bootstrappingLogger;
|
||||
$this->setDefaultLogger($bootstrappingLogger);
|
||||
}
|
||||
$traceReflector = new \ReflectionProperty('Exception', 'trace');
|
||||
$traceReflector = new \ReflectionProperty(\Exception::class, 'trace');
|
||||
$traceReflector->setAccessible(true);
|
||||
$this->configureException = \Closure::bind(static function ($e, $trace, $file = null, $line = null) use ($traceReflector) {
|
||||
$traceReflector->setValue($e, $trace);
|
||||
|
@ -17,7 +17,7 @@
|
||||
);
|
||||
</script>
|
||||
|
||||
<?php if (class_exists('Symfony\Component\HttpKernel\Kernel')) { ?>
|
||||
<?php if (class_exists(\Symfony\Component\HttpKernel\Kernel::class)) { ?>
|
||||
<header>
|
||||
<div class="container">
|
||||
<h1 class="logo"><?= $this->include('assets/images/symfony-logo.svg'); ?> Symfony Exception</h1>
|
||||
|
@ -133,8 +133,8 @@ class EventDispatcherTest extends TestCase
|
||||
$this->dispatcher->dispatch(new Event(), self::preFoo);
|
||||
$this->assertTrue($this->listener->preFooInvoked);
|
||||
$this->assertFalse($this->listener->postFooInvoked);
|
||||
$this->assertInstanceOf('Symfony\Contracts\EventDispatcher\Event', $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(), 'noevent'));
|
||||
$this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), self::preFoo));
|
||||
$event = new Event();
|
||||
$return = $this->dispatcher->dispatch($event, self::preFoo);
|
||||
$this->assertSame($event, $return);
|
||||
@ -213,7 +213,7 @@ class EventDispatcherTest extends TestCase
|
||||
$listeners = $this->dispatcher->getListeners('pre.foo');
|
||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||
$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()
|
||||
|
@ -38,7 +38,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
|
||||
$this->decoratedFactory = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface::class)->getMock();
|
||||
$this->factory = new CachingFactoryDecorator($this->decoratedFactory);
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
|
||||
public function testCreateFromLoaderSameLoader()
|
||||
{
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
|
||||
$list = new ArrayChoiceList([]);
|
||||
$list2 = new ArrayChoiceList([]);
|
||||
|
||||
@ -269,8 +269,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
|
||||
public function testCreateFromLoaderDifferentLoader()
|
||||
{
|
||||
$loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||
$loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||
$loader1 = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
|
||||
$loader2 = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
|
||||
$list1 = new ArrayChoiceList([]);
|
||||
$list2 = new ArrayChoiceList([]);
|
||||
|
||||
@ -288,7 +288,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
|
||||
public function testCreateFromLoaderSameValueClosure()
|
||||
{
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
|
||||
$type = $this->createMock(FormTypeInterface::class);
|
||||
$list = new ArrayChoiceList([]);
|
||||
$list2 = new ArrayChoiceList([]);
|
||||
@ -328,7 +328,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
|
||||
public function testCreateFromLoaderDifferentValueClosure()
|
||||
{
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
|
||||
$type = $this->createMock(FormTypeInterface::class);
|
||||
$list1 = new ArrayChoiceList([]);
|
||||
$list2 = new ArrayChoiceList([]);
|
||||
@ -349,7 +349,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
|
||||
public function testCreateFromLoaderSameFilterClosure()
|
||||
{
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
|
||||
$type = $this->createMock(FormTypeInterface::class);
|
||||
$list = new ArrayChoiceList([]);
|
||||
$list2 = new ArrayChoiceList([]);
|
||||
@ -391,7 +391,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
|
||||
public function testCreateFromLoaderDifferentFilterClosure()
|
||||
{
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
|
||||
$type = $this->createMock(FormTypeInterface::class);
|
||||
$list1 = new ArrayChoiceList([]);
|
||||
$list2 = new ArrayChoiceList([]);
|
||||
@ -413,7 +413,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
public function testCreateViewSamePreferredChoices()
|
||||
{
|
||||
$preferred = ['a'];
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -447,7 +447,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
{
|
||||
$preferred1 = ['a'];
|
||||
$preferred2 = ['b'];
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view1 = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -466,7 +466,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
public function testCreateViewSamePreferredChoicesClosure()
|
||||
{
|
||||
$preferred = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -500,7 +500,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
{
|
||||
$preferred1 = function () {};
|
||||
$preferred2 = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view1 = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -519,7 +519,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
public function testCreateViewSameLabelClosure()
|
||||
{
|
||||
$labels = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -553,7 +553,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
{
|
||||
$labels1 = function () {};
|
||||
$labels2 = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view1 = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -572,7 +572,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
public function testCreateViewSameIndexClosure()
|
||||
{
|
||||
$index = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -606,7 +606,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
{
|
||||
$index1 = function () {};
|
||||
$index2 = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view1 = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -625,7 +625,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
public function testCreateViewSameGroupByClosure()
|
||||
{
|
||||
$groupBy = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -659,7 +659,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
{
|
||||
$groupBy1 = function () {};
|
||||
$groupBy2 = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view1 = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -678,7 +678,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
public function testCreateViewSameAttributes()
|
||||
{
|
||||
$attr = ['class' => 'foobar'];
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -711,7 +711,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
{
|
||||
$attr1 = ['class' => 'foobar1'];
|
||||
$attr2 = ['class' => 'foobar2'];
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view1 = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -730,7 +730,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
public function testCreateViewSameAttributesClosure()
|
||||
{
|
||||
$attr = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
@ -763,7 +763,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
||||
{
|
||||
$attr1 = function () {};
|
||||
$attr2 = function () {};
|
||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
|
||||
$view1 = new ChoiceListView();
|
||||
$view2 = new ChoiceListView();
|
||||
|
||||
|
@ -271,7 +271,7 @@ class DefaultChoiceListFactoryTest extends TestCase
|
||||
|
||||
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 () {};
|
||||
|
||||
$list = $this->factory->createListFromLoader($loader, null, $filter);
|
||||
|
@ -124,7 +124,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
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 = [
|
||||
'two' => (object) ['property' => 'value 2', 'filter' => true],
|
||||
];
|
||||
|
@ -273,7 +273,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
public function testAddThrowsExceptionIfAlreadySubmitted()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class);
|
||||
$this->form->submit([]);
|
||||
$this->form->add($this->getBuilder('foo')->getForm());
|
||||
}
|
||||
@ -290,7 +290,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
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->submit(['foo' => 'bar']);
|
||||
$this->form->remove('foo');
|
||||
@ -351,7 +351,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
->method('mapDataToForms')
|
||||
->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
|
||||
->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));
|
||||
});
|
||||
|
||||
@ -441,7 +441,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
->method('mapDataToForms')
|
||||
->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
|
||||
->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));
|
||||
});
|
||||
|
||||
@ -888,7 +888,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
$this->assertSame($error1, $errorsAsArray[0]);
|
||||
$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]);
|
||||
|
||||
@ -941,9 +941,9 @@ class CompoundFormTest extends AbstractFormTest
|
||||
// Basic cases are covered in SimpleFormTest
|
||||
public function testCreateViewWithChildren()
|
||||
{
|
||||
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||
$type1 = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||
$type2 = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||
$type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
|
||||
$type1 = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
|
||||
$type2 = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
|
||||
$options = ['a' => 'Foo', 'b' => 'Bar'];
|
||||
$field1 = $this->getBuilder('foo')
|
||||
->setType($type1)
|
||||
@ -997,7 +997,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
public function testNoClickedButton()
|
||||
{
|
||||
$button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton')
|
||||
$button = $this->getMockBuilder(\Symfony\Component\Form\SubmitButton::class)
|
||||
->setConstructorArgs([new SubmitButtonBuilder('submit')])
|
||||
->setMethods(['isClicked'])
|
||||
->getMock();
|
||||
@ -1019,7 +1019,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
public function testClickedButton()
|
||||
{
|
||||
$button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton')
|
||||
$button = $this->getMockBuilder(\Symfony\Component\Form\SubmitButton::class)
|
||||
->setConstructorArgs([new SubmitButtonBuilder('submit')])
|
||||
->setMethods(['isClicked'])
|
||||
->getMock();
|
||||
@ -1038,7 +1038,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
{
|
||||
$button = $this->getBuilder('submit')->getForm();
|
||||
|
||||
$nestedForm = $this->getMockBuilder('Symfony\Component\Form\Form')
|
||||
$nestedForm = $this->getMockBuilder(\Symfony\Component\Form\Form::class)
|
||||
->setConstructorArgs([$this->getBuilder('nested')])
|
||||
->setMethods(['getClickedButton'])
|
||||
->getMock();
|
||||
@ -1057,7 +1057,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
{
|
||||
$button = $this->getBuilder('submit')->getForm();
|
||||
|
||||
$parentForm = $this->getMockBuilder('Symfony\Component\Form\Form')
|
||||
$parentForm = $this->getMockBuilder(\Symfony\Component\Form\Form::class)
|
||||
->setConstructorArgs([$this->getBuilder('parent')])
|
||||
->setMethods(['getClickedButton'])
|
||||
->getMock();
|
||||
|
@ -222,7 +222,7 @@ class FormPassTest extends TestCase
|
||||
|
||||
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.');
|
||||
$container = $this->createContainerBuilder();
|
||||
|
||||
|
@ -230,7 +230,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
{
|
||||
$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');
|
||||
}
|
||||
@ -239,7 +239,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
{
|
||||
$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);
|
||||
}
|
||||
@ -262,7 +262,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
|
||||
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
||||
// Since we test against "de_DE", we need the full implementation
|
||||
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
|
||||
|
||||
@ -275,7 +275,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
|
||||
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
||||
// Since we test against "de_DE", we need the full implementation
|
||||
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
|
||||
|
||||
@ -317,7 +317,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
|
||||
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
||||
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
|
||||
|
||||
$transformer = new PercentToLocalizedStringTransformer(1, 'integer', \NumberFormatter::ROUND_HALFUP);
|
||||
@ -327,7 +327,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
|
||||
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
||||
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
|
||||
|
||||
$transformer = new PercentToLocalizedStringTransformer(1, 'integer', \NumberFormatter::ROUND_HALFUP);
|
||||
@ -341,7 +341,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, 1);
|
||||
$formatter->setAttribute(\NumberFormatter::GROUPING_USED, false);
|
||||
|
||||
$transformer = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer')
|
||||
$transformer = $this->getMockBuilder(PercentToLocalizedStringTransformer::class)
|
||||
->setMethods(['getNumberFormatter'])
|
||||
->setConstructorArgs([1, 'integer', \NumberFormatter::ROUND_HALFUP])
|
||||
->getMock();
|
||||
@ -355,7 +355,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
|
||||
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->reverseTransform('foo123');
|
||||
@ -363,7 +363,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
|
||||
public function testReverseTransformDisallowsCenteredExtraCharacters()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
||||
$this->expectExceptionMessage('The number contains unrecognized characters: "foo3"');
|
||||
$transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP);
|
||||
|
||||
@ -375,7 +375,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
*/
|
||||
public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
||||
$this->expectExceptionMessage('The number contains unrecognized characters: "foo8"');
|
||||
// Since we test against other locales, we need the full implementation
|
||||
IntlTestHelper::requireFullIntl($this, false);
|
||||
@ -389,7 +389,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
|
||||
public function testReverseTransformDisallowsTrailingExtraCharacters()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
||||
$this->expectExceptionMessage('The number contains unrecognized characters: "foo"');
|
||||
$transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP);
|
||||
|
||||
@ -401,7 +401,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
*/
|
||||
public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
|
||||
$this->expectExceptionMessage('The number contains unrecognized characters: "foo"');
|
||||
// Since we test against other locales, we need the full implementation
|
||||
IntlTestHelper::requireFullIntl($this, false);
|
||||
|
@ -343,7 +343,7 @@ class FormTypeTest extends BaseTypeTest
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ class NumberTypeTest extends BaseTypeTest
|
||||
|
||||
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->factory->create(static::TESTED_TYPE, 12345.6789, [
|
||||
@ -90,7 +90,7 @@ class NumberTypeTest extends BaseTypeTest
|
||||
|
||||
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->factory->create(static::TESTED_TYPE, 12345, [
|
||||
|
@ -476,7 +476,7 @@ class TimeTypeTest extends BaseTypeTest
|
||||
|
||||
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.');
|
||||
|
||||
$form = $this->factory->create(static::TESTED_TYPE, null, [
|
||||
|
@ -169,7 +169,7 @@ class TimezoneTypeTest extends BaseTypeTest
|
||||
|
||||
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->factory->create(static::TESTED_TYPE, null, [
|
||||
'choice_translation_locale' => 'uk',
|
||||
|
@ -26,8 +26,8 @@ class FormBuilderTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
|
||||
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
|
||||
$this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
|
||||
$this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
|
||||
$this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory);
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ class FormBuilderTest extends TestCase
|
||||
|
||||
public function testAddNameNoStringAndNoInteger()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
||||
$this->expectException(\Symfony\Component\Form\Exception\UnexpectedTypeException::class);
|
||||
$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->remove('foo');
|
||||
$form = $this->builder->getForm();
|
||||
$this->assertInstanceOf('Symfony\Component\Form\Form', $form);
|
||||
$this->assertInstanceOf(\Symfony\Component\Form\Form::class, $form);
|
||||
}
|
||||
|
||||
public function testCreateNoTypeNo()
|
||||
@ -156,7 +156,7 @@ class FormBuilderTest extends TestCase
|
||||
|
||||
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->builder->get('foo');
|
||||
@ -223,7 +223,7 @@ class FormBuilderTest extends TestCase
|
||||
|
||||
private function getFormBuilder($name = 'name')
|
||||
{
|
||||
$mock = $this->getMockBuilder('Symfony\Component\Form\FormBuilder')
|
||||
$mock = $this->getMockBuilder(FormBuilder::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
|
@ -53,10 +53,10 @@ class FormFactoryTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->guesser1 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock();
|
||||
$this->guesser2 = $this->getMockBuilder('Symfony\Component\Form\FormTypeGuesserInterface')->getMock();
|
||||
$this->registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock();
|
||||
$this->builder = $this->getMockBuilder('Symfony\Component\Form\Test\FormBuilderInterface')->getMock();
|
||||
$this->guesser1 = $this->getMockBuilder(\Symfony\Component\Form\FormTypeGuesserInterface::class)->getMock();
|
||||
$this->guesser2 = $this->getMockBuilder(\Symfony\Component\Form\FormTypeGuesserInterface::class)->getMock();
|
||||
$this->registry = $this->getMockBuilder(\Symfony\Component\Form\FormRegistryInterface::class)->getMock();
|
||||
$this->builder = $this->getMockBuilder(\Symfony\Component\Form\Test\FormBuilderInterface::class)->getMock();
|
||||
$this->factory = new FormFactory($this->registry);
|
||||
|
||||
$this->registry->expects($this->any())
|
||||
@ -155,7 +155,7 @@ class FormFactoryTest extends TestCase
|
||||
$resolvedOptions = ['a' => '2', 'b' => '3'];
|
||||
|
||||
// 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()
|
||||
->getMock();
|
||||
|
||||
@ -225,8 +225,8 @@ class FormFactoryTest extends TestCase
|
||||
|
||||
public function testCreateBuilderForPropertyWithoutTypeGuesser()
|
||||
{
|
||||
$registry = $this->getMockBuilder('Symfony\Component\Form\FormRegistryInterface')->getMock();
|
||||
$factory = $this->getMockBuilder('Symfony\Component\Form\FormFactory')
|
||||
$registry = $this->getMockBuilder(\Symfony\Component\Form\FormRegistryInterface::class)->getMock();
|
||||
$factory = $this->getMockBuilder(FormFactory::class)
|
||||
->setMethods(['createNamedBuilder'])
|
||||
->setConstructorArgs([$registry])
|
||||
->getMock();
|
||||
@ -463,7 +463,7 @@ class FormFactoryTest extends TestCase
|
||||
|
||||
private function getMockFactory(array $methods = [])
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Form\FormFactory')
|
||||
return $this->getMockBuilder(FormFactory::class)
|
||||
->setMethods($methods)
|
||||
->setConstructorArgs([$this->registry])
|
||||
->getMock();
|
||||
@ -471,6 +471,6 @@ class FormFactoryTest extends TestCase
|
||||
|
||||
private function getMockResolvedType()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||
return $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,14 @@ class FormRendererTest extends TestCase
|
||||
|
||||
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.');
|
||||
|
||||
$formView = new FormView();
|
||||
$formView->vars['name'] = 'foo';
|
||||
$formView->setRendered();
|
||||
|
||||
$engine = $this->getMockBuilder('Symfony\Component\Form\FormRendererEngineInterface')->getMock();
|
||||
$engine = $this->getMockBuilder(\Symfony\Component\Form\FormRendererEngineInterface::class)->getMock();
|
||||
$renderer = new FormRenderer($engine);
|
||||
$renderer->searchAndRenderBlock($formView, 'row');
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ class ResolvedFormTypeTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
|
||||
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
|
||||
$this->dataMapper = $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
|
||||
$this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
|
||||
$this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
|
||||
$this->dataMapper = $this->getMockBuilder(\Symfony\Component\Form\DataMapperInterface::class)->getMock();
|
||||
$this->parentType = $this->getMockFormType();
|
||||
$this->type = $this->getMockFormType();
|
||||
$this->extension1 = $this->getMockFormTypeExtension();
|
||||
@ -129,9 +129,9 @@ class ResolvedFormTypeTest extends TestCase
|
||||
{
|
||||
$givenOptions = ['a' => 'a_custom', 'c' => 'c_custom'];
|
||||
$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])
|
||||
->setMethods(['getOptionsResolver'])
|
||||
->getMock();
|
||||
@ -157,9 +157,9 @@ class ResolvedFormTypeTest extends TestCase
|
||||
{
|
||||
$givenOptions = ['data_class' => 'Foo'];
|
||||
$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])
|
||||
->setMethods(['getOptionsResolver'])
|
||||
->getMock();
|
||||
@ -183,7 +183,7 @@ class ResolvedFormTypeTest extends TestCase
|
||||
|
||||
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.');
|
||||
$optionsResolver = (new OptionsResolver())
|
||||
->setRequired('foo')
|
||||
@ -219,7 +219,7 @@ class ResolvedFormTypeTest extends TestCase
|
||||
};
|
||||
|
||||
$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
|
||||
$this->parentType->expects($this->once())
|
||||
@ -253,18 +253,18 @@ class ResolvedFormTypeTest extends TestCase
|
||||
|
||||
$view = $this->resolvedType->createView($form);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Form\FormView', $view);
|
||||
$this->assertInstanceOf(\Symfony\Component\Form\FormView::class, $view);
|
||||
$this->assertNull($view->parent);
|
||||
}
|
||||
|
||||
public function testCreateViewWithParent()
|
||||
{
|
||||
$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);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Form\FormView', $view);
|
||||
$this->assertInstanceOf(\Symfony\Component\Form\FormView::class, $view);
|
||||
$this->assertSame($parentView, $view->parent);
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ class ResolvedFormTypeTest extends TestCase
|
||||
{
|
||||
$options = ['a' => '1', 'b' => '2'];
|
||||
$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;
|
||||
|
||||
@ -314,7 +314,7 @@ class ResolvedFormTypeTest extends TestCase
|
||||
{
|
||||
$options = ['a' => '1', 'b' => '2'];
|
||||
$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;
|
||||
|
||||
@ -392,11 +392,11 @@ class ResolvedFormTypeTest extends TestCase
|
||||
|
||||
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
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
|
||||
return $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
|
||||
}
|
||||
}
|
||||
|
@ -193,28 +193,28 @@ class HttpClientTraitTest extends TestCase
|
||||
|
||||
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.');
|
||||
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS);
|
||||
}
|
||||
|
||||
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".');
|
||||
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => "a\nb"], HttpClientInterface::OPTIONS_DEFAULTS);
|
||||
}
|
||||
|
||||
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.');
|
||||
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => 'foo', 'auth_basic' => 'foo:bar'], HttpClientInterface::OPTIONS_DEFAULTS);
|
||||
}
|
||||
|
||||
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');
|
||||
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()
|
||||
{
|
||||
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cannot auto-detect fingerprint algorithm for "foo".');
|
||||
$this->normalizePeerFingerprint('foo');
|
||||
}
|
||||
|
||||
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.');
|
||||
$fingerprint = new \stdClass();
|
||||
|
||||
|
@ -52,7 +52,7 @@ class CookieTest extends TestCase
|
||||
*/
|
||||
public function testWithRawThrowsExceptionIfCookieNameContainsSpecialCharacters($name)
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
Cookie::create($name)->withRaw();
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ class JsonResponseTest extends TestCase
|
||||
{
|
||||
$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(204, $response->getStatusCode());
|
||||
}
|
||||
@ -108,7 +108,7 @@ class JsonResponseTest extends TestCase
|
||||
public function testStaticCreateEmptyJsonObject()
|
||||
{
|
||||
$response = JsonResponse::create();
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
||||
$this->assertInstanceOf(JsonResponse::class, $response);
|
||||
$this->assertSame('{}', $response->getContent());
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ class JsonResponseTest extends TestCase
|
||||
public function testStaticCreateJsonArray()
|
||||
{
|
||||
$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());
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ class JsonResponseTest extends TestCase
|
||||
public function testStaticCreateJsonObject()
|
||||
{
|
||||
$response = JsonResponse::create(['foo' => 'bar']);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
||||
$this->assertInstanceOf(JsonResponse::class, $response);
|
||||
$this->assertSame('{"foo":"bar"}', $response->getContent());
|
||||
}
|
||||
|
||||
@ -138,20 +138,20 @@ class JsonResponseTest extends TestCase
|
||||
public function testStaticCreateWithSimpleTypes()
|
||||
{
|
||||
$response = JsonResponse::create('foo');
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
||||
$this->assertInstanceOf(JsonResponse::class, $response);
|
||||
$this->assertSame('"foo"', $response->getContent());
|
||||
|
||||
$response = JsonResponse::create(0);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
||||
$this->assertInstanceOf(JsonResponse::class, $response);
|
||||
$this->assertSame('0', $response->getContent());
|
||||
|
||||
$response = JsonResponse::create(0.1);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
||||
$this->assertInstanceOf(JsonResponse::class, $response);
|
||||
$this->assertEquals(0.1, $response->getContent());
|
||||
$this->assertIsString($response->getContent());
|
||||
|
||||
$response = JsonResponse::create(true);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
||||
$this->assertInstanceOf(JsonResponse::class, $response);
|
||||
$this->assertSame('true', $response->getContent());
|
||||
}
|
||||
|
||||
@ -236,22 +236,22 @@ class JsonResponseTest extends TestCase
|
||||
|
||||
public function testSetCallbackInvalidIdentifier()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$response = new JsonResponse('foo');
|
||||
$response->setCallback('+invalid');
|
||||
}
|
||||
|
||||
public function testSetContent()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
new JsonResponse("\xB1\x31");
|
||||
}
|
||||
|
||||
public function testSetContentJsonSerializeError()
|
||||
{
|
||||
$this->expectException('Exception');
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage('This error is expected');
|
||||
if (!interface_exists('JsonSerializable', false)) {
|
||||
if (!interface_exists(\JsonSerializable::class, false)) {
|
||||
$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
|
||||
{
|
||||
public function jsonSerialize()
|
||||
|
@ -25,14 +25,14 @@ class RedirectResponseTest extends TestCase
|
||||
|
||||
public function testRedirectResponseConstructorEmptyUrl()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cannot redirect to an empty URL.');
|
||||
new RedirectResponse('');
|
||||
}
|
||||
|
||||
public function testRedirectResponseConstructorWrongStatusCode()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
new RedirectResponse('foo.bar', 404);
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ class RedirectResponseTest extends TestCase
|
||||
{
|
||||
$response = RedirectResponse::create('foo', 301);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
|
||||
$this->assertInstanceOf(RedirectResponse::class, $response);
|
||||
$this->assertEquals(301, $response->getStatusCode());
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class ResponseTest extends ResponseTestCase
|
||||
{
|
||||
$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('bar', $response->headers->get('foo'));
|
||||
}
|
||||
@ -614,7 +614,7 @@ class ResponseTest extends ResponseTestCase
|
||||
$response->setCache(['wrong option' => 'value']);
|
||||
$this->fail('->setCache() throws an InvalidArgumentException if an option is not supported');
|
||||
} 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());
|
||||
}
|
||||
|
||||
|
@ -71,14 +71,14 @@ class NativeSessionStorageTest extends TestCase
|
||||
|
||||
public function testRegisterBagException()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$storage = $this->getStorage();
|
||||
$storage->getBag('non_existing');
|
||||
}
|
||||
|
||||
public function testRegisterBagForAStartedSessionThrowsException()
|
||||
{
|
||||
$this->expectException('LogicException');
|
||||
$this->expectException(\LogicException::class);
|
||||
$storage = $this->getStorage();
|
||||
$storage->start();
|
||||
$storage->registerBag(new AttributeBag());
|
||||
@ -210,22 +210,22 @@ class NativeSessionStorageTest extends TestCase
|
||||
$this->iniSet('session.save_handler', 'files');
|
||||
$storage = $this->getStorage();
|
||||
$storage->setSaveHandler();
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
|
||||
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
|
||||
$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()));
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
|
||||
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
|
||||
$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()));
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
|
||||
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
|
||||
$storage->setSaveHandler(new NullSessionHandler());
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
|
||||
$this->assertInstanceOf(SessionHandlerProxy::class, $storage->getSaveHandler());
|
||||
}
|
||||
|
||||
public function testStarted()
|
||||
{
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$storage = $this->getStorage();
|
||||
|
||||
$this->assertFalse($storage->getSaveHandler()->isActive());
|
||||
|
@ -18,7 +18,7 @@ class FileLocatorTest extends TestCase
|
||||
{
|
||||
public function testLocate()
|
||||
{
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
|
||||
$kernel
|
||||
->expects($this->atLeastOnce())
|
||||
->method('locateResource')
|
||||
@ -30,7 +30,7 @@ class FileLocatorTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->never())
|
||||
->method('locateResource');
|
||||
$this->expectException('LogicException');
|
||||
$this->expectException(\LogicException::class);
|
||||
$locator->locate('/some/path');
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
{
|
||||
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.');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
@ -42,7 +42,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
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".');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
@ -57,7 +57,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
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".');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
@ -72,7 +72,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
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".');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
@ -87,7 +87,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
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".');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
@ -102,7 +102,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
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".');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
@ -197,7 +197,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
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?');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
@ -217,7 +217,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
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".');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
|
@ -23,7 +23,7 @@ class HIncludeFragmentRendererTest extends TestCase
|
||||
{
|
||||
public function testRenderExceptionWhenControllerAndNoSigner()
|
||||
{
|
||||
$this->expectException('LogicException');
|
||||
$this->expectException(\LogicException::class);
|
||||
$strategy = new HIncludeFragmentRenderer();
|
||||
$strategy->render(new ControllerReference('main_controller', [], []), Request::create('/'));
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class ConnectionTest extends TestCase
|
||||
|
||||
public function testItThrowsATransportExceptionIfItCannotAcknowledgeMessage()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Messenger\Exception\TransportException');
|
||||
$this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class);
|
||||
$driverConnection = $this->getDBALConnectionMock();
|
||||
|
||||
if (class_exists(Exception::class)) {
|
||||
@ -108,7 +108,7 @@ class ConnectionTest extends TestCase
|
||||
|
||||
public function testItThrowsATransportExceptionIfItCannotRejectMessage()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Messenger\Exception\TransportException');
|
||||
$this->expectException(\Symfony\Component\Messenger\Exception\TransportException::class);
|
||||
$driverConnection = $this->getDBALConnectionMock();
|
||||
|
||||
if (class_exists(Exception::class)) {
|
||||
@ -257,14 +257,14 @@ class ConnectionTest extends TestCase
|
||||
|
||||
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]');
|
||||
Connection::buildConfiguration('doctrine://default', ['new_option' => 'woops']);
|
||||
}
|
||||
|
||||
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]');
|
||||
Connection::buildConfiguration('doctrine://default?new_option=woops');
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class HandleTraitTest extends TestCase
|
||||
{
|
||||
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.');
|
||||
$queryBus = new TestQueryBus(null);
|
||||
$query = new DummyMessage('Hello');
|
||||
@ -48,7 +48,7 @@ class HandleTraitTest extends TestCase
|
||||
|
||||
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()".');
|
||||
$bus = $this->createMock(MessageBus::class);
|
||||
$queryBus = new TestQueryBus($bus);
|
||||
@ -61,7 +61,7 @@ class HandleTraitTest extends TestCase
|
||||
|
||||
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".');
|
||||
$bus = $this->createMock(MessageBus::class);
|
||||
$queryBus = new TestQueryBus($bus);
|
||||
|
@ -37,7 +37,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefault('z', '1');
|
||||
$this->resolver->setDefault('a', '2');
|
||||
@ -47,7 +47,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefault('z', '1');
|
||||
$this->resolver->setDefault('a', '2');
|
||||
@ -57,7 +57,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->resolve([]);
|
||||
});
|
||||
@ -83,7 +83,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailIfSetDefaultFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('lazy', function (Options $options) {
|
||||
$options->setDefault('default', 42);
|
||||
});
|
||||
@ -225,7 +225,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailIfSetRequiredFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->setRequired('bar');
|
||||
});
|
||||
@ -235,7 +235,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsIfRequiredOptionMissing()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException');
|
||||
$this->expectException(\Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class);
|
||||
$this->resolver->setRequired('foo');
|
||||
|
||||
$this->resolver->resolve();
|
||||
@ -349,7 +349,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailIfSetDefinedFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->setDefined('bar');
|
||||
});
|
||||
@ -444,7 +444,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailIfSetDeprecatedFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver
|
||||
->setDefault('bar', 'baz')
|
||||
->setDefault('foo', function (Options $options) {
|
||||
@ -456,13 +456,13 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testSetDeprecatedFailsIfUnknownOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
|
||||
$this->expectException(UndefinedOptionsException::class);
|
||||
$this->resolver->setDeprecated('foo');
|
||||
}
|
||||
|
||||
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->resolver
|
||||
->setDefined('foo')
|
||||
@ -472,7 +472,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver
|
||||
->setDefined('foo')
|
||||
@ -485,7 +485,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver
|
||||
->setDefined(['foo', 'bar'])
|
||||
@ -756,7 +756,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testSetAllowedTypesFailsIfUnknownOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
|
||||
$this->expectException(UndefinedOptionsException::class);
|
||||
$this->resolver->setAllowedTypes('foo', 'string');
|
||||
}
|
||||
|
||||
@ -771,7 +771,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailIfSetAllowedTypesFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->setAllowedTypes('bar', 'string');
|
||||
});
|
||||
@ -783,7 +783,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'int[]');
|
||||
@ -793,7 +793,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'int[]');
|
||||
@ -803,7 +803,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'int[]');
|
||||
@ -818,7 +818,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'int[][]');
|
||||
@ -838,7 +838,7 @@ class OptionsResolverTest extends TestCase
|
||||
$this->resolver->setDefined('option');
|
||||
$this->resolver->setAllowedTypes('option', $allowedType);
|
||||
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
|
||||
$this->resolver->resolve(['option' => $actualType]);
|
||||
@ -873,7 +873,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefault('foo', 42);
|
||||
$this->resolver->setAllowedTypes('foo', ['string', 'bool']);
|
||||
@ -914,7 +914,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsIfNotInstanceOfClass()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 'bar');
|
||||
$this->resolver->setAllowedTypes('foo', '\stdClass');
|
||||
|
||||
@ -923,13 +923,13 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testAddAllowedTypesFailsIfUnknownOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
|
||||
$this->expectException(UndefinedOptionsException::class);
|
||||
$this->resolver->addAllowedTypes('foo', 'string');
|
||||
}
|
||||
|
||||
public function testFailIfAddAllowedTypesFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->addAllowedTypes('bar', 'string');
|
||||
});
|
||||
@ -941,7 +941,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsIfInvalidAddedType()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 42);
|
||||
$this->resolver->addAllowedTypes('foo', 'string');
|
||||
|
||||
@ -958,7 +958,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsIfInvalidAddedTypeMultiple()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 42);
|
||||
$this->resolver->addAllowedTypes('foo', ['string', 'bool']);
|
||||
|
||||
@ -997,13 +997,13 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testSetAllowedValuesFailsIfUnknownOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
|
||||
$this->expectException(UndefinedOptionsException::class);
|
||||
$this->resolver->setAllowedValues('foo', 'bar');
|
||||
}
|
||||
|
||||
public function testFailIfSetAllowedValuesFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->setAllowedValues('bar', 'baz');
|
||||
});
|
||||
@ -1015,7 +1015,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedValues('foo', 'bar');
|
||||
@ -1025,7 +1025,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefault('foo', null);
|
||||
$this->resolver->setAllowedValues('foo', 'bar');
|
||||
@ -1035,7 +1035,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsIfInvalidValueStrict()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 42);
|
||||
$this->resolver->setAllowedValues('foo', '42');
|
||||
|
||||
@ -1060,7 +1060,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefault('foo', 42);
|
||||
$this->resolver->setAllowedValues('foo', ['bar', false, null]);
|
||||
@ -1109,7 +1109,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsIfAllClosuresReturnFalse()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 42);
|
||||
$this->resolver->setAllowedValues('foo', [
|
||||
function () { return false; },
|
||||
@ -1134,13 +1134,13 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testAddAllowedValuesFailsIfUnknownOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
|
||||
$this->expectException(UndefinedOptionsException::class);
|
||||
$this->resolver->addAllowedValues('foo', 'bar');
|
||||
}
|
||||
|
||||
public function testFailIfAddAllowedValuesFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->addAllowedValues('bar', 'baz');
|
||||
});
|
||||
@ -1152,7 +1152,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsIfInvalidAddedValue()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 42);
|
||||
$this->resolver->addAllowedValues('foo', 'bar');
|
||||
|
||||
@ -1177,7 +1177,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsIfInvalidAddedValueMultiple()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 42);
|
||||
$this->resolver->addAllowedValues('foo', ['bar', 'baz']);
|
||||
|
||||
@ -1212,7 +1212,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testResolveFailsIfAllAddedClosuresReturnFalse()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 42);
|
||||
$this->resolver->setAllowedValues('foo', function () { return false; });
|
||||
$this->resolver->addAllowedValues('foo', function () { return false; });
|
||||
@ -1256,13 +1256,13 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testSetNormalizerFailsIfUnknownOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
|
||||
$this->expectException(UndefinedOptionsException::class);
|
||||
$this->resolver->setNormalizer('foo', function () {});
|
||||
}
|
||||
|
||||
public function testFailIfSetNormalizerFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->setNormalizer('foo', function () {});
|
||||
});
|
||||
@ -1298,7 +1298,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testValidateTypeBeforeNormalization()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 'bar');
|
||||
|
||||
$this->resolver->setAllowedTypes('foo', 'int');
|
||||
@ -1312,7 +1312,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testValidateValueBeforeNormalization()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectException(InvalidOptionsException::class);
|
||||
$this->resolver->setDefault('foo', 'bar');
|
||||
|
||||
$this->resolver->setAllowedValues('foo', 'baz');
|
||||
@ -1364,7 +1364,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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('norm2', 'baz');
|
||||
|
||||
@ -1381,7 +1381,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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) {
|
||||
$options['norm'];
|
||||
});
|
||||
@ -1527,13 +1527,13 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testAddNormalizerFailsIfUnknownOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
|
||||
$this->expectException(UndefinedOptionsException::class);
|
||||
$this->resolver->addNormalizer('foo', function () {});
|
||||
}
|
||||
|
||||
public function testFailIfAddNormalizerFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->addNormalizer('foo', function () {});
|
||||
});
|
||||
@ -1565,7 +1565,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailIfSetDefaultsFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->setDefaults(['two' => '2']);
|
||||
});
|
||||
@ -1644,7 +1644,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailIfRemoveFromLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->remove('bar');
|
||||
});
|
||||
@ -1718,7 +1718,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailIfClearFromLazyption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', function (Options $options) {
|
||||
$options->clear();
|
||||
});
|
||||
@ -1775,7 +1775,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testArrayAccessGetFailsOutsideResolve()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('default', 0);
|
||||
|
||||
$this->resolver['default'];
|
||||
@ -1783,7 +1783,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testArrayAccessExistsFailsOutsideResolve()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('default', 0);
|
||||
|
||||
isset($this->resolver['default']);
|
||||
@ -1791,13 +1791,13 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testArrayAccessSetNotSupported()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver['default'] = 0;
|
||||
}
|
||||
|
||||
public function testArrayAccessUnsetNotSupported()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('default', 0);
|
||||
|
||||
unset($this->resolver['default']);
|
||||
@ -1805,7 +1805,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefault('foo', 'bar');
|
||||
|
||||
@ -1818,7 +1818,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('defined');
|
||||
|
||||
@ -1831,7 +1831,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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) {
|
||||
$options['lazy2'];
|
||||
});
|
||||
@ -1864,7 +1864,7 @@ class OptionsResolverTest extends TestCase
|
||||
*/
|
||||
public function testCountFailsOutsideResolve()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
|
||||
$this->expectException(AccessException::class);
|
||||
$this->resolver->setDefault('foo', 0);
|
||||
$this->resolver->setRequired('bar');
|
||||
$this->resolver->setDefined('bar');
|
||||
@ -1921,7 +1921,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'float[][][][]');
|
||||
@ -1939,7 +1939,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'int[][]');
|
||||
@ -1952,7 +1952,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'int[][]');
|
||||
@ -1965,7 +1965,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'string[][][]');
|
||||
@ -1978,7 +1978,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'string[][][]');
|
||||
@ -1992,7 +1992,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefined('foo');
|
||||
$this->resolver->setAllowedTypes('foo', 'string[]');
|
||||
@ -2016,7 +2016,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefaults([
|
||||
'name' => 'default',
|
||||
@ -2031,7 +2031,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefaults([
|
||||
'name' => 'default',
|
||||
@ -2046,7 +2046,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefaults([
|
||||
'name' => 'default',
|
||||
@ -2063,7 +2063,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->setDefaults([
|
||||
'name' => 'default',
|
||||
@ -2270,7 +2270,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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) {
|
||||
$resolver->setDefault('replicas', $parent['database']);
|
||||
});
|
||||
@ -2279,7 +2279,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailsIfCyclicDependencyBetweenNestedOptionAndParentLazyOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
|
||||
$this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
|
||||
$this->resolver->setDefaults([
|
||||
'version' => function (Options $options) {
|
||||
return $options['database']['server_version'];
|
||||
@ -2293,7 +2293,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
public function testFailsIfCyclicDependencyBetweenNormalizerAndNestedOption()
|
||||
{
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
|
||||
$this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class);
|
||||
$this->resolver
|
||||
->setDefault('name', 'default')
|
||||
->setDefault('database', function (OptionsResolver $resolver, Options $parent) {
|
||||
@ -2307,7 +2307,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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) {
|
||||
$resolver->setDefault('host', $parent['replica']['host']);
|
||||
});
|
||||
@ -2400,7 +2400,7 @@ class OptionsResolverTest extends TestCase
|
||||
|
||||
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->resolver->define('foo');
|
||||
$this->resolver->define('foo');
|
||||
|
@ -684,7 +684,7 @@ class PropertyAccessor implements PropertyAccessorInterface
|
||||
*/
|
||||
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__));
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
|
||||
|
||||
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_[^"]*"./');
|
||||
$car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock();
|
||||
$axesBefore = $this->getContainer([1 => 'second', 3 => 'fourth']);
|
||||
@ -187,7 +187,7 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
|
||||
|
||||
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\./');
|
||||
$car = new PropertyAccessorCollectionTest_Car();
|
||||
|
||||
|
@ -26,7 +26,7 @@ class RouterTest extends TestCase
|
||||
|
||||
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->cacheDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('router_', true);
|
||||
@ -59,7 +59,7 @@ class RouterTest extends TestCase
|
||||
|
||||
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->router->setOptions([
|
||||
'cache_dir' => './cache',
|
||||
@ -78,14 +78,14 @@ class RouterTest extends TestCase
|
||||
|
||||
public function testSetOptionWithUnsupportedOption()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('The Router does not support the "option_foo" option');
|
||||
$this->router->setOption('option_foo', true);
|
||||
}
|
||||
|
||||
public function testGetOptionWithUnsupportedOption()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('The Router does not support the "option_foo" option');
|
||||
$this->router->getOption('option_foo', true);
|
||||
}
|
||||
@ -111,7 +111,7 @@ class RouterTest extends TestCase
|
||||
->method('load')->with('routing.yml', null)
|
||||
->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()
|
||||
@ -122,12 +122,12 @@ class RouterTest extends TestCase
|
||||
->method('load')->with('routing.yml', null)
|
||||
->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()
|
||||
{
|
||||
$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');
|
||||
|
||||
$p = new \ReflectionProperty($this->router, 'matcher');
|
||||
@ -139,7 +139,7 @@ class RouterTest extends TestCase
|
||||
|
||||
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');
|
||||
|
||||
$p = new \ReflectionProperty($this->router, 'matcher');
|
||||
@ -161,7 +161,7 @@ class RouterTest extends TestCase
|
||||
|
||||
$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->setAccessible(true);
|
||||
@ -181,7 +181,7 @@ class RouterTest extends TestCase
|
||||
|
||||
$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->setAccessible(true);
|
||||
|
@ -25,7 +25,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
{
|
||||
public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationServiceException::class);
|
||||
$provider = $this->getProvider('fabien');
|
||||
$method = new \ReflectionMethod($provider, 'retrieveUser');
|
||||
$method->setAccessible(true);
|
||||
@ -35,14 +35,14 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
public function testRetrieveUserWhenUsernameIsNotFound()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
|
||||
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
|
||||
$this->expectException(UsernameNotFoundException::class);
|
||||
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
|
||||
$userProvider->expects($this->once())
|
||||
->method('loadUserByUsername')
|
||||
->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->setAccessible(true);
|
||||
|
||||
@ -51,14 +51,14 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
public function testRetrieveUserWhenAnExceptionOccurs()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
||||
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationServiceException::class);
|
||||
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
|
||||
$userProvider->expects($this->once())
|
||||
->method('loadUserByUsername')
|
||||
->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->setAccessible(true);
|
||||
|
||||
@ -67,7 +67,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
public function testRetrieveUserReturnsUserFromTokenOnReauthentication()
|
||||
{
|
||||
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
|
||||
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
|
||||
$userProvider->expects($this->never())
|
||||
->method('loadUserByUsername')
|
||||
;
|
||||
@ -79,7 +79,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
->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->setAccessible(true);
|
||||
$result = $reflection->invoke($provider, 'someUser', $token);
|
||||
@ -91,13 +91,13 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
{
|
||||
$user = new TestUser();
|
||||
|
||||
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
|
||||
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
|
||||
$userProvider->expects($this->once())
|
||||
->method('loadUserByUsername')
|
||||
->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->setAccessible(true);
|
||||
|
||||
@ -106,8 +106,8 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
public function testCheckAuthenticationWhenCredentialsAreEmpty()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
|
||||
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
|
||||
$encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock();
|
||||
$encoder
|
||||
->expects($this->never())
|
||||
->method('isPasswordValid')
|
||||
@ -129,7 +129,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
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
|
||||
->expects($this->once())
|
||||
->method('isPasswordValid')
|
||||
@ -156,8 +156,8 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
public function testCheckAuthenticationWhenCredentialsAreNotValid()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
|
||||
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
|
||||
$encoder = $this->getMockBuilder(\Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::class)->getMock();
|
||||
$encoder->expects($this->once())
|
||||
->method('isPasswordValid')
|
||||
->willReturn(false)
|
||||
@ -178,8 +178,8 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
|
||||
$user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
|
||||
$user = $this->getMockBuilder(UserInterface::class)->getMock();
|
||||
$user->expects($this->once())
|
||||
->method('getPassword')
|
||||
->willReturn('foo')
|
||||
@ -190,7 +190,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
->method('getUser')
|
||||
->willReturn($user);
|
||||
|
||||
$dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
|
||||
$dbUser = $this->getMockBuilder(UserInterface::class)->getMock();
|
||||
$dbUser->expects($this->once())
|
||||
->method('getPassword')
|
||||
->willReturn('newFoo')
|
||||
@ -204,7 +204,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithoutOriginalCredentials()
|
||||
{
|
||||
$user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
|
||||
$user = $this->getMockBuilder(UserInterface::class)->getMock();
|
||||
$user->expects($this->once())
|
||||
->method('getPassword')
|
||||
->willReturn('foo')
|
||||
@ -215,7 +215,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
->method('getUser')
|
||||
->willReturn($user);
|
||||
|
||||
$dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
|
||||
$dbUser = $this->getMockBuilder(UserInterface::class)->getMock();
|
||||
$dbUser->expects($this->once())
|
||||
->method('getPassword')
|
||||
->willReturn('foo')
|
||||
@ -229,7 +229,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
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())
|
||||
->method('isPasswordValid')
|
||||
->willReturn(true)
|
||||
@ -288,7 +288,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
|
||||
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
|
||||
->expects($this->any())
|
||||
->method('getProviderKey')
|
||||
@ -309,14 +309,14 @@ class DaoAuthenticationProviderTest extends TestCase
|
||||
}
|
||||
|
||||
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) {
|
||||
$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
|
||||
->expects($this->any())
|
||||
->method('getEncoder')
|
||||
|
@ -26,7 +26,7 @@ class AbstractTokenTest extends TestCase
|
||||
$token->setUser(new TestUser('fabien'));
|
||||
$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');
|
||||
$token->setUser($user);
|
||||
$this->assertEquals('fabien', $token->getUsername());
|
||||
@ -36,7 +36,7 @@ class AbstractTokenTest extends TestCase
|
||||
{
|
||||
$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');
|
||||
$token->setUser($user);
|
||||
|
||||
@ -106,7 +106,7 @@ class AbstractTokenTest extends TestCase
|
||||
|
||||
public function getUsers()
|
||||
{
|
||||
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
|
||||
$user = $this->getMockBuilder(UserInterface::class)->getMock();
|
||||
|
||||
return [
|
||||
[$user],
|
||||
@ -133,7 +133,7 @@ class AbstractTokenTest extends TestCase
|
||||
|
||||
public function getUserChanges()
|
||||
{
|
||||
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
|
||||
$user = $this->getMockBuilder(UserInterface::class)->getMock();
|
||||
|
||||
return [
|
||||
['foo', 'bar'],
|
||||
|
@ -22,7 +22,7 @@ class AccessDecisionManagerTest extends TestCase
|
||||
|
||||
public function testSetUnsupportedStrategy()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
new AccessDecisionManager([$this->getVoter(VoterInterface::ACCESS_GRANTED)], 'fooBar');
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ class AccessDecisionManagerTest extends TestCase
|
||||
*/
|
||||
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);
|
||||
|
||||
$this->assertSame($expected, $manager->decide($token, ['ROLE_FOO']));
|
||||
@ -137,7 +137,7 @@ class AccessDecisionManagerTest extends TestCase
|
||||
|
||||
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())
|
||||
->method('vote')
|
||||
->willReturn($vote);
|
||||
|
@ -64,13 +64,13 @@ class AuthenticatedVoterTest extends TestCase
|
||||
protected function getToken($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) {
|
||||
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) {
|
||||
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 {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class ExpressionVoterTest extends TestCase
|
||||
|
||||
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) {
|
||||
$mock->expects($this->once())
|
||||
@ -70,7 +70,7 @@ class ExpressionVoterTest extends TestCase
|
||||
|
||||
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()
|
||||
@ -80,7 +80,7 @@ class ExpressionVoterTest extends TestCase
|
||||
|
||||
protected function createExpression()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\ExpressionLanguage\Expression')
|
||||
return $this->getMockBuilder(\Symfony\Component\ExpressionLanguage\Expression::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class VoterTest extends TestCase
|
||||
|
||||
public function testVoteWithTypeError()
|
||||
{
|
||||
$this->expectException('TypeError');
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->expectExceptionMessage('Should error');
|
||||
$voter = new TypeErrorVoterTest_Voter();
|
||||
$voter->vote($this->token, new \stdClass(), ['EDIT']);
|
||||
|
@ -21,7 +21,7 @@ class UserCheckerTest extends TestCase
|
||||
{
|
||||
$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()
|
||||
@ -32,28 +32,28 @@ class UserCheckerTest extends TestCase
|
||||
|
||||
public function testCheckPostAuthCredentialsExpired()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\CredentialsExpiredException');
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\CredentialsExpiredException::class);
|
||||
$checker = new UserChecker();
|
||||
$checker->checkPostAuth(new User('John', 'password', [], true, true, false, true));
|
||||
}
|
||||
|
||||
public function testCheckPreAuthAccountLocked()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\LockedException');
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\LockedException::class);
|
||||
$checker = new UserChecker();
|
||||
$checker->checkPreAuth(new User('John', 'password', [], true, true, false, false));
|
||||
}
|
||||
|
||||
public function testCheckPreAuthDisabled()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\DisabledException');
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\DisabledException::class);
|
||||
$checker = new UserChecker();
|
||||
$checker->checkPreAuth(new User('John', 'password', [], false, true, false, true));
|
||||
}
|
||||
|
||||
public function testCheckPreAuthAccountExpired()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\AccountExpiredException');
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\AccountExpiredException::class);
|
||||
$checker = new UserChecker();
|
||||
$checker->checkPreAuth(new User('John', 'password', [], true, false, true, true));
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class CsrfTokenManagerTest extends TestCase
|
||||
|
||||
$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', $token->getValue());
|
||||
}
|
||||
@ -64,7 +64,7 @@ class CsrfTokenManagerTest extends TestCase
|
||||
|
||||
$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', $token->getValue());
|
||||
}
|
||||
@ -87,7 +87,7 @@ class CsrfTokenManagerTest extends TestCase
|
||||
|
||||
$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', $token->getValue());
|
||||
}
|
||||
@ -159,9 +159,9 @@ class CsrfTokenManagerTest extends TestCase
|
||||
|
||||
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');
|
||||
$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->push(new Request([], [], [], [], [], ['HTTPS' => 'on']));
|
||||
@ -207,8 +207,8 @@ class CsrfTokenManagerTest extends TestCase
|
||||
private function getGeneratorAndStorage(): array
|
||||
{
|
||||
return [
|
||||
$this->getMockBuilder('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface')->getMock(),
|
||||
$this->getMockBuilder('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface')->getMock(),
|
||||
$this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface::class)->getMock(),
|
||||
$this->getMockBuilder(\Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface::class)->getMock(),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -121,12 +121,12 @@ class GuardAuthenticationProviderTest extends TestCase
|
||||
|
||||
public function testGuardWithNoLongerAuthenticatedTriggersLogout()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationExpiredException');
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationExpiredException::class);
|
||||
$providerKey = 'my_firewall_abc';
|
||||
|
||||
// create a token and mark it as NOT authenticated anymore
|
||||
// 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->setAuthenticated(false);
|
||||
|
||||
@ -140,7 +140,7 @@ class GuardAuthenticationProviderTest extends TestCase
|
||||
$authenticatorB = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
|
||||
$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);
|
||||
|
||||
$token = new PreAuthenticationGuardToken($mockedUser, 'first_firewall_1');
|
||||
@ -154,12 +154,12 @@ class GuardAuthenticationProviderTest extends TestCase
|
||||
|
||||
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/');
|
||||
$authenticatorA = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
|
||||
$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);
|
||||
|
||||
$token = new PreAuthenticationGuardToken($mockedUser, 'second_firewall_0');
|
||||
@ -168,9 +168,9 @@ class GuardAuthenticationProviderTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
|
||||
$this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
|
||||
$this->preAuthenticationToken = $this->getMockBuilder('Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken')
|
||||
$this->userProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock();
|
||||
$this->userChecker = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserCheckerInterface::class)->getMock();
|
||||
$this->preAuthenticationToken = $this->getMockBuilder(PreAuthenticationGuardToken::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class SessionStrategyListenerTest extends TestCase
|
||||
|
||||
private function configurePreviousSession()
|
||||
{
|
||||
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
|
||||
$session = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)->getMock();
|
||||
$session->expects($this->any())
|
||||
->method('getName')
|
||||
->willReturn('test_session_name');
|
||||
|
@ -121,7 +121,7 @@ class LogoutListenerTest extends TestCase
|
||||
|
||||
public function testNoResponseSet()
|
||||
{
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
[$listener, , $httpUtils, $options] = $this->getListener();
|
||||
|
||||
@ -137,7 +137,7 @@ class LogoutListenerTest extends TestCase
|
||||
|
||||
public function testCsrfValidationFails()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\LogoutException');
|
||||
$this->expectException(\Symfony\Component\Security\Core\Exception\LogoutException::class);
|
||||
$tokenManager = $this->getTokenManager();
|
||||
|
||||
[$listener, , $httpUtils, $options] = $this->getListener(null, $tokenManager);
|
||||
@ -194,12 +194,12 @@ class LogoutListenerTest extends TestCase
|
||||
|
||||
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()
|
||||
{
|
||||
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()
|
||||
@ -217,7 +217,7 @@ class LogoutListenerTest extends TestCase
|
||||
|
||||
private function getHttpUtils()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')
|
||||
return $this->getMockBuilder(\Symfony\Component\Security\Http\HttpUtils::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
@ -247,6 +247,6 @@ class LogoutListenerTest extends TestCase
|
||||
|
||||
private function getToken()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
|
||||
return $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,13 @@
|
||||
namespace Symfony\Component\Security\Http\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Http\Firewall;
|
||||
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
|
||||
use Symfony\Component\Security\Http\FirewallMapInterface;
|
||||
|
||||
class FirewallTest extends TestCase
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
$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
|
||||
->expects($this->once())
|
||||
->method('loadTokenBySeries')
|
||||
@ -81,7 +81,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
$request = new Request();
|
||||
$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
|
||||
->expects($this->once())
|
||||
->method('loadTokenBySeries')
|
||||
@ -106,7 +106,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
$request = new Request();
|
||||
$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);
|
||||
|
||||
$tokenProvider
|
||||
@ -137,7 +137,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
$request = new Request();
|
||||
$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
|
||||
->expects($this->once())
|
||||
->method('loadTokenBySeries')
|
||||
@ -156,7 +156,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
*/
|
||||
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
|
||||
->expects($this->once())
|
||||
->method('getRoles')
|
||||
@ -175,7 +175,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
$request = new Request();
|
||||
$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';
|
||||
$tokenProvider
|
||||
->expects($this->once())
|
||||
@ -187,7 +187,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
|
||||
$returnedToken = $service->autoLogin($request);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', $returnedToken);
|
||||
$this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::class, $returnedToken);
|
||||
$this->assertSame($user, $returnedToken->getUser());
|
||||
$this->assertEquals('foosecret', $returnedToken->getSecret());
|
||||
$this->assertTrue($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME));
|
||||
@ -199,9 +199,9 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
$request = new Request();
|
||||
$request->cookies->set('foo', $this->encodeCookie(['fooseries', 'foovalue']));
|
||||
$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
|
||||
->expects($this->once())
|
||||
->method('deleteTokenBySeries')
|
||||
@ -225,9 +225,9 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
$service = $this->getService(null, ['name' => 'foo', 'path' => null, 'domain' => null]);
|
||||
$request = new Request();
|
||||
$response = new Response();
|
||||
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
|
||||
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
|
||||
|
||||
$tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock();
|
||||
$tokenProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface::class)->getMock();
|
||||
$tokenProvider
|
||||
->expects($this->never())
|
||||
->method('deleteTokenBySeries')
|
||||
@ -248,9 +248,9 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
$request = new Request();
|
||||
$request->cookies->set('foo', 'somefoovalue');
|
||||
$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
|
||||
->expects($this->never())
|
||||
->method('deleteTokenBySeries')
|
||||
@ -278,20 +278,20 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
$request = new Request();
|
||||
$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
|
||||
->expects($this->once())
|
||||
->method('getUsername')
|
||||
->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
|
||||
->expects($this->any())
|
||||
->method('getUser')
|
||||
->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
|
||||
->expects($this->once())
|
||||
->method('createNewToken')
|
||||
@ -334,7 +334,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
||||
|
||||
protected function getProvider()
|
||||
{
|
||||
$provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
|
||||
$provider = $this->getMockBuilder(\Symfony\Component\Security\Core\User\UserProviderInterface::class)->getMock();
|
||||
$provider
|
||||
->expects($this->any())
|
||||
->method('supportsClass')
|
||||
|
@ -68,7 +68,7 @@ class JsonSerializableNormalizerTest extends TestCase
|
||||
|
||||
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->serializer
|
||||
@ -86,7 +86,7 @@ class JsonSerializableNormalizerTest extends TestCase
|
||||
|
||||
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->normalizer->normalize(new \stdClass());
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class UnwrappinDenormalizerTest extends TestCase
|
||||
|
||||
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->setSerializer($this->serializer);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class SerializerTest extends TestCase
|
||||
|
||||
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".');
|
||||
|
||||
new Serializer([new \stdClass()]);
|
||||
@ -74,7 +74,7 @@ class SerializerTest extends TestCase
|
||||
|
||||
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"');
|
||||
|
||||
new Serializer([], [new \stdClass()]);
|
||||
|
@ -19,7 +19,7 @@ class LoggingTranslatorTest extends TestCase
|
||||
{
|
||||
public function testTransWithNoTranslationIsLogged()
|
||||
{
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
|
||||
$logger->expects($this->exactly(1))
|
||||
->method('warning')
|
||||
->with('Translation not found.')
|
||||
|
@ -37,7 +37,7 @@ class TranslatorTest extends TestCase
|
||||
*/
|
||||
public function testConstructorInvalidLocale($locale)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
|
||||
$this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
|
||||
new Translator($locale);
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ class TranslatorTest extends TestCase
|
||||
*/
|
||||
public function testSetInvalidLocale($locale)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
|
||||
$this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
|
||||
$translator = new Translator('fr');
|
||||
$translator->setLocale($locale);
|
||||
}
|
||||
@ -149,7 +149,7 @@ class TranslatorTest extends TestCase
|
||||
*/
|
||||
public function testSetFallbackInvalidLocales($locale)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
|
||||
$this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
|
||||
$translator = new Translator('fr');
|
||||
$translator->setFallbackLocales(['fr', $locale]);
|
||||
}
|
||||
@ -181,7 +181,7 @@ class TranslatorTest extends TestCase
|
||||
*/
|
||||
public function testAddResourceInvalidLocales($locale)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
|
||||
$this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
|
||||
$translator = new Translator('fr');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], $locale);
|
||||
}
|
||||
@ -216,7 +216,7 @@ class TranslatorTest extends TestCase
|
||||
*/
|
||||
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;
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader($format, new $loaderClass());
|
||||
@ -332,7 +332,7 @@ class TranslatorTest extends TestCase
|
||||
|
||||
public function testWhenAResourceHasNoRegisteredLoader()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Translation\Exception\RuntimeException');
|
||||
$this->expectException(RuntimeException::class);
|
||||
$translator = new Translator('en');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
|
||||
|
||||
@ -398,7 +398,7 @@ class TranslatorTest extends TestCase
|
||||
*/
|
||||
public function testTransInvalidLocale($locale)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
|
||||
$this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class);
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Translation\Tests\Writer;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Translation\Dumper\DumperInterface;
|
||||
use Symfony\Component\Translation\MessageCatalogue;
|
||||
use Symfony\Component\Translation\Writer\TranslationWriter;
|
||||
|
||||
|
@ -112,7 +112,7 @@ abstract class ConstraintValidatorTestCase extends TestCase
|
||||
{
|
||||
$translator = $this->getMockBuilder(TranslatorInterface::class)->getMock();
|
||||
$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())
|
||||
->method('validate')
|
||||
->willReturnCallback(function () {
|
||||
|
@ -22,7 +22,7 @@ class AtLeastOneOfTest extends TestCase
|
||||
{
|
||||
public function testRejectNonConstraints()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
|
||||
new AtLeastOneOf([
|
||||
'foo',
|
||||
]);
|
||||
@ -30,7 +30,7 @@ class AtLeastOneOfTest extends TestCase
|
||||
|
||||
public function testRejectValidConstraint()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
|
||||
new AtLeastOneOf([
|
||||
new Valid(),
|
||||
]);
|
||||
|
@ -57,7 +57,7 @@ class LengthValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
|
||||
$this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
|
||||
$this->validator->validate(new \stdClass(), new Length(['value' => 5]));
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class LocaleValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
|
||||
$this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
|
||||
$this->validator->validate(new \stdClass(), new Locale());
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class UrlValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testExpectsStringCompatibleType()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
|
||||
$this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
|
||||
$this->validator->validate(new \stdClass(), new Url());
|
||||
}
|
||||
|
||||
|
@ -108,9 +108,9 @@ class LazyLoadingMetadataFactoryTest extends TestCase
|
||||
|
||||
public function testNonClassNameStringValues()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Validator\Exception\NoSuchMetadataException');
|
||||
$this->expectException(\Symfony\Component\Validator\Exception\NoSuchMetadataException::class);
|
||||
$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);
|
||||
$factory = new LazyLoadingMetadataFactory($loader, $cache);
|
||||
$cache
|
||||
|
@ -41,7 +41,7 @@ class ValidatorBuilderTest extends TestCase
|
||||
public function testAddObjectInitializer()
|
||||
{
|
||||
$this->assertSame($this->builder, $this->builder->addObjectInitializer(
|
||||
$this->getMockBuilder('Symfony\Component\Validator\ObjectInitializerInterface')->getMock()
|
||||
$this->getMockBuilder(\Symfony\Component\Validator\ObjectInitializerInterface::class)->getMock()
|
||||
));
|
||||
}
|
||||
|
||||
@ -163,14 +163,14 @@ class ValidatorBuilderTest extends TestCase
|
||||
public function testSetConstraintValidatorFactory()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$this->assertSame($this->builder, $this->builder->setTranslator(
|
||||
$this->getMockBuilder('Symfony\Contracts\Translation\TranslatorInterface')->getMock())
|
||||
$this->getMockBuilder(\Symfony\Contracts\Translation\TranslatorInterface::class)->getMock())
|
||||
);
|
||||
}
|
||||
|
||||
@ -181,6 +181,6 @@ class ValidatorBuilderTest extends TestCase
|
||||
|
||||
public function testGetValidator()
|
||||
{
|
||||
$this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator());
|
||||
$this->assertInstanceOf(\Symfony\Component\Validator\Validator\RecursiveValidator::class, $this->builder->getValidator());
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class InMemoryMetadataStoreTest extends TestCase
|
||||
|
||||
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->store->getMetadata('title', true);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class WorkflowValidatorTest extends TestCase
|
||||
|
||||
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".');
|
||||
$places = range('a', 'c');
|
||||
|
||||
|
@ -24,7 +24,7 @@ class WorkflowTest extends TestCase
|
||||
|
||||
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".');
|
||||
$subject = new Subject();
|
||||
$workflow = new Workflow(new Definition([], []), $this->getMockBuilder(MarkingStoreInterface::class)->getMock());
|
||||
@ -34,7 +34,7 @@ class WorkflowTest extends TestCase
|
||||
|
||||
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".');
|
||||
$subject = new Subject();
|
||||
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
|
||||
@ -44,7 +44,7 @@ class WorkflowTest extends TestCase
|
||||
|
||||
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".');
|
||||
$subject = new Subject();
|
||||
$subject->setMarking(['nope' => 1]);
|
||||
@ -171,7 +171,7 @@ class WorkflowTest extends TestCase
|
||||
|
||||
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".');
|
||||
$definition = $this->createSimpleWorkflowDefinition();
|
||||
$subject = new Subject();
|
||||
|
@ -525,7 +525,7 @@ EOF;
|
||||
|
||||
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").');
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
|
Reference in New Issue
Block a user