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\Config\Tests\DependencyInjection;
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;
23 class ConfigCachePassTest extends TestCase
25 public function testThatCheckersAreProcessedInPriorityOrder()
27 $container = new ContainerBuilder();
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');
34 $pass = new ConfigCachePass();
35 $pass->process($container);
37 $expected = new IteratorArgument(array(
38 new Reference('checker_1'),
39 new Reference('checker_2'),
40 new Reference('checker_3'),
42 $this->assertEquals($expected, $definition->getArgument(0));
45 public function testThatCheckersCanBeMissing()
47 $container = new ContainerBuilder();
49 $definitionsBefore = \count($container->getDefinitions());
50 $aliasesBefore = \count($container->getAliases());
52 $pass = new ConfigCachePass();
53 $pass->process($container);
55 // the container is untouched (i.e. no new definitions or aliases)
56 $this->assertCount($definitionsBefore, $container->getDefinitions());
57 $this->assertCount($aliasesBefore, $container->getAliases());