a219f860078b797527f88d5474bcf6a8bde4f36f
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Compiler / ResolveTaggedIteratorArgumentPassTest.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\DependencyInjection\Tests\Compiler;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
16 use Symfony\Component\DependencyInjection\Compiler\ResolveTaggedIteratorArgumentPass;
17 use Symfony\Component\DependencyInjection\ContainerBuilder;
18 use Symfony\Component\DependencyInjection\Reference;
19
20 /**
21  * @author Roland Franssen <franssen.roland@gmail.com>
22  */
23 class ResolveTaggedIteratorArgumentPassTest extends TestCase
24 {
25     public function testProcess()
26     {
27         $container = new ContainerBuilder();
28         $container->register('a', 'stdClass')->addTag('foo');
29         $container->register('b', 'stdClass')->addTag('foo', array('priority' => 20));
30         $container->register('c', 'stdClass')->addTag('foo', array('priority' => 10));
31         $container->register('d', 'stdClass')->setProperty('foos', new TaggedIteratorArgument('foo'));
32
33         (new ResolveTaggedIteratorArgumentPass())->process($container);
34
35         $properties = $container->getDefinition('d')->getProperties();
36         $expected = new TaggedIteratorArgument('foo');
37         $expected->setValues(array(new Reference('b'), new Reference('c'), new Reference('a')));
38         $this->assertEquals($expected, $properties['foos']);
39     }
40 }