4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\DependencyInjection\Definition;
17 use Symfony\Component\DependencyInjection\Reference;
18 use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
19 use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
21 class ControllerArgumentValueResolverPassTest extends TestCase
23 public function testServicesAreOrderedAccordingToPriority()
26 'n3' => array(array()),
27 'n1' => array(array('priority' => 200)),
28 'n2' => array(array('priority' => 100)),
37 $definition = new Definition(ArgumentResolver::class, array(null, array()));
38 $container = new ContainerBuilder();
39 $container->setDefinition('argument_resolver', $definition);
41 foreach ($services as $id => list($tag)) {
42 $container->register($id)->addTag('controller.argument_value_resolver', $tag);
45 (new ControllerArgumentValueResolverPass())->process($container);
46 $this->assertEquals($expected, $definition->getArgument(1)->getValues());
49 public function testReturningEmptyArrayWhenNoService()
51 $definition = new Definition(ArgumentResolver::class, array(null, array()));
52 $container = new ContainerBuilder();
53 $container->setDefinition('argument_resolver', $definition);
55 (new ControllerArgumentValueResolverPass())->process($container);
56 $this->assertEquals(array(), $definition->getArgument(1)->getValues());
59 public function testNoArgumentResolver()
61 $container = new ContainerBuilder();
63 (new ControllerArgumentValueResolverPass())->process($container);
65 $this->assertFalse($container->hasDefinition('argument_resolver'));