Merge branch '5.2' into 5.x
* 5.2: Use ::class keyword when possible
This commit is contained in:
commit
c373e24e49
@ -21,6 +21,7 @@ use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
|
||||
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
class EntityUserProviderTest extends TestCase
|
||||
{
|
||||
@ -154,7 +155,7 @@ class EntityUserProviderTest extends TestCase
|
||||
->method('loadUserByUsername')
|
||||
->with('name')
|
||||
->willReturn(
|
||||
$this->getMockBuilder('\Symfony\Component\Security\Core\User\UserInterface')->getMock()
|
||||
$this->getMockBuilder(UserInterface::class)->getMock()
|
||||
);
|
||||
|
||||
$provider = new EntityUserProvider(
|
||||
|
@ -14,6 +14,8 @@ namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy;
|
||||
require_once __DIR__.'/Fixtures/includes/foo.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ProxyManager\Proxy\LazyLoadingInterface;
|
||||
use ProxyManagerBridgeFooClass;
|
||||
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
@ -31,7 +33,7 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
$builder->setProxyInstantiator(new RuntimeInstantiator());
|
||||
|
||||
$builder->register('foo1', 'ProxyManagerBridgeFooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php')->setPublic(true);
|
||||
$builder->register('foo1', ProxyManagerBridgeFooClass::class)->setFile(__DIR__.'/Fixtures/includes/foo.php')->setPublic(true);
|
||||
$builder->getDefinition('foo1')->setLazy(true);
|
||||
|
||||
$builder->compile();
|
||||
@ -43,16 +45,16 @@ class ContainerBuilderTest extends TestCase
|
||||
$this->assertSame(0, $foo1::$destructorCount);
|
||||
|
||||
$this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved on multiple subsequent calls');
|
||||
$this->assertInstanceOf('\ProxyManagerBridgeFooClass', $foo1);
|
||||
$this->assertInstanceOf('\ProxyManager\Proxy\LazyLoadingInterface', $foo1);
|
||||
$this->assertInstanceOf(ProxyManagerBridgeFooClass::class, $foo1);
|
||||
$this->assertInstanceOf(LazyLoadingInterface::class, $foo1);
|
||||
$this->assertFalse($foo1->isProxyInitialized());
|
||||
|
||||
$foo1->initializeProxy();
|
||||
|
||||
$this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved after initialization');
|
||||
$this->assertTrue($foo1->isProxyInitialized());
|
||||
$this->assertInstanceOf('\ProxyManagerBridgeFooClass', $foo1->getWrappedValueHolderValue());
|
||||
$this->assertNotInstanceOf('\ProxyManager\Proxy\LazyLoadingInterface', $foo1->getWrappedValueHolderValue());
|
||||
$this->assertInstanceOf(ProxyManagerBridgeFooClass::class, $foo1->getWrappedValueHolderValue());
|
||||
$this->assertNotInstanceOf(LazyLoadingInterface::class, $foo1->getWrappedValueHolderValue());
|
||||
|
||||
$foo1->__destruct();
|
||||
$this->assertSame(1, $foo1::$destructorCount);
|
||||
|
@ -102,7 +102,7 @@ class TranslatorTest extends TestCase
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('Invalid "invalid locale" locale.');
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
|
||||
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
|
||||
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', TranslatorWithInvalidLocale::class);
|
||||
|
||||
$translator->trans('foo');
|
||||
}
|
||||
@ -308,7 +308,7 @@ class TranslatorTest extends TestCase
|
||||
return $container;
|
||||
}
|
||||
|
||||
public function getTranslator($loader, $options = [], $loaderFomat = 'loader', $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $defaultLocale = 'en', array $enabledLocales = [])
|
||||
public function getTranslator($loader, $options = [], $loaderFomat = 'loader', $translatorClass = Translator::class, $defaultLocale = 'en', array $enabledLocales = [])
|
||||
{
|
||||
$translator = $this->createTranslator($loader, $options, $translatorClass, $loaderFomat, $defaultLocale, $enabledLocales);
|
||||
|
||||
@ -390,7 +390,7 @@ class TranslatorTest extends TestCase
|
||||
$this->assertEquals('It works!', $translator->trans('message', [], 'domain.with.dots'));
|
||||
}
|
||||
|
||||
private function createTranslator($loader, $options, $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $loaderFomat = 'loader', $defaultLocale = 'en', array $enabledLocales = [])
|
||||
private function createTranslator($loader, $options, $translatorClass = Translator::class, $loaderFomat = 'loader', $defaultLocale = 'en', array $enabledLocales = [])
|
||||
{
|
||||
if (null === $defaultLocale) {
|
||||
return new $translatorClass(
|
||||
|
@ -258,7 +258,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
|
||||
|
||||
public function testEncodePasswordNoConfigForGivenUserClass()
|
||||
{
|
||||
$this->expectException('\RuntimeException');
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('No encoder has been configured for account "Foo\Bar\User".');
|
||||
|
||||
$this->passwordEncoderCommandTester->execute([
|
||||
|
@ -12,10 +12,14 @@
|
||||
namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\AppVariable;
|
||||
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass;
|
||||
use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;
|
||||
use Symfony\Bundle\TwigBundle\TemplateIterator;
|
||||
use Symfony\Bundle\TwigBundle\TwigEngine;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Twig\Loader\FilesystemLoader as TwigFilesystemLoader;
|
||||
|
||||
class ExtensionPassTest extends TestCase
|
||||
{
|
||||
@ -24,12 +28,12 @@ class ExtensionPassTest extends TestCase
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('kernel.debug', false);
|
||||
|
||||
$container->register('twig.app_variable', '\Symfony\Bridge\Twig\AppVariable');
|
||||
$container->register('twig.app_variable', AppVariable::class);
|
||||
$container->register('twig.extension.yaml');
|
||||
$container->register('twig.extension.debug.stopwatch');
|
||||
$container->register('twig.extension.expression');
|
||||
|
||||
$nativeTwigLoader = new Definition('\Twig\Loader\FilesystemLoader');
|
||||
$nativeTwigLoader = new Definition(TwigFilesystemLoader::class);
|
||||
$nativeTwigLoader->addMethodCall('addPath', []);
|
||||
$container->setDefinition('twig.loader.native_filesystem', $nativeTwigLoader);
|
||||
|
||||
|
@ -81,7 +81,7 @@ class HttpBrowserTest extends AbstractBrowserTest
|
||||
->method('request')
|
||||
->with('POST', 'http://example.com/', $this->callback(function ($options) {
|
||||
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
|
||||
$this->assertInstanceOf('\Generator', $options['body']);
|
||||
$this->assertInstanceOf(\Generator::class, $options['body']);
|
||||
$this->assertStringContainsString('my_file', implode('', iterator_to_array($options['body'])));
|
||||
|
||||
return true;
|
||||
@ -191,7 +191,7 @@ class HttpBrowserTest extends AbstractBrowserTest
|
||||
->method('request')
|
||||
->with('POST', 'http://example.com/', $this->callback(function ($options) use ($fileContents) {
|
||||
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
|
||||
$this->assertInstanceOf('\Generator', $options['body']);
|
||||
$this->assertInstanceOf(\Generator::class, $options['body']);
|
||||
$body = implode('', iterator_to_array($options['body'], false));
|
||||
foreach ($fileContents as $content) {
|
||||
$this->assertStringContainsString($content, $body);
|
||||
@ -209,7 +209,7 @@ class HttpBrowserTest extends AbstractBrowserTest
|
||||
->method('request')
|
||||
->with('POST', 'http://example.com/', $this->callback(function ($options) use ($fileContents) {
|
||||
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
|
||||
$this->assertInstanceOf('\Generator', $options['body']);
|
||||
$this->assertInstanceOf(\Generator::class, $options['body']);
|
||||
$body = implode('', iterator_to_array($options['body'], false));
|
||||
foreach ($fileContents as $content) {
|
||||
$this->assertStringNotContainsString($content, $body);
|
||||
|
@ -186,7 +186,7 @@ class MemcachedAdapterTest extends AdapterTestCase
|
||||
|
||||
public function provideDsnWithOptions(): iterable
|
||||
{
|
||||
if (!class_exists('\Memcached')) {
|
||||
if (!class_exists(\Memcached::class)) {
|
||||
self::markTestSkipped('Extension memcached required.');
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Config\Tests;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Config\ResourceCheckerConfigCache;
|
||||
use Symfony\Component\Config\ResourceCheckerInterface;
|
||||
use Symfony\Component\Config\Tests\Resource\ResourceStub;
|
||||
|
||||
class ResourceCheckerConfigCacheTest extends TestCase
|
||||
@ -45,7 +46,7 @@ class ResourceCheckerConfigCacheTest extends TestCase
|
||||
|
||||
public function testCacheIsNotFreshIfEmpty()
|
||||
{
|
||||
$checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock()
|
||||
$checker = $this->getMockBuilder(ResourceCheckerInterface::class)->getMock()
|
||||
->expects($this->never())->method('supports');
|
||||
|
||||
/* If there is nothing in the cache, it needs to be filled (and thus it's not fresh).
|
||||
@ -82,7 +83,7 @@ class ResourceCheckerConfigCacheTest extends TestCase
|
||||
|
||||
public function testIsFreshWithchecker()
|
||||
{
|
||||
$checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock();
|
||||
$checker = $this->getMockBuilder(ResourceCheckerInterface::class)->getMock();
|
||||
|
||||
$checker->expects($this->once())
|
||||
->method('supports')
|
||||
@ -100,7 +101,7 @@ class ResourceCheckerConfigCacheTest extends TestCase
|
||||
|
||||
public function testIsNotFreshWithchecker()
|
||||
{
|
||||
$checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock();
|
||||
$checker = $this->getMockBuilder(ResourceCheckerInterface::class)->getMock();
|
||||
|
||||
$checker->expects($this->once())
|
||||
->method('supports')
|
||||
@ -118,7 +119,7 @@ class ResourceCheckerConfigCacheTest extends TestCase
|
||||
|
||||
public function testCacheIsNotFreshWhenUnserializeFails()
|
||||
{
|
||||
$checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock();
|
||||
$checker = $this->getMockBuilder(ResourceCheckerInterface::class)->getMock();
|
||||
$cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]);
|
||||
$cache->write('foo', [new FileResource(__FILE__)]);
|
||||
|
||||
@ -138,7 +139,8 @@ class ResourceCheckerConfigCacheTest extends TestCase
|
||||
|
||||
public function testCacheIsNotFreshIfNotExistsMetaFile()
|
||||
{
|
||||
$checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock();
|
||||
$checker = $this->getMockBuilder(ResourceCheckerInterface::class
|
||||
)->getMock();
|
||||
$cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]);
|
||||
$cache->write('foo', [new FileResource(__FILE__)]);
|
||||
|
||||
|
@ -764,7 +764,7 @@ class ApplicationTest extends TestCase
|
||||
$tester->run(['command' => 'foo'], ['decorated' => false]);
|
||||
$this->fail('->setCatchExceptions() sets the catch exception flag');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\Exception', $e, '->setCatchExceptions() sets the catch exception flag');
|
||||
$this->assertInstanceOf(\Exception::class, $e, '->setCatchExceptions() sets the catch exception flag');
|
||||
$this->assertEquals('Command "foo" is not defined.', $e->getMessage(), '->setCatchExceptions() sets the catch exception flag');
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class OutputFormatterStyleTest extends TestCase
|
||||
$style->setOption('foo');
|
||||
$this->fail('->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
|
||||
$this->assertStringContainsString('Invalid option specified: "foo"', $e->getMessage(), '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Console\Tests\Helper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\HelperInterface;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
|
||||
class HelperSetTest extends TestCase
|
||||
@ -66,7 +67,7 @@ class HelperSetTest extends TestCase
|
||||
$helperset->get('foo');
|
||||
$this->fail('->get() throws InvalidArgumentException when helper not found');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws InvalidArgumentException when helper not found');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->get() throws InvalidArgumentException when helper not found');
|
||||
$this->assertInstanceOf('Symfony\Component\Console\Exception\ExceptionInterface', $e, '->get() throws domain specific exception when helper not found');
|
||||
$this->assertStringContainsString('The helper "foo" is not defined.', $e->getMessage(), '->get() throws InvalidArgumentException when helper not found');
|
||||
}
|
||||
@ -111,7 +112,7 @@ class HelperSetTest extends TestCase
|
||||
|
||||
private function getGenericMockHelper($name, HelperSet $helperset = null)
|
||||
{
|
||||
$mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock();
|
||||
$mock_helper = $this->getMockBuilder(HelperInterface::class)->getMock();
|
||||
$mock_helper->expects($this->any())
|
||||
->method('getName')
|
||||
->willReturn($name);
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Helper\FormatterHelper;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
@ -728,7 +729,7 @@ EOD;
|
||||
' [<info>żółw </info>] bar',
|
||||
' [<info>łabądź</info>] baz',
|
||||
];
|
||||
$output = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface')->getMock();
|
||||
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
|
||||
$output->method('getFormatter')->willReturn(new OutputFormatter());
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
|
@ -55,7 +55,7 @@ class ResolveClassPassTest extends TestCase
|
||||
{
|
||||
yield [\stdClass::class];
|
||||
yield ['bar'];
|
||||
yield ['\DateTime'];
|
||||
yield [\DateTime::class];
|
||||
}
|
||||
|
||||
public function testNonFqcnChildDefinition()
|
||||
|
@ -420,7 +420,7 @@ class ContainerBuilderTest extends TestCase
|
||||
$builder = new ContainerBuilder();
|
||||
$builder->register('foo1', '%class%');
|
||||
$builder->setParameter('class', 'stdClass');
|
||||
$this->assertInstanceOf('\stdClass', $builder->get('foo1'), '->createService() replaces parameters in the class provided by the service definition');
|
||||
$this->assertInstanceOf(\stdClass::class, $builder->get('foo1'), '->createService() replaces parameters in the class provided by the service definition');
|
||||
}
|
||||
|
||||
public function testCreateServiceArguments()
|
||||
@ -519,7 +519,7 @@ class ContainerBuilderTest extends TestCase
|
||||
foreach ($lazyContext->lazyValues as $k => $v) {
|
||||
++$i;
|
||||
$this->assertEquals('k1', $k);
|
||||
$this->assertInstanceOf('\stdClass', $v);
|
||||
$this->assertInstanceOf(\stdClass::class, $v);
|
||||
}
|
||||
|
||||
// The second argument should have been ignored.
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\DependencyInjection\Tests;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
@ -116,7 +117,7 @@ class ContainerTest extends TestCase
|
||||
$sc->getParameter('baba');
|
||||
$this->fail('->getParameter() thrown an \InvalidArgumentException if the key does not exist');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
|
||||
$this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
|
||||
}
|
||||
}
|
||||
@ -252,7 +253,7 @@ class ContainerTest extends TestCase
|
||||
$sc->get('circular');
|
||||
$this->fail('->get() throws a ServiceCircularReferenceException if it contains circular reference');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException', $e, '->get() throws a ServiceCircularReferenceException if it contains circular reference');
|
||||
$this->assertInstanceOf(ServiceCircularReferenceException::class, $e, '->get() throws a ServiceCircularReferenceException if it contains circular reference');
|
||||
$this->assertStringStartsWith('Circular reference detected for service "circular"', $e->getMessage(), '->get() throws a \LogicException if it contains circular reference');
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ class PhpDumperTest extends TestCase
|
||||
$dumper->dump();
|
||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertInstanceOf(RuntimeException::class, $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class XmlDumperTest extends TestCase
|
||||
$dumper->dump();
|
||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertInstanceOf(\RuntimeException::class, $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class YamlDumperTest extends TestCase
|
||||
$dumper->dump();
|
||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertInstanceOf(\RuntimeException::class, $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
require_once __DIR__.'/../includes/classes.php';
|
||||
require_once __DIR__.'/../includes/foo.php';
|
||||
|
||||
use Bar\FooClass;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
@ -13,7 +14,7 @@ use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container
|
||||
->register('foo', '\Bar\FooClass')
|
||||
->register('foo', FooClass::class)
|
||||
->addTag('foo', ['foo' => 'foo'])
|
||||
->addTag('foo', ['bar' => 'bar', 'baz' => 'baz'])
|
||||
->addTag('foo', ['name' => 'bar', 'baz' => 'baz'])
|
||||
|
@ -548,7 +548,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
$loader->load('extensions/services4.xml');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the tag is not valid');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag is not valid');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tag is not valid');
|
||||
$this->assertStringStartsWith('There is no extension able to load the configuration for "project:bar" (in', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag is not valid');
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
$loader->load('services11.yml');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the tag is not valid');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag is not valid');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tag is not valid');
|
||||
$this->assertStringStartsWith('There is no extension able to load the configuration for "foobarfoobar" (in', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag is not valid');
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ class FlattenExceptionTest extends TestCase
|
||||
|
||||
$args = $array[$i++];
|
||||
$this->assertSame('object', $args[0]);
|
||||
$this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], '\Closure'), 'Expect object class name to be Closure or a subclass of Closure.');
|
||||
$this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], \Closure::class), 'Expect object class name to be Closure or a subclass of Closure.');
|
||||
|
||||
$this->assertSame(['array', [['integer', 1], ['integer', 2]]], $array[$i++]);
|
||||
$this->assertSame(['array', ['foo' => ['integer', 123]]], $array[$i++]);
|
||||
|
@ -80,7 +80,7 @@ class GenericEventTest extends TestCase
|
||||
|
||||
public function testGetArgException()
|
||||
{
|
||||
$this->expectException('\InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->event->getArgument('nameNotExist');
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ class GenericEventTest extends TestCase
|
||||
$this->assertEquals('Event', $this->event['name']);
|
||||
|
||||
// test getting invalid arg
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->assertFalse($this->event['nameNotExist']);
|
||||
}
|
||||
|
||||
|
@ -72,13 +72,13 @@ class ImmutableEventDispatcherTest extends TestCase
|
||||
|
||||
public function testAddListenerDisallowed()
|
||||
{
|
||||
$this->expectException('\BadMethodCallException');
|
||||
$this->expectException(\BadMethodCallException::class);
|
||||
$this->dispatcher->addListener('event', function () { return 'foo'; });
|
||||
}
|
||||
|
||||
public function testAddSubscriberDisallowed()
|
||||
{
|
||||
$this->expectException('\BadMethodCallException');
|
||||
$this->expectException(\BadMethodCallException::class);
|
||||
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
|
||||
|
||||
$this->dispatcher->addSubscriber($subscriber);
|
||||
@ -86,13 +86,13 @@ class ImmutableEventDispatcherTest extends TestCase
|
||||
|
||||
public function testRemoveListenerDisallowed()
|
||||
{
|
||||
$this->expectException('\BadMethodCallException');
|
||||
$this->expectException(\BadMethodCallException::class);
|
||||
$this->dispatcher->removeListener('event', function () { return 'foo'; });
|
||||
}
|
||||
|
||||
public function testRemoveSubscriberDisallowed()
|
||||
{
|
||||
$this->expectException('\BadMethodCallException');
|
||||
$this->expectException(\BadMethodCallException::class);
|
||||
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
|
||||
|
||||
$this->dispatcher->removeSubscriber($subscriber);
|
||||
|
@ -82,7 +82,7 @@ class DateIntervalToArrayTransformer implements DataTransformerInterface
|
||||
);
|
||||
}
|
||||
if (!$dateInterval instanceof \DateInterval) {
|
||||
throw new UnexpectedTypeException($dateInterval, '\DateInterval');
|
||||
throw new UnexpectedTypeException($dateInterval, \DateInterval::class);
|
||||
}
|
||||
$result = [];
|
||||
foreach (self::$availableFields as $field => $char) {
|
||||
|
@ -51,7 +51,7 @@ class DateIntervalToStringTransformer implements DataTransformerInterface
|
||||
return '';
|
||||
}
|
||||
if (!$value instanceof \DateInterval) {
|
||||
throw new UnexpectedTypeException($value, '\DateInterval');
|
||||
throw new UnexpectedTypeException($value, \DateInterval::class);
|
||||
}
|
||||
|
||||
return $value->format($this->format);
|
||||
|
@ -26,6 +26,7 @@ use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
|
||||
use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface;
|
||||
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
|
||||
use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
||||
@ -351,17 +352,17 @@ class ChoiceType extends AbstractType
|
||||
$resolver->setNormalizer('placeholder', $placeholderNormalizer);
|
||||
$resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer);
|
||||
|
||||
$resolver->setAllowedTypes('choices', ['null', 'array', '\Traversable']);
|
||||
$resolver->setAllowedTypes('choices', ['null', 'array', \Traversable::class]);
|
||||
$resolver->setAllowedTypes('choice_translation_domain', ['null', 'bool', 'string']);
|
||||
$resolver->setAllowedTypes('choice_loader', ['null', 'Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface', ChoiceLoader::class]);
|
||||
$resolver->setAllowedTypes('choice_loader', ['null', ChoiceLoaderInterface::class, ChoiceLoader::class]);
|
||||
$resolver->setAllowedTypes('choice_filter', ['null', 'callable', 'string', PropertyPath::class, ChoiceFilter::class]);
|
||||
$resolver->setAllowedTypes('choice_label', ['null', 'bool', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath', ChoiceLabel::class]);
|
||||
$resolver->setAllowedTypes('choice_name', ['null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath', ChoiceFieldName::class]);
|
||||
$resolver->setAllowedTypes('choice_value', ['null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath', ChoiceValue::class]);
|
||||
$resolver->setAllowedTypes('choice_attr', ['null', 'array', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath', ChoiceAttr::class]);
|
||||
$resolver->setAllowedTypes('choice_label', ['null', 'bool', 'callable', 'string', PropertyPath::class, ChoiceLabel::class]);
|
||||
$resolver->setAllowedTypes('choice_name', ['null', 'callable', 'string', PropertyPath::class, ChoiceFieldName::class]);
|
||||
$resolver->setAllowedTypes('choice_value', ['null', 'callable', 'string', PropertyPath::class, ChoiceValue::class]);
|
||||
$resolver->setAllowedTypes('choice_attr', ['null', 'array', 'callable', 'string', PropertyPath::class, ChoiceAttr::class]);
|
||||
$resolver->setAllowedTypes('choice_translation_parameters', ['null', 'array', 'callable', ChoiceTranslationParameters::class]);
|
||||
$resolver->setAllowedTypes('preferred_choices', ['array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath', PreferredChoice::class]);
|
||||
$resolver->setAllowedTypes('group_by', ['null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath', GroupBy::class]);
|
||||
$resolver->setAllowedTypes('preferred_choices', ['array', '\Traversable', 'callable', 'string', PropertyPath::class, PreferredChoice::class]);
|
||||
$resolver->setAllowedTypes('group_by', ['null', 'callable', 'string', PropertyPath::class, GroupBy::class]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,15 +36,15 @@ class ButtonBuilderTest extends TestCase
|
||||
*/
|
||||
public function testValidNames($name)
|
||||
{
|
||||
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder($name));
|
||||
$this->assertInstanceOf(ButtonBuilder::class, new ButtonBuilder($name));
|
||||
}
|
||||
|
||||
public function testNameContainingIllegalCharacters()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('The name "button[]" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").');
|
||||
|
||||
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder('button[]'));
|
||||
$this->assertInstanceOf(ButtonBuilder::class, new ButtonBuilder('button[]'));
|
||||
}
|
||||
|
||||
public function getInvalidNames()
|
||||
|
@ -45,7 +45,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromChoices')
|
||||
->with($choices, $this->isInstanceOf('\Closure'))
|
||||
->with($choices, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($choices, $callback) {
|
||||
return new ArrayChoiceList(array_map($callback, $choices));
|
||||
});
|
||||
@ -59,7 +59,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromChoices')
|
||||
->with($choices, $this->isInstanceOf('\Closure'))
|
||||
->with($choices, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($choices, $callback) {
|
||||
return new ArrayChoiceList(array_map($callback, $choices));
|
||||
});
|
||||
@ -114,7 +114,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromLoader')
|
||||
->with($loader, $this->isInstanceOf('\Closure'))
|
||||
->with($loader, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($loader, $callback) {
|
||||
return new ArrayChoiceList((array) $callback((object) ['property' => 'value']));
|
||||
});
|
||||
@ -149,7 +149,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromChoices')
|
||||
->with($choices, $this->isInstanceOf('\Closure'))
|
||||
->with($choices, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($choices, $callback) {
|
||||
return new ArrayChoiceList(array_map($callback, $choices));
|
||||
});
|
||||
@ -164,7 +164,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromLoader')
|
||||
->with($loader, $this->isInstanceOf('\Closure'))
|
||||
->with($loader, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($loader, $callback) {
|
||||
return new ArrayChoiceList((array) $callback(null));
|
||||
});
|
||||
@ -178,7 +178,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createListFromLoader')
|
||||
->with($loader, $this->isInstanceOf('\Closure'))
|
||||
->with($loader, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($loader, $callback) {
|
||||
return new ArrayChoiceList((array) $callback((object) ['property' => 'value']));
|
||||
});
|
||||
@ -192,7 +192,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, $this->isInstanceOf('\Closure'))
|
||||
->with($list, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred) {
|
||||
return new ChoiceListView((array) $preferred((object) ['property' => true]));
|
||||
});
|
||||
@ -206,7 +206,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, $this->isInstanceOf('\Closure'))
|
||||
->with($list, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred) {
|
||||
return new ChoiceListView((array) $preferred((object) ['property' => true]));
|
||||
});
|
||||
@ -221,7 +221,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, $this->isInstanceOf('\Closure'))
|
||||
->with($list, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred) {
|
||||
return new ChoiceListView((array) $preferred((object) ['category' => null]));
|
||||
});
|
||||
@ -235,7 +235,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, $this->isInstanceOf('\Closure'))
|
||||
->with($list, null, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred, $label) {
|
||||
return new ChoiceListView((array) $label((object) ['property' => 'label']));
|
||||
});
|
||||
@ -249,7 +249,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, $this->isInstanceOf('\Closure'))
|
||||
->with($list, null, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred, $label) {
|
||||
return new ChoiceListView((array) $label((object) ['property' => 'label']));
|
||||
});
|
||||
@ -263,7 +263,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, null, $this->isInstanceOf('\Closure'))
|
||||
->with($list, null, null, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred, $label, $index) {
|
||||
return new ChoiceListView((array) $index((object) ['property' => 'index']));
|
||||
});
|
||||
@ -277,7 +277,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, null, $this->isInstanceOf('\Closure'))
|
||||
->with($list, null, null, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred, $label, $index) {
|
||||
return new ChoiceListView((array) $index((object) ['property' => 'index']));
|
||||
});
|
||||
@ -291,7 +291,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
|
||||
->with($list, null, null, null, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
|
||||
return new ChoiceListView((array) $groupBy((object) ['property' => 'group']));
|
||||
});
|
||||
@ -305,7 +305,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
|
||||
->with($list, null, null, null, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
|
||||
return new ChoiceListView((array) $groupBy((object) ['property' => 'group']));
|
||||
});
|
||||
@ -320,7 +320,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
|
||||
->with($list, null, null, null, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
|
||||
return new ChoiceListView((array) $groupBy((object) ['group' => null]));
|
||||
});
|
||||
@ -334,7 +334,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
|
||||
->with($list, null, null, null, null, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
|
||||
return new ChoiceListView((array) $attr((object) ['property' => 'attr']));
|
||||
});
|
||||
@ -348,7 +348,7 @@ class PropertyAccessDecoratorTest extends TestCase
|
||||
|
||||
$this->decoratedFactory->expects($this->once())
|
||||
->method('createView')
|
||||
->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
|
||||
->with($list, null, null, null, null, $this->isInstanceOf(\Closure::class))
|
||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
|
||||
return new ChoiceListView((array) $attr((object) ['property' => 'attr']));
|
||||
});
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Form\Tests\ChoiceList\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
||||
use Symfony\Component\Form\ChoiceList\LazyChoiceList;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
|
||||
|
||||
@ -63,7 +64,7 @@ class CallbackChoiceLoaderTest extends TestCase
|
||||
|
||||
public function testLoadChoiceList()
|
||||
{
|
||||
$this->assertInstanceOf('\Symfony\Component\Form\ChoiceList\ChoiceListInterface', self::$loader->loadChoiceList(self::$value));
|
||||
$this->assertInstanceOf(ChoiceListInterface::class, self::$loader->loadChoiceList(self::$value));
|
||||
}
|
||||
|
||||
public function testLoadChoiceListOnlyOnce()
|
||||
|
@ -227,7 +227,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
public function testAddUsingNameButNoType()
|
||||
{
|
||||
$this->form = $this->getBuilder('name', null, '\stdClass')
|
||||
$this->form = $this->getBuilder('name', null, \stdClass::class)
|
||||
->setCompound(true)
|
||||
->setDataMapper($this->getDataMapper())
|
||||
->getForm();
|
||||
@ -236,7 +236,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
$this->factory->expects($this->once())
|
||||
->method('createForProperty')
|
||||
->with('\stdClass', 'foo')
|
||||
->with(\stdClass::class, 'foo')
|
||||
->willReturn($child);
|
||||
|
||||
$this->form->add('foo');
|
||||
@ -248,7 +248,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
public function testAddUsingNameButNoTypeAndOptions()
|
||||
{
|
||||
$this->form = $this->getBuilder('name', null, '\stdClass')
|
||||
$this->form = $this->getBuilder('name', null, \stdClass::class)
|
||||
->setCompound(true)
|
||||
->setDataMapper($this->getDataMapper())
|
||||
->getForm();
|
||||
@ -257,7 +257,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
$this->factory->expects($this->once())
|
||||
->method('createForProperty')
|
||||
->with('\stdClass', 'foo', null, [
|
||||
->with(\stdClass::class, 'foo', null, [
|
||||
'bar' => 'baz',
|
||||
'auto_initialize' => false,
|
||||
])
|
||||
@ -348,7 +348,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$child = $this->getBuilder()->getForm();
|
||||
$mapper->expects($this->once())
|
||||
->method('mapDataToForms')
|
||||
->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator'))
|
||||
->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
|
||||
->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) {
|
||||
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
|
||||
$this->assertSame([$child->getName() => $child], iterator_to_array($iterator));
|
||||
@ -438,7 +438,7 @@ class CompoundFormTest extends AbstractFormTest
|
||||
|
||||
$mapper->expects($this->once())
|
||||
->method('mapDataToForms')
|
||||
->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator'))
|
||||
->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
|
||||
->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) {
|
||||
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
|
||||
$this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
|
||||
|
@ -24,6 +24,6 @@ class MergeCollectionListenerArrayObjectTest extends MergeCollectionListenerTest
|
||||
|
||||
protected function getBuilder($name = 'name')
|
||||
{
|
||||
return new FormBuilder($name, '\ArrayObject', new EventDispatcher(), (new FormFactoryBuilder())->getFormFactory());
|
||||
return new FormBuilder($name, \ArrayObject::class, new EventDispatcher(), (new FormFactoryBuilder())->getFormFactory());
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormFactoryBuilder;
|
||||
use Symfony\Component\Form\Util\ServerParams;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManager;
|
||||
|
||||
class CsrfValidationListenerTest extends TestCase
|
||||
@ -76,7 +77,7 @@ class CsrfValidationListenerTest extends TestCase
|
||||
public function testMaxPostSizeExceeded()
|
||||
{
|
||||
$serverParams = $this
|
||||
->getMockBuilder('\Symfony\Component\Form\Util\ServerParams')
|
||||
->getMockBuilder(ServerParams::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
|
@ -31,7 +31,7 @@ class GuessTest extends TestCase
|
||||
|
||||
public function testGuessExpectsValidConfidence()
|
||||
{
|
||||
$this->expectException('\InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
new TestGuess(5);
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ class ResolvedFormTypeTest extends TestCase
|
||||
public function testCreateBuilderWithDataClassOption()
|
||||
{
|
||||
$givenOptions = ['data_class' => 'Foo'];
|
||||
$resolvedOptions = ['data_class' => '\stdClass'];
|
||||
$resolvedOptions = ['data_class' => \stdClass::class];
|
||||
$optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock();
|
||||
|
||||
$this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType')
|
||||
@ -178,7 +178,7 @@ class ResolvedFormTypeTest extends TestCase
|
||||
|
||||
$this->assertSame($this->resolvedType, $builder->getType());
|
||||
$this->assertSame($resolvedOptions, $builder->getOptions());
|
||||
$this->assertSame('\stdClass', $builder->getDataClass());
|
||||
$this->assertSame(\stdClass::class, $builder->getDataClass());
|
||||
}
|
||||
|
||||
public function testFailsCreateBuilderOnInvalidFormOptionsResolution()
|
||||
|
@ -121,7 +121,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
$preSetData = false;
|
||||
$preSubmit = false;
|
||||
|
||||
$mock = $this->getMockBuilder('\stdClass')
|
||||
$mock = $this->getMockBuilder(\stdClass::class)
|
||||
->setMethods(['preSetData', 'preSubmit'])
|
||||
->getMock();
|
||||
$mock->expects($this->once())
|
||||
@ -153,7 +153,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
// https://github.com/symfony/symfony/pull/7789
|
||||
public function testFalseIsConvertedToNull()
|
||||
{
|
||||
$mock = $this->getMockBuilder('\stdClass')
|
||||
$mock = $this->getMockBuilder(\stdClass::class)
|
||||
->setMethods(['preSubmit'])
|
||||
->getMock();
|
||||
$mock->expects($this->once())
|
||||
@ -394,7 +394,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
public function testSetDataClonesObjectIfNotByReference()
|
||||
{
|
||||
$data = new \stdClass();
|
||||
$form = $this->getBuilder('name', null, '\stdClass')->setByReference(false)->getForm();
|
||||
$form = $this->getBuilder('name', null, \stdClass::class)->setByReference(false)->getForm();
|
||||
$form->setData($data);
|
||||
|
||||
$this->assertNotSame($data, $form->getData());
|
||||
@ -404,7 +404,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
public function testSetDataDoesNotCloneObjectIfByReference()
|
||||
{
|
||||
$data = new \stdClass();
|
||||
$form = $this->getBuilder('name', null, '\stdClass')->setByReference(true)->getForm();
|
||||
$form = $this->getBuilder('name', null, \stdClass::class)->setByReference(true)->getForm();
|
||||
$form->setData($data);
|
||||
|
||||
$this->assertSame($data, $form->getData());
|
||||
|
@ -89,7 +89,7 @@ class SessionTest extends TestCase
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
$this->assertInstanceOf('\LogicException', $e);
|
||||
$this->assertInstanceOf(\LogicException::class, $e);
|
||||
}
|
||||
|
||||
public function testSetName()
|
||||
|
@ -136,6 +136,6 @@ class MemcachedSessionHandlerTest extends TestCase
|
||||
$method = new \ReflectionMethod($this->storage, 'getMemcached');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertInstanceOf('\Memcached', $method->invoke($this->storage));
|
||||
$this->assertInstanceOf(\Memcached::class, $method->invoke($this->storage));
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ class PdoSessionHandlerTest extends TestCase
|
||||
$method = new \ReflectionMethod($storage, 'getConnection');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertInstanceOf('\PDO', $method->invoke($storage));
|
||||
$this->assertInstanceOf(\PDO::class, $method->invoke($storage));
|
||||
}
|
||||
|
||||
public function testGetConnectionConnectsIfNeeded()
|
||||
@ -308,7 +308,7 @@ class PdoSessionHandlerTest extends TestCase
|
||||
$method = new \ReflectionMethod($storage, 'getConnection');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertInstanceOf('\PDO', $method->invoke($storage));
|
||||
$this->assertInstanceOf(\PDO::class, $method->invoke($storage));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +132,7 @@ class ArgumentResolverTest extends TestCase
|
||||
self::$resolver->getArguments($request, $controller);
|
||||
$this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
|
||||
$this->assertInstanceOf(\RuntimeException::class, $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ final class Intl
|
||||
*/
|
||||
public static function isExtensionLoaded(): bool
|
||||
{
|
||||
return class_exists('\ResourceBundle');
|
||||
return class_exists(\ResourceBundle::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Intl\Tests\Collator;
|
||||
|
||||
use Symfony\Component\Intl\Collator\Collator;
|
||||
use Symfony\Component\Intl\Exception\MethodNotImplementedException;
|
||||
use Symfony\Component\Intl\Globals\IntlGlobals;
|
||||
|
||||
/**
|
||||
@ -60,19 +61,19 @@ class CollatorTest extends AbstractCollatorTest
|
||||
public function testConstructWithoutLocale()
|
||||
{
|
||||
$collator = $this->getCollator(null);
|
||||
$this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
|
||||
$this->assertInstanceOf(Collator::class, $collator);
|
||||
}
|
||||
|
||||
public function testGetSortKey()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
|
||||
$this->expectException(MethodNotImplementedException::class);
|
||||
$collator = $this->getCollator('en');
|
||||
$collator->getSortKey('Hello');
|
||||
}
|
||||
|
||||
public function testGetStrength()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
|
||||
$this->expectException(MethodNotImplementedException::class);
|
||||
$collator = $this->getCollator('en');
|
||||
$collator->getStrength();
|
||||
}
|
||||
@ -95,7 +96,7 @@ class CollatorTest extends AbstractCollatorTest
|
||||
{
|
||||
$collator = $this->getCollator('en');
|
||||
$collator = $collator::create('en');
|
||||
$this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
|
||||
$this->assertInstanceOf(Collator::class, $collator);
|
||||
}
|
||||
|
||||
protected function getCollator(?string $locale): Collator
|
||||
|
@ -34,7 +34,7 @@ class IntlBundleReaderTest extends TestCase
|
||||
{
|
||||
$data = $this->reader->read(__DIR__.'/Fixtures/res', 'ro');
|
||||
|
||||
$this->assertInstanceOf('\ArrayAccess', $data);
|
||||
$this->assertInstanceOf(\ArrayAccess::class, $data);
|
||||
$this->assertSame('Bar', $data['Foo']);
|
||||
$this->assertArrayNotHasKey('ExistsNot', $data);
|
||||
}
|
||||
@ -44,7 +44,7 @@ class IntlBundleReaderTest extends TestCase
|
||||
// "alias" = "ro"
|
||||
$data = $this->reader->read(__DIR__.'/Fixtures/res', 'alias');
|
||||
|
||||
$this->assertInstanceOf('\ArrayAccess', $data);
|
||||
$this->assertInstanceOf(\ArrayAccess::class, $data);
|
||||
$this->assertSame('Bar', $data['Foo']);
|
||||
$this->assertArrayNotHasKey('ExistsNot', $data);
|
||||
}
|
||||
@ -54,7 +54,7 @@ class IntlBundleReaderTest extends TestCase
|
||||
// "ro_MD" -> "ro"
|
||||
$data = $this->reader->read(__DIR__.'/Fixtures/res', 'ro_MD');
|
||||
|
||||
$this->assertInstanceOf('\ArrayAccess', $data);
|
||||
$this->assertInstanceOf(\ArrayAccess::class, $data);
|
||||
$this->assertSame('Bam', $data['Baz']);
|
||||
$this->assertArrayNotHasKey('Foo', $data);
|
||||
$this->assertNull($data['Foo']);
|
||||
|
@ -47,7 +47,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
||||
{
|
||||
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
|
||||
$formatter = $formatter::create('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
|
||||
$this->assertInstanceOf('\Symfony\Component\Intl\DateFormatter\IntlDateFormatter', $formatter);
|
||||
$this->assertInstanceOf(IntlDateFormatter::class, $formatter);
|
||||
}
|
||||
|
||||
public function testFormatWithUnsupportedTimestampArgument()
|
||||
|
@ -56,10 +56,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
|
||||
|
||||
public function testConstructWithoutLocale()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
'\Symfony\Component\Intl\NumberFormatter\NumberFormatter',
|
||||
$this->getNumberFormatter(null, NumberFormatter::DECIMAL)
|
||||
);
|
||||
$this->assertInstanceOf(NumberFormatter::class, $this->getNumberFormatter(null, NumberFormatter::DECIMAL));
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
|
@ -29,7 +29,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$this->assertInstanceOf('\NumberFormatter', \NumberFormatter::create('en', \NumberFormatter::DECIMAL));
|
||||
$this->assertInstanceOf(\NumberFormatter::class, \NumberFormatter::create('en', \NumberFormatter::DECIMAL));
|
||||
}
|
||||
|
||||
public function testGetTextAttribute()
|
||||
|
@ -60,7 +60,7 @@ trait ExpiringStoreTestTrait
|
||||
*/
|
||||
public function testAbortAfterExpiration()
|
||||
{
|
||||
$this->expectException('\Symfony\Component\Lock\Exception\LockExpiredException');
|
||||
$this->expectException(LockExpiredException::class);
|
||||
$key = new Key(uniqid(__METHOD__, true));
|
||||
|
||||
/** @var PersistingStoreInterface $store */
|
||||
|
@ -57,7 +57,7 @@ abstract class AbstractMimeTypeGuesserTest extends TestCase
|
||||
$this->markTestSkipped('Guesser is not supported');
|
||||
}
|
||||
|
||||
$this->expectException('\InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->getGuesser()->guessMimeType(__DIR__.'/Fixtures/mimetypes/directory');
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ abstract class AbstractMimeTypeGuesserTest extends TestCase
|
||||
$this->markTestSkipped('Guesser is not supported');
|
||||
}
|
||||
|
||||
$this->expectException('\InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->getGuesser()->guessMimeType(__DIR__.'/Fixtures/mimetypes/not_here');
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class RouteCollectionTest extends TestCase
|
||||
$collection->addCollection($collection1);
|
||||
$collection->add('last', $last = new Route('/last'));
|
||||
|
||||
$this->assertInstanceOf('\ArrayIterator', $collection->getIterator());
|
||||
$this->assertInstanceOf(\ArrayIterator::class, $collection->getIterator());
|
||||
$this->assertSame(['bar' => $bar, 'foo' => $foo, 'last' => $last], $collection->getIterator()->getArrayCopy());
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@ namespace Symfony\Component\Routing\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute;
|
||||
use Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler;
|
||||
|
||||
class RouteTest extends TestCase
|
||||
{
|
||||
@ -266,13 +268,13 @@ class RouteTest extends TestCase
|
||||
*/
|
||||
public function testSerializeWhenCompiledWithClass()
|
||||
{
|
||||
$route = new Route('/', [], [], ['compiler_class' => '\Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler']);
|
||||
$this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $route->compile(), '->compile() returned a proper route');
|
||||
$route = new Route('/', [], [], ['compiler_class' => CustomRouteCompiler::class]);
|
||||
$this->assertInstanceOf(CustomCompiledRoute::class, $route->compile(), '->compile() returned a proper route');
|
||||
|
||||
$serialized = serialize($route);
|
||||
try {
|
||||
$unserialized = unserialize($serialized);
|
||||
$this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $unserialized->compile(), 'the unserialized route compiled successfully');
|
||||
$this->assertInstanceOf(CustomCompiledRoute::class, $unserialized->compile(), 'the unserialized route compiled successfully');
|
||||
} catch (\Exception $e) {
|
||||
$this->fail('unserializing a route which uses a custom compiled route class');
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class AbstractTokenTest extends TestCase
|
||||
$token->getAttribute('foobar');
|
||||
$this->fail('->getAttribute() throws an \InvalidArgumentException exception when the attribute does not exist');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->getAttribute() throws an \InvalidArgumentException exception when the attribute does not exist');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->getAttribute() throws an \InvalidArgumentException exception when the attribute does not exist');
|
||||
$this->assertEquals('This token has no "foobar" attribute.', $e->getMessage(), '->getAttribute() throws an \InvalidArgumentException exception when the attribute does not exist');
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,14 @@ namespace Symfony\Component\Security\Http\Tests\Firewall;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Http\Firewall\RememberMeListener;
|
||||
use Symfony\Component\Security\Http\SecurityEvents;
|
||||
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
class RememberMeListenerTest extends TestCase
|
||||
@ -227,7 +229,7 @@ class RememberMeListenerTest extends TestCase
|
||||
->willReturn($token)
|
||||
;
|
||||
|
||||
$session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
|
||||
$session = $this->getMockBuilder(SessionInterface::class)->getMock();
|
||||
$session
|
||||
->expects($this->once())
|
||||
->method('isStarted')
|
||||
@ -277,7 +279,7 @@ class RememberMeListenerTest extends TestCase
|
||||
->willReturn($token)
|
||||
;
|
||||
|
||||
$session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
|
||||
$session = $this->getMockBuilder(SessionInterface::class)->getMock();
|
||||
$session
|
||||
->expects($this->once())
|
||||
->method('isStarted')
|
||||
@ -402,6 +404,6 @@ class RememberMeListenerTest extends TestCase
|
||||
|
||||
private function getSessionStrategy()
|
||||
{
|
||||
return $this->getMockBuilder('\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock();
|
||||
return $this->getMockBuilder(SessionAuthenticationStrategyInterface::class)->getMock();
|
||||
}
|
||||
}
|
||||
|
@ -863,7 +863,7 @@ XML;
|
||||
*/
|
||||
private function createMockDateTimeNormalizer(): object
|
||||
{
|
||||
$mock = $this->getMockBuilder('\Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock();
|
||||
$mock = $this->getMockBuilder(CustomNormalizer::class)->getMock();
|
||||
|
||||
$mock
|
||||
->expects($this->once())
|
||||
|
@ -232,7 +232,7 @@ class SerializerTest extends TestCase
|
||||
{
|
||||
$serializer = new Serializer([new GetSetMethodNormalizer()], ['json' => new JsonEncoder()]);
|
||||
$data = ['title' => 'foo', 'numbers' => [5, 3]];
|
||||
$result = $serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
|
||||
$result = $serializer->deserialize(json_encode($data), Model::class, 'json');
|
||||
$this->assertEquals($data, $result->toArray());
|
||||
}
|
||||
|
||||
@ -240,9 +240,9 @@ class SerializerTest extends TestCase
|
||||
{
|
||||
$serializer = new Serializer([new GetSetMethodNormalizer()], ['json' => new JsonEncoder()]);
|
||||
$data = ['title' => 'foo', 'numbers' => [5, 3]];
|
||||
$serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
|
||||
$serializer->deserialize(json_encode($data), Model::class, 'json');
|
||||
$data = ['title' => 'bar', 'numbers' => [2, 8]];
|
||||
$result = $serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
|
||||
$result = $serializer->deserialize(json_encode($data), Model::class, 'json');
|
||||
$this->assertEquals($data, $result->toArray());
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ class SerializerTest extends TestCase
|
||||
$this->expectException('Symfony\Component\Serializer\Exception\LogicException');
|
||||
$serializer = new Serializer([], ['json' => new JsonEncoder()]);
|
||||
$data = ['title' => 'foo', 'numbers' => [5, 3]];
|
||||
$serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
|
||||
$serializer->deserialize(json_encode($data), Model::class, 'json');
|
||||
}
|
||||
|
||||
public function testDeserializeWrongNormalizer()
|
||||
@ -259,7 +259,7 @@ class SerializerTest extends TestCase
|
||||
$this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
|
||||
$serializer = new Serializer([new CustomNormalizer()], ['json' => new JsonEncoder()]);
|
||||
$data = ['title' => 'foo', 'numbers' => [5, 3]];
|
||||
$serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
|
||||
$serializer->deserialize(json_encode($data), Model::class, 'json');
|
||||
}
|
||||
|
||||
public function testDeserializeNoEncoder()
|
||||
@ -267,14 +267,14 @@ class SerializerTest extends TestCase
|
||||
$this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
|
||||
$serializer = new Serializer([], []);
|
||||
$data = ['title' => 'foo', 'numbers' => [5, 3]];
|
||||
$serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
|
||||
$serializer->deserialize(json_encode($data), Model::class, 'json');
|
||||
}
|
||||
|
||||
public function testDeserializeSupported()
|
||||
{
|
||||
$serializer = new Serializer([new GetSetMethodNormalizer()], []);
|
||||
$data = ['title' => 'foo', 'numbers' => [5, 3]];
|
||||
$this->assertTrue($serializer->supportsDenormalization(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json'));
|
||||
$this->assertTrue($serializer->supportsDenormalization(json_encode($data), Model::class, 'json'));
|
||||
}
|
||||
|
||||
public function testDeserializeNotSupported()
|
||||
@ -288,7 +288,7 @@ class SerializerTest extends TestCase
|
||||
{
|
||||
$serializer = new Serializer([], []);
|
||||
$data = ['title' => 'foo', 'numbers' => [5, 3]];
|
||||
$this->assertFalse($serializer->supportsDenormalization(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json'));
|
||||
$this->assertFalse($serializer->supportsDenormalization(json_encode($data), Model::class, 'json'));
|
||||
}
|
||||
|
||||
public function testEncode()
|
||||
|
@ -66,7 +66,7 @@ class SlotsHelperTest extends TestCase
|
||||
$this->fail('->start() throws an InvalidArgumentException if a slot with the same name is already started');
|
||||
} catch (\Exception $e) {
|
||||
$helper->stop();
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->start() throws an InvalidArgumentException if a slot with the same name is already started');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->start() throws an InvalidArgumentException if a slot with the same name is already started');
|
||||
$this->assertEquals('A slot named "bar" is already started.', $e->getMessage(), '->start() throws an InvalidArgumentException if a slot with the same name is already started');
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ class SlotsHelperTest extends TestCase
|
||||
$helper->stop();
|
||||
$this->fail('->stop() throws an LogicException if no slot is started');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\LogicException', $e, '->stop() throws an LogicException if no slot is started');
|
||||
$this->assertInstanceOf(\LogicException::class, $e, '->stop() throws an LogicException if no slot is started');
|
||||
$this->assertEquals('No slot started.', $e->getMessage(), '->stop() throws an LogicException if no slot is started');
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class PhpEngineTest extends TestCase
|
||||
$engine['bar'];
|
||||
$this->fail('->offsetGet() throws an InvalidArgumentException if the helper is not defined');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->offsetGet() throws an InvalidArgumentException if the helper is not defined');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->offsetGet() throws an InvalidArgumentException if the helper is not defined');
|
||||
$this->assertEquals('The helper "bar" is not defined.', $e->getMessage(), '->offsetGet() throws an InvalidArgumentException if the helper is not defined');
|
||||
}
|
||||
}
|
||||
@ -72,7 +72,7 @@ class PhpEngineTest extends TestCase
|
||||
$engine->get('foobar');
|
||||
$this->fail('->get() throws an InvalidArgumentException if the helper is not defined');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws an InvalidArgumentException if the helper is not defined');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->get() throws an InvalidArgumentException if the helper is not defined');
|
||||
$this->assertEquals('The helper "foobar" is not defined.', $e->getMessage(), '->get() throws an InvalidArgumentException if the helper is not defined');
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ class PhpEngineTest extends TestCase
|
||||
$foo = new \Symfony\Component\Templating\Tests\Fixtures\SimpleHelper('foo');
|
||||
$engine->set($foo);
|
||||
|
||||
$this->expectException('\LogicException');
|
||||
$this->expectException(\LogicException::class);
|
||||
|
||||
unset($engine['foo']);
|
||||
}
|
||||
@ -99,7 +99,7 @@ class PhpEngineTest extends TestCase
|
||||
$engine->render('name');
|
||||
$this->fail('->render() throws an InvalidArgumentException if the template does not exist');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->render() throws an InvalidArgumentException if the template does not exist');
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->render() throws an InvalidArgumentException if the template does not exist');
|
||||
$this->assertEquals('The template "name" does not exist.', $e->getMessage(), '->render() throws an InvalidArgumentException if the template does not exist');
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Validator\Constraints;
|
||||
|
||||
use Egulias\EmailValidator\EmailValidator as EguliasEmailValidator;
|
||||
use Egulias\EmailValidator\Validation\EmailValidation;
|
||||
use Egulias\EmailValidator\Validation\NoRFCWarningsValidation;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
@ -77,7 +78,7 @@ class EmailValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
if (Email::VALIDATION_MODE_STRICT === $constraint->mode) {
|
||||
$strictValidator = new \Egulias\EmailValidator\EmailValidator();
|
||||
$strictValidator = new EguliasEmailValidator();
|
||||
|
||||
if (interface_exists(EmailValidation::class) && !$strictValidator->isValid($value, new NoRFCWarningsValidation())) {
|
||||
$this->context->buildViolation($constraint->message)
|
||||
|
@ -116,7 +116,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
$loader = new XmlFileLoader(__DIR__.'/withdoctype.xml');
|
||||
$metadata = new ClassMetadata(Entity::class);
|
||||
|
||||
$this->expectException('\Symfony\Component\Validator\Exception\MappingException');
|
||||
$this->expectException(MappingException::class);
|
||||
$loader->loadClassMetadata($metadata);
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
try {
|
||||
$loader->loadClassMetadata($metadata);
|
||||
} catch (MappingException $e) {
|
||||
$this->expectException('\Symfony\Component\Validator\Exception\MappingException');
|
||||
$this->expectException(MappingException::class);
|
||||
$loader->loadClassMetadata($metadata);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
$loader->loadClassMetadata($metadata);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// Call again. Again an exception should be thrown
|
||||
$this->expectException('\InvalidArgumentException');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$loader->loadClassMetadata($metadata);
|
||||
}
|
||||
}
|
||||
@ -87,7 +87,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
public function testLoadClassMetadataReturnsFalseIfNotSuccessful()
|
||||
{
|
||||
$loader = new YamlFileLoader(__DIR__.'/constraint-mapping.yml');
|
||||
$metadata = new ClassMetadata('\stdClass');
|
||||
$metadata = new ClassMetadata(\stdClass::class);
|
||||
|
||||
$this->assertFalse($loader->loadClassMetadata($metadata));
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class ParserTest extends TestCase
|
||||
|
||||
$this->fail('YAML files must not contain tabs');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\Exception', $e, 'YAML files must not contain tabs');
|
||||
$this->assertInstanceOf(\Exception::class, $e, 'YAML files must not contain tabs');
|
||||
$this->assertEquals('A YAML file cannot contain tabs as indentation at line 2 (near "'.strpbrk($yaml, "\t").'").', $e->getMessage(), 'YAML files must not contain tabs');
|
||||
}
|
||||
}
|
||||
@ -1414,7 +1414,7 @@ EOT;
|
||||
*/
|
||||
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
|
||||
{
|
||||
$this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
|
||||
$this->expectException(ParseException::class);
|
||||
$this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
|
||||
|
||||
$this->parser->parse($yaml);
|
||||
|
Reference in New Issue
Block a user