updated packages
This commit is contained in:
@@ -24,76 +24,76 @@ class AddAnnotatedClassesToCachePassTest extends TestCase
|
||||
$r->setAccessible(true);
|
||||
$expand = $r->getClosure($pass);
|
||||
|
||||
$this->assertSame('Foo', $expand(array('Foo'), array())[0]);
|
||||
$this->assertSame('Foo', $expand(array('\\Foo'), array())[0]);
|
||||
$this->assertSame('Foo', $expand(array('Foo'), array('\\Foo'))[0]);
|
||||
$this->assertSame('Foo', $expand(array('Foo'), array('Foo'))[0]);
|
||||
$this->assertSame('Foo', $expand(array('\\Foo'), array('\\Foo\\Bar'))[0]);
|
||||
$this->assertSame('Foo', $expand(array('Foo'), array('\\Foo\\Bar'))[0]);
|
||||
$this->assertSame('Foo', $expand(array('\\Foo'), array('\\Foo\\Bar\\Acme'))[0]);
|
||||
$this->assertSame('Foo', $expand(['Foo'], [])[0]);
|
||||
$this->assertSame('Foo', $expand(['\\Foo'], [])[0]);
|
||||
$this->assertSame('Foo', $expand(['Foo'], ['\\Foo'])[0]);
|
||||
$this->assertSame('Foo', $expand(['Foo'], ['Foo'])[0]);
|
||||
$this->assertSame('Foo', $expand(['\\Foo'], ['\\Foo\\Bar'])[0]);
|
||||
$this->assertSame('Foo', $expand(['Foo'], ['\\Foo\\Bar'])[0]);
|
||||
$this->assertSame('Foo', $expand(['\\Foo'], ['\\Foo\\Bar\\Acme'])[0]);
|
||||
|
||||
$this->assertSame('Foo\\Bar', $expand(array('Foo\\'), array('\\Foo\\Bar'))[0]);
|
||||
$this->assertSame('Foo\\Bar\\Acme', $expand(array('Foo\\'), array('\\Foo\\Bar\\Acme'))[0]);
|
||||
$this->assertEmpty($expand(array('Foo\\'), array('\\Foo')));
|
||||
$this->assertSame('Foo\\Bar', $expand(['Foo\\'], ['\\Foo\\Bar'])[0]);
|
||||
$this->assertSame('Foo\\Bar\\Acme', $expand(['Foo\\'], ['\\Foo\\Bar\\Acme'])[0]);
|
||||
$this->assertEmpty($expand(['Foo\\'], ['\\Foo']));
|
||||
|
||||
$this->assertSame('Acme\\Foo\\Bar', $expand(array('**\\Foo\\'), array('\\Acme\\Foo\\Bar'))[0]);
|
||||
$this->assertEmpty($expand(array('**\\Foo\\'), array('\\Foo\\Bar')));
|
||||
$this->assertEmpty($expand(array('**\\Foo\\'), array('\\Acme\\Foo')));
|
||||
$this->assertEmpty($expand(array('**\\Foo\\'), array('\\Foo')));
|
||||
$this->assertSame('Acme\\Foo\\Bar', $expand(['**\\Foo\\'], ['\\Acme\\Foo\\Bar'])[0]);
|
||||
$this->assertEmpty($expand(['**\\Foo\\'], ['\\Foo\\Bar']));
|
||||
$this->assertEmpty($expand(['**\\Foo\\'], ['\\Acme\\Foo']));
|
||||
$this->assertEmpty($expand(['**\\Foo\\'], ['\\Foo']));
|
||||
|
||||
$this->assertSame('Acme\\Foo', $expand(array('**\\Foo'), array('\\Acme\\Foo'))[0]);
|
||||
$this->assertEmpty($expand(array('**\\Foo'), array('\\Acme\\Foo\\AcmeBundle')));
|
||||
$this->assertEmpty($expand(array('**\\Foo'), array('\\Acme\\FooBar\\AcmeBundle')));
|
||||
$this->assertSame('Acme\\Foo', $expand(['**\\Foo'], ['\\Acme\\Foo'])[0]);
|
||||
$this->assertEmpty($expand(['**\\Foo'], ['\\Acme\\Foo\\AcmeBundle']));
|
||||
$this->assertEmpty($expand(['**\\Foo'], ['\\Acme\\FooBar\\AcmeBundle']));
|
||||
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\*\\Bar'), array('\\Foo\\Acme\\Bar'))[0]);
|
||||
$this->assertEmpty($expand(array('Foo\\*\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar')));
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\*\\Bar'], ['\\Foo\\Acme\\Bar'])[0]);
|
||||
$this->assertEmpty($expand(['Foo\\*\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar']));
|
||||
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\**\\Bar'), array('\\Foo\\Acme\\Bar'))[0]);
|
||||
$this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(array('Foo\\**\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))[0]);
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\**\\Bar'], ['\\Foo\\Acme\\Bar'])[0]);
|
||||
$this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(['Foo\\**\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar'])[0]);
|
||||
|
||||
$this->assertSame('Acme\\Bar', $expand(array('*\\Bar'), array('\\Acme\\Bar'))[0]);
|
||||
$this->assertEmpty($expand(array('*\\Bar'), array('\\Bar')));
|
||||
$this->assertEmpty($expand(array('*\\Bar'), array('\\Foo\\Acme\\Bar')));
|
||||
$this->assertSame('Acme\\Bar', $expand(['*\\Bar'], ['\\Acme\\Bar'])[0]);
|
||||
$this->assertEmpty($expand(['*\\Bar'], ['\\Bar']));
|
||||
$this->assertEmpty($expand(['*\\Bar'], ['\\Foo\\Acme\\Bar']));
|
||||
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(array('**\\Bar'), array('\\Foo\\Acme\\Bar'))[0]);
|
||||
$this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(array('**\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))[0]);
|
||||
$this->assertEmpty($expand(array('**\\Bar'), array('\\Bar')));
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(['**\\Bar'], ['\\Foo\\Acme\\Bar'])[0]);
|
||||
$this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(['**\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar'])[0]);
|
||||
$this->assertEmpty($expand(['**\\Bar'], ['\\Bar']));
|
||||
|
||||
$this->assertSame('Foo\\Bar', $expand(array('Foo\\*'), array('\\Foo\\Bar'))[0]);
|
||||
$this->assertEmpty($expand(array('Foo\\*'), array('\\Foo\\Acme\\Bar')));
|
||||
$this->assertSame('Foo\\Bar', $expand(['Foo\\*'], ['\\Foo\\Bar'])[0]);
|
||||
$this->assertEmpty($expand(['Foo\\*'], ['\\Foo\\Acme\\Bar']));
|
||||
|
||||
$this->assertSame('Foo\\Bar', $expand(array('Foo\\**'), array('\\Foo\\Bar'))[0]);
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\**'), array('\\Foo\\Acme\\Bar'))[0]);
|
||||
$this->assertSame('Foo\\Bar', $expand(['Foo\\**'], ['\\Foo\\Bar'])[0]);
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\**'], ['\\Foo\\Acme\\Bar'])[0]);
|
||||
|
||||
$this->assertSame(array('Foo\\Bar'), $expand(array('Foo\\*'), array('Foo\\Bar', 'Foo\\BarTest')));
|
||||
$this->assertSame(array('Foo\\Bar', 'Foo\\BarTest'), $expand(array('Foo\\*', 'Foo\\*Test'), array('Foo\\Bar', 'Foo\\BarTest')));
|
||||
$this->assertSame(['Foo\\Bar'], $expand(['Foo\\*'], ['Foo\\Bar', 'Foo\\BarTest']));
|
||||
$this->assertSame(['Foo\\Bar', 'Foo\\BarTest'], $expand(['Foo\\*', 'Foo\\*Test'], ['Foo\\Bar', 'Foo\\BarTest']));
|
||||
|
||||
$this->assertSame(
|
||||
'Acme\\FooBundle\\Controller\\DefaultController',
|
||||
$expand(array('**Bundle\\Controller\\'), array('\\Acme\\FooBundle\\Controller\\DefaultController'))[0]
|
||||
$expand(['**Bundle\\Controller\\'], ['\\Acme\\FooBundle\\Controller\\DefaultController'])[0]
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'FooBundle\\Controller\\DefaultController',
|
||||
$expand(array('**Bundle\\Controller\\'), array('\\FooBundle\\Controller\\DefaultController'))[0]
|
||||
$expand(['**Bundle\\Controller\\'], ['\\FooBundle\\Controller\\DefaultController'])[0]
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'Acme\\FooBundle\\Controller\\Bar\\DefaultController',
|
||||
$expand(array('**Bundle\\Controller\\'), array('\\Acme\\FooBundle\\Controller\\Bar\\DefaultController'))[0]
|
||||
$expand(['**Bundle\\Controller\\'], ['\\Acme\\FooBundle\\Controller\\Bar\\DefaultController'])[0]
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'Bundle\\Controller\\Bar\\DefaultController',
|
||||
$expand(array('**Bundle\\Controller\\'), array('\\Bundle\\Controller\\Bar\\DefaultController'))[0]
|
||||
$expand(['**Bundle\\Controller\\'], ['\\Bundle\\Controller\\Bar\\DefaultController'])[0]
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'Acme\\Bundle\\Controller\\Bar\\DefaultController',
|
||||
$expand(array('**Bundle\\Controller\\'), array('\\Acme\\Bundle\\Controller\\Bar\\DefaultController'))[0]
|
||||
$expand(['**Bundle\\Controller\\'], ['\\Acme\\Bundle\\Controller\\Bar\\DefaultController'])[0]
|
||||
);
|
||||
|
||||
$this->assertSame('Foo\\Bar', $expand(array('Foo\\Bar'), array())[0]);
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\**'), array('\\Foo\\Acme\\Bar'))[0]);
|
||||
$this->assertSame('Foo\\Bar', $expand(['Foo\\Bar'], [])[0]);
|
||||
$this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\**'], ['\\Foo\\Acme\\Bar'])[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,19 +23,19 @@ class ControllerArgumentValueResolverPassTest extends TestCase
|
||||
{
|
||||
public function testServicesAreOrderedAccordingToPriority()
|
||||
{
|
||||
$services = array(
|
||||
'n3' => array(array()),
|
||||
'n1' => array(array('priority' => 200)),
|
||||
'n2' => array(array('priority' => 100)),
|
||||
);
|
||||
$services = [
|
||||
'n3' => [[]],
|
||||
'n1' => [['priority' => 200]],
|
||||
'n2' => [['priority' => 100]],
|
||||
];
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
new Reference('n1'),
|
||||
new Reference('n2'),
|
||||
new Reference('n3'),
|
||||
);
|
||||
];
|
||||
|
||||
$definition = new Definition(ArgumentResolver::class, array(null, array()));
|
||||
$definition = new Definition(ArgumentResolver::class, [null, []]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->setDefinition('argument_resolver', $definition);
|
||||
|
||||
@@ -55,19 +55,19 @@ class ControllerArgumentValueResolverPassTest extends TestCase
|
||||
|
||||
public function testInDebugWithStopWatchDefinition()
|
||||
{
|
||||
$services = array(
|
||||
'n3' => array(array()),
|
||||
'n1' => array(array('priority' => 200)),
|
||||
'n2' => array(array('priority' => 100)),
|
||||
);
|
||||
$services = [
|
||||
'n3' => [[]],
|
||||
'n1' => [['priority' => 200]],
|
||||
'n2' => [['priority' => 100]],
|
||||
];
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
new Reference('n1'),
|
||||
new Reference('n2'),
|
||||
new Reference('n3'),
|
||||
);
|
||||
];
|
||||
|
||||
$definition = new Definition(ArgumentResolver::class, array(null, array()));
|
||||
$definition = new Definition(ArgumentResolver::class, [null, []]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('debug.stopwatch', Stopwatch::class);
|
||||
$container->setDefinition('argument_resolver', $definition);
|
||||
@@ -92,9 +92,9 @@ class ControllerArgumentValueResolverPassTest extends TestCase
|
||||
|
||||
public function testInDebugWithouStopWatchDefinition()
|
||||
{
|
||||
$expected = array(new Reference('n1'));
|
||||
$expected = [new Reference('n1')];
|
||||
|
||||
$definition = new Definition(ArgumentResolver::class, array(null, array()));
|
||||
$definition = new Definition(ArgumentResolver::class, [null, []]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('n1')->addTag('controller.argument_value_resolver');
|
||||
$container->setDefinition('argument_resolver', $definition);
|
||||
@@ -110,14 +110,14 @@ class ControllerArgumentValueResolverPassTest extends TestCase
|
||||
|
||||
public function testReturningEmptyArrayWhenNoService()
|
||||
{
|
||||
$definition = new Definition(ArgumentResolver::class, array(null, array()));
|
||||
$definition = new Definition(ArgumentResolver::class, [null, []]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->setDefinition('argument_resolver', $definition);
|
||||
|
||||
$container->setParameter('kernel.debug', false);
|
||||
|
||||
(new ControllerArgumentValueResolverPass())->process($container);
|
||||
$this->assertEquals(array(), $definition->getArgument(1)->getValues());
|
||||
$this->assertEquals([], $definition->getArgument(1)->getValues());
|
||||
}
|
||||
|
||||
public function testNoArgumentResolver()
|
||||
|
||||
@@ -33,12 +33,12 @@ class FragmentRendererPassTest extends TestCase
|
||||
$builder = new ContainerBuilder();
|
||||
$fragmentHandlerDefinition = $builder->register('fragment.handler');
|
||||
$builder->register('my_content_renderer', 'Symfony\Component\DependencyInjection\Definition')
|
||||
->addTag('kernel.fragment_renderer', array('alias' => 'foo'));
|
||||
->addTag('kernel.fragment_renderer', ['alias' => 'foo']);
|
||||
|
||||
$pass = new FragmentRendererPass();
|
||||
$pass->process($builder);
|
||||
|
||||
$this->assertEquals(array(array('addRendererService', array('foo', 'my_content_renderer'))), $fragmentHandlerDefinition->getMethodCalls());
|
||||
$this->assertEquals([['addRendererService', ['foo', 'my_content_renderer']]], $fragmentHandlerDefinition->getMethodCalls());
|
||||
}
|
||||
|
||||
public function testValidContentRenderer()
|
||||
@@ -47,20 +47,20 @@ class FragmentRendererPassTest extends TestCase
|
||||
$fragmentHandlerDefinition = $builder->register('fragment.handler')
|
||||
->addArgument(null);
|
||||
$builder->register('my_content_renderer', 'Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService')
|
||||
->addTag('kernel.fragment_renderer', array('alias' => 'foo'));
|
||||
->addTag('kernel.fragment_renderer', ['alias' => 'foo']);
|
||||
|
||||
$pass = new FragmentRendererPass();
|
||||
$pass->process($builder);
|
||||
|
||||
$serviceLocatorDefinition = $builder->getDefinition((string) $fragmentHandlerDefinition->getArgument(0));
|
||||
$this->assertSame(ServiceLocator::class, $serviceLocatorDefinition->getClass());
|
||||
$this->assertEquals(array('foo' => new ServiceClosureArgument(new Reference('my_content_renderer'))), $serviceLocatorDefinition->getArgument(0));
|
||||
$this->assertEquals(['foo' => new ServiceClosureArgument(new Reference('my_content_renderer'))], $serviceLocatorDefinition->getArgument(0));
|
||||
}
|
||||
}
|
||||
|
||||
class RendererService implements FragmentRendererInterface
|
||||
{
|
||||
public function render($uri, Request $request = null, array $options = array())
|
||||
public function render($uri, Request $request = null, array $options = [])
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ class MergeExtensionConfigurationPassTest extends TestCase
|
||||
$container = new ContainerBuilder();
|
||||
$container->registerExtension(new LoadedExtension());
|
||||
$container->registerExtension(new NotLoadedExtension());
|
||||
$container->loadFromExtension('loaded', array());
|
||||
$container->loadFromExtension('loaded', []);
|
||||
|
||||
$configPass = new MergeExtensionConfigurationPass(array('loaded', 'not_loaded'));
|
||||
$configPass = new MergeExtensionConfigurationPass(['loaded', 'not_loaded']);
|
||||
$configPass->process($container);
|
||||
|
||||
$this->assertTrue($container->hasDefinition('loaded.foo'));
|
||||
|
||||
@@ -32,7 +32,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testInvalidClass()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument(array());
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', NotFound::class)
|
||||
->addTag('controller.service_arguments')
|
||||
@@ -49,10 +49,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testNoAction()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument(array());
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', RegisterTestController::class)
|
||||
->addTag('controller.service_arguments', array('argument' => 'bar'))
|
||||
->addTag('controller.service_arguments', ['argument' => 'bar'])
|
||||
;
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
@@ -66,10 +66,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testNoArgument()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument(array());
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', RegisterTestController::class)
|
||||
->addTag('controller.service_arguments', array('action' => 'fooAction'))
|
||||
->addTag('controller.service_arguments', ['action' => 'fooAction'])
|
||||
;
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
@@ -83,10 +83,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testNoService()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument(array());
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', RegisterTestController::class)
|
||||
->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar'))
|
||||
->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'bar'])
|
||||
;
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
@@ -100,10 +100,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testInvalidMethod()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument(array());
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', RegisterTestController::class)
|
||||
->addTag('controller.service_arguments', array('action' => 'barAction', 'argument' => 'bar', 'id' => 'bar_service'))
|
||||
->addTag('controller.service_arguments', ['action' => 'barAction', 'argument' => 'bar', 'id' => 'bar_service'])
|
||||
;
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
@@ -117,10 +117,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testInvalidArgument()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument(array());
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', RegisterTestController::class)
|
||||
->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'baz', 'id' => 'bar'))
|
||||
->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'baz', 'id' => 'bar'])
|
||||
;
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
@@ -130,7 +130,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testAllActions()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', RegisterTestController::class)
|
||||
->addTag('controller.service_arguments')
|
||||
@@ -141,7 +141,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
||||
|
||||
$this->assertEquals(array('foo::fooAction'), array_keys($locator));
|
||||
$this->assertEquals(['foo::fooAction'], array_keys($locator));
|
||||
$this->assertInstanceof(ServiceClosureArgument::class, $locator['foo::fooAction']);
|
||||
|
||||
$locator = $container->getDefinition((string) $locator['foo::fooAction']->getValues()[0]);
|
||||
@@ -149,18 +149,18 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
$this->assertSame(ServiceLocator::class, $locator->getClass());
|
||||
$this->assertFalse($locator->isPublic());
|
||||
|
||||
$expected = array('bar' => new ServiceClosureArgument(new TypedReference(ControllerDummy::class, ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE, 'bar')));
|
||||
$expected = ['bar' => new ServiceClosureArgument(new TypedReference(ControllerDummy::class, ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE, 'bar'))];
|
||||
$this->assertEquals($expected, $locator->getArgument(0));
|
||||
}
|
||||
|
||||
public function testExplicitArgument()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', RegisterTestController::class)
|
||||
->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar', 'id' => 'bar'))
|
||||
->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar', 'id' => 'baz')) // should be ignored, the first wins
|
||||
->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'bar', 'id' => 'bar'])
|
||||
->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'bar', 'id' => 'baz']) // should be ignored, the first wins
|
||||
;
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
@@ -169,17 +169,17 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
||||
$locator = $container->getDefinition((string) $locator['foo::fooAction']->getValues()[0]);
|
||||
|
||||
$expected = array('bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE)));
|
||||
$expected = ['bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE))];
|
||||
$this->assertEquals($expected, $locator->getArgument(0));
|
||||
}
|
||||
|
||||
public function testOptionalArgument()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', RegisterTestController::class)
|
||||
->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar', 'id' => '?bar'))
|
||||
->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'bar', 'id' => '?bar'])
|
||||
;
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
@@ -188,14 +188,14 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
||||
$locator = $container->getDefinition((string) $locator['foo::fooAction']->getValues()[0]);
|
||||
|
||||
$expected = array('bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
|
||||
$expected = ['bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE))];
|
||||
$this->assertEquals($expected, $locator->getArgument(0));
|
||||
}
|
||||
|
||||
public function testSkipSetContainer()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', ContainerAwareRegisterTestController::class)
|
||||
->addTag('controller.service_arguments');
|
||||
@@ -204,7 +204,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
$pass->process($container);
|
||||
|
||||
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
||||
$this->assertSame(array('foo::fooAction'), array_keys($locator));
|
||||
$this->assertSame(['foo::fooAction'], array_keys($locator));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +214,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testExceptionOnNonExistentTypeHint()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument(array());
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', NonExistentClassController::class)
|
||||
->addTag('controller.service_arguments');
|
||||
@@ -230,7 +230,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testExceptionOnNonExistentTypeHintDifferentNamespace()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('argument_resolver.service')->addArgument(array());
|
||||
$container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', NonExistentClassDifferentNamespaceController::class)
|
||||
->addTag('controller.service_arguments');
|
||||
@@ -242,7 +242,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testNoExceptionOnNonExistentTypeHintOptionalArg()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', NonExistentClassOptionalController::class)
|
||||
->addTag('controller.service_arguments');
|
||||
@@ -251,13 +251,13 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
$pass->process($container);
|
||||
|
||||
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
||||
$this->assertSame(array('foo::barAction', 'foo::fooAction'), array_keys($locator));
|
||||
$this->assertSame(['foo::barAction', 'foo::fooAction'], array_keys($locator));
|
||||
}
|
||||
|
||||
public function testArgumentWithNoTypeHintIsOk()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', ArgumentWithoutTypeController::class)
|
||||
->addTag('controller.service_arguments');
|
||||
@@ -272,7 +272,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testControllersAreMadePublic()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', ArgumentWithoutTypeController::class)
|
||||
->setPublic(false)
|
||||
@@ -290,10 +290,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testBindings($bindingName)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', RegisterTestController::class)
|
||||
->setBindings(array($bindingName => new Reference('foo')))
|
||||
->setBindings([$bindingName => new Reference('foo')])
|
||||
->addTag('controller.service_arguments');
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
@@ -303,17 +303,17 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
$locator = $container->getDefinition((string) $locator['foo::fooAction']->getValues()[0]);
|
||||
|
||||
$expected = array('bar' => new ServiceClosureArgument(new Reference('foo')));
|
||||
$expected = ['bar' => new ServiceClosureArgument(new Reference('foo'))];
|
||||
$this->assertEquals($expected, $locator->getArgument(0));
|
||||
}
|
||||
|
||||
public function provideBindings()
|
||||
{
|
||||
return array(
|
||||
array(ControllerDummy::class.'$bar'),
|
||||
array(ControllerDummy::class),
|
||||
array('$bar'),
|
||||
);
|
||||
return [
|
||||
[ControllerDummy::class.'$bar'],
|
||||
[ControllerDummy::class],
|
||||
['$bar'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,10 +322,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testBindScalarValueToControllerArgument($bindingKey)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('foo', ArgumentWithoutTypeController::class)
|
||||
->setBindings(array($bindingKey => '%foo%'))
|
||||
->setBindings([$bindingKey => '%foo%'])
|
||||
->addTag('controller.service_arguments');
|
||||
|
||||
$container->setParameter('foo', 'foo_val');
|
||||
@@ -350,19 +350,19 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
public function provideBindScalarValueToControllerArgument()
|
||||
{
|
||||
yield array('$someArg');
|
||||
yield array('string $someArg');
|
||||
yield ['$someArg'];
|
||||
yield ['string $someArg'];
|
||||
}
|
||||
|
||||
public function testBindingsOnChildDefinitions()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('parent', ArgumentWithoutTypeController::class);
|
||||
|
||||
$container->setDefinition('child', (new ChildDefinition('parent'))
|
||||
->setBindings(array('$someArg' => new Reference('parent')))
|
||||
->setBindings(['$someArg' => new Reference('parent')])
|
||||
->addTag('controller.service_arguments')
|
||||
);
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@ class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testProcess()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('stdClass', 'stdClass');
|
||||
$container->register(parent::class, 'stdClass');
|
||||
$container->register('c1', RemoveTestController1::class)->addTag('controller.service_arguments');
|
||||
$container->register('c2', RemoveTestController2::class)->addTag('controller.service_arguments')
|
||||
->addMethodCall('setTestCase', array(new Reference('c1')));
|
||||
->addMethodCall('setTestCase', [new Reference('c1')]);
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
$pass->process($container);
|
||||
@@ -43,19 +43,19 @@ class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase
|
||||
(new ResolveInvalidReferencesPass())->process($container);
|
||||
|
||||
$this->assertCount(1, $container->getDefinition((string) $controllers['c2::setTestCase']->getValues()[0])->getArgument(0));
|
||||
$this->assertSame(array(), $container->getDefinition((string) $controllers['c2::fooAction']->getValues()[0])->getArgument(0));
|
||||
$this->assertSame([], $container->getDefinition((string) $controllers['c2::fooAction']->getValues()[0])->getArgument(0));
|
||||
|
||||
(new RemoveEmptyControllerArgumentLocatorsPass())->process($container);
|
||||
|
||||
$controllers = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
||||
|
||||
$this->assertSame(array('c1::fooAction', 'c1:fooAction'), array_keys($controllers));
|
||||
$this->assertSame(array('bar'), array_keys($container->getDefinition((string) $controllers['c1::fooAction']->getValues()[0])->getArgument(0)));
|
||||
$this->assertSame(['c1::fooAction', 'c1:fooAction'], array_keys($controllers));
|
||||
$this->assertSame(['bar'], array_keys($container->getDefinition((string) $controllers['c1::fooAction']->getValues()[0])->getArgument(0)));
|
||||
|
||||
$expectedLog = array(
|
||||
$expectedLog = [
|
||||
'Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass: Removing service-argument resolver for controller "c2::fooAction": no corresponding services exist for the referenced types.',
|
||||
'Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass: Removing method "setTestCase" of service "c2" from controller candidates: the method is called at instantiation, thus cannot be an action.',
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertSame($expectedLog, $container->getCompiler()->getLog());
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase
|
||||
public function testInvoke()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||
|
||||
$container->register('invokable', InvokableRegisterTestController::class)
|
||||
->addTag('controller.service_arguments')
|
||||
@@ -73,7 +73,7 @@ class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase
|
||||
(new RemoveEmptyControllerArgumentLocatorsPass())->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array('invokable::__invoke', 'invokable:__invoke', 'invokable'),
|
||||
['invokable::__invoke', 'invokable:__invoke', 'invokable'],
|
||||
array_keys($container->getDefinition((string) $resolver->getArgument(0))->getArgument(0))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ class ResettableServicePassTest extends TestCase
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('one', ResettableService::class)
|
||||
->setPublic(true)
|
||||
->addTag('kernel.reset', array('method' => 'reset'));
|
||||
->addTag('kernel.reset', ['method' => 'reset']);
|
||||
$container->register('two', ClearableService::class)
|
||||
->setPublic(true)
|
||||
->addTag('kernel.reset', array('method' => 'clear'));
|
||||
->addTag('kernel.reset', ['method' => 'clear']);
|
||||
|
||||
$container->register('services_resetter', ServicesResetter::class)
|
||||
->setPublic(true)
|
||||
->setArguments(array(null, array()));
|
||||
->setArguments([null, []]);
|
||||
$container->addCompilerPass(new ResettableServicePass());
|
||||
|
||||
$container->compile();
|
||||
@@ -34,16 +34,16 @@ class ResettableServicePassTest extends TestCase
|
||||
$definition = $container->getDefinition('services_resetter');
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
new IteratorArgument(array(
|
||||
[
|
||||
new IteratorArgument([
|
||||
'one' => new Reference('one', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE),
|
||||
'two' => new Reference('two', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE),
|
||||
)),
|
||||
array(
|
||||
]),
|
||||
[
|
||||
'one' => 'reset',
|
||||
'two' => 'clear',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
$definition->getArguments()
|
||||
);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class ResettableServicePassTest extends TestCase
|
||||
$container->register(ResettableService::class)
|
||||
->addTag('kernel.reset');
|
||||
$container->register('services_resetter', ServicesResetter::class)
|
||||
->setArguments(array(null, array()));
|
||||
->setArguments([null, []]);
|
||||
$container->addCompilerPass(new ResettableServicePass());
|
||||
|
||||
$container->compile();
|
||||
@@ -68,7 +68,7 @@ class ResettableServicePassTest extends TestCase
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('services_resetter', ServicesResetter::class)
|
||||
->setArguments(array(null, array()));
|
||||
->setArguments([null, []]);
|
||||
$container->addCompilerPass(new ResettableServicePass());
|
||||
|
||||
$container->compile();
|
||||
|
||||
@@ -26,13 +26,13 @@ class ServicesResetterTest extends TestCase
|
||||
|
||||
public function testResetServices()
|
||||
{
|
||||
$resetter = new ServicesResetter(new \ArrayIterator(array(
|
||||
$resetter = new ServicesResetter(new \ArrayIterator([
|
||||
'id1' => new ResettableService(),
|
||||
'id2' => new ClearableService(),
|
||||
)), array(
|
||||
]), [
|
||||
'id1' => 'reset',
|
||||
'id2' => 'clear',
|
||||
));
|
||||
]);
|
||||
|
||||
$resetter->reset();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user