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\DependencyInjection\Tests\Compiler;
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;
21 * @author Roland Franssen <franssen.roland@gmail.com>
23 class ResolveTaggedIteratorArgumentPassTest extends TestCase
25 public function testProcess()
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'));
33 (new ResolveTaggedIteratorArgumentPass())->process($container);
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']);