58aeda682689f8e8df6b59adac799d3572c1f57e
[yaffs-website] / vendor / symfony / config / Tests / DependencyInjection / ConfigCachePassTest.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\Config\Tests\DependencyInjection;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
16 use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
17 use Symfony\Component\DependencyInjection\ContainerBuilder;
18 use Symfony\Component\DependencyInjection\Reference;
19
20 /**
21  * @group legacy
22  */
23 class ConfigCachePassTest extends TestCase
24 {
25     public function testThatCheckersAreProcessedInPriorityOrder()
26     {
27         $container = new ContainerBuilder();
28
29         $definition = $container->register('config_cache_factory')->addArgument(null);
30         $container->register('checker_2')->addTag('config_cache.resource_checker', array('priority' => 100));
31         $container->register('checker_1')->addTag('config_cache.resource_checker', array('priority' => 200));
32         $container->register('checker_3')->addTag('config_cache.resource_checker');
33
34         $pass = new ConfigCachePass();
35         $pass->process($container);
36
37         $expected = new IteratorArgument(array(
38             new Reference('checker_1'),
39             new Reference('checker_2'),
40             new Reference('checker_3'),
41         ));
42         $this->assertEquals($expected, $definition->getArgument(0));
43     }
44
45     public function testThatCheckersCanBeMissing()
46     {
47         $container = new ContainerBuilder();
48
49         $definitionsBefore = \count($container->getDefinitions());
50         $aliasesBefore = \count($container->getAliases());
51
52         $pass = new ConfigCachePass();
53         $pass->process($container);
54
55         // the container is untouched (i.e. no new definitions or aliases)
56         $this->assertCount($definitionsBefore, $container->getDefinitions());
57         $this->assertCount($aliasesBefore, $container->getAliases());
58     }
59 }