Classes List

Symfony\Component\PropertyInfo\Tests\DependencyInjection\PropertyInfoPassTest

 1 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
 27 
 28 
 29 
 30 
 31 
 32 
 33 
 34 
 35 
 36 
 37 
 38 
 39 
 40 
 41 
 42 
 43 
 44 
 45 
 46 
 47 
 48 
 49 
 50 
 51 
 52 
 53 
 54 
 55 
 56 
 57 
 58 
 59 
 60 
 61 
 62 
 63 
 64 
 65 
 66 
 67 
 68 
 69 
 70 
<?php

/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */


namespace Symfony\Component\PropertyInfo\Tests\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;

class PropertyInfoPassTest extends TestCase
{
    /** * @dataProvider provideTags */
    public function testServicesAreOrderedAccordingToPriority($index$tag)
    {
        $container = new ContainerBuilder();

        $definition = $container->register('property_info')->setArguments(array(nullnullnullnull));
        $container->register('n2')->addTag($tagarray('priority' => 100));
        $container->register('n1')->addTag($tagarray('priority' => 200));
        $container->register('n3')->addTag($tag);

        $propertyInfoPass = new PropertyInfoPass();
        $propertyInfoPass->process($container);

        $expected = new IteratorArgument(array(
            new Reference('n1'),
            new Reference('n2'),
            new Reference('n3'),
        ));
        $this->assertEquals($expected$definition->getArgument($index));
    }

    public function provideTags()
    {
        return array(
            array(0'property_info.list_extractor'),
            array(1'property_info.type_extractor'),
            array(2'property_info.description_extractor'),
            array(3'property_info.access_extractor'),
        );
    }

    public function testReturningEmptyArrayWhenNoService()
    {
        $container = new ContainerBuilder();
        $propertyInfoExtractorDefinition = $container->register('property_info')
            ->setArguments(array(array(), array(), array(), array()));

        $propertyInfoPass = new PropertyInfoPass();
        $propertyInfoPass->process($container);

        $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(0));
        $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(1));
        $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(2));
        $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(3));
    }
}