Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / vendor / symfony / http-kernel / Tests / DependencyInjection / ControllerArgumentValueResolverPassTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
13
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;
20
21 class ControllerArgumentValueResolverPassTest extends TestCase
22 {
23     public function testServicesAreOrderedAccordingToPriority()
24     {
25         $services = array(
26             'n3' => array(array()),
27             'n1' => array(array('priority' => 200)),
28             'n2' => array(array('priority' => 100)),
29         );
30
31         $expected = array(
32             new Reference('n1'),
33             new Reference('n2'),
34             new Reference('n3'),
35         );
36
37         $definition = new Definition(ArgumentResolver::class, array(null, array()));
38         $container = new ContainerBuilder();
39         $container->setDefinition('argument_resolver', $definition);
40
41         foreach ($services as $id => list($tag)) {
42             $container->register($id)->addTag('controller.argument_value_resolver', $tag);
43         }
44
45         (new ControllerArgumentValueResolverPass())->process($container);
46         $this->assertEquals($expected, $definition->getArgument(1)->getValues());
47     }
48
49     public function testReturningEmptyArrayWhenNoService()
50     {
51         $definition = new Definition(ArgumentResolver::class, array(null, array()));
52         $container = new ContainerBuilder();
53         $container->setDefinition('argument_resolver', $definition);
54
55         (new ControllerArgumentValueResolverPass())->process($container);
56         $this->assertEquals(array(), $definition->getArgument(1)->getValues());
57     }
58
59     public function testNoArgumentResolver()
60     {
61         $container = new ContainerBuilder();
62
63         (new ControllerArgumentValueResolverPass())->process($container);
64
65         $this->assertFalse($container->hasDefinition('argument_resolver'));
66     }
67 }