|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
| 16 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
16 | 17 | use Symfony\Component\DependencyInjection\Reference;
|
17 | 18 | use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
|
18 | 19 |
|
19 | 20 | class ConfigCachePassTest extends TestCase
|
20 | 21 | {
|
21 | 22 | public function testThatCheckersAreProcessedInPriorityOrder()
|
22 | 23 | {
|
23 |
| - $services = array( |
24 |
| - 'checker_2' => array(0 => array('priority' => 100)), |
25 |
| - 'checker_1' => array(0 => array('priority' => 200)), |
26 |
| - 'checker_3' => array(0 => array()), |
27 |
| - ); |
| 24 | + $container = new ContainerBuilder(); |
28 | 25 |
|
29 |
| - $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); |
30 |
| - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock(); |
31 |
| - |
32 |
| - $container->expects($this->atLeastOnce()) |
33 |
| - ->method('findTaggedServiceIds') |
34 |
| - ->will($this->returnValue($services)); |
35 |
| - $container->expects($this->atLeastOnce()) |
36 |
| - ->method('getDefinition') |
37 |
| - ->with('config_cache_factory') |
38 |
| - ->will($this->returnValue($definition)); |
39 |
| - |
40 |
| - $definition->expects($this->once()) |
41 |
| - ->method('replaceArgument') |
42 |
| - ->with(0, new IteratorArgument(array( |
43 |
| - new Reference('checker_1'), |
44 |
| - new Reference('checker_2'), |
45 |
| - new Reference('checker_3'), |
46 |
| - ))); |
| 26 | + $definition = $container->register('config_cache_factory')->addArgument(null); |
| 27 | + $container->register('checker_2')->addTag('config_cache.resource_checker', array('priority' => 100)); |
| 28 | + $container->register('checker_1')->addTag('config_cache.resource_checker', array('priority' => 200)); |
| 29 | + $container->register('checker_3')->addTag('config_cache.resource_checker'); |
47 | 30 |
|
48 | 31 | $pass = new ConfigCachePass();
|
49 | 32 | $pass->process($container);
|
| 33 | + |
| 34 | + $expected = new IteratorArgument(array( |
| 35 | + new Reference('checker_1'), |
| 36 | + new Reference('checker_2'), |
| 37 | + new Reference('checker_3'), |
| 38 | + )); |
| 39 | + $this->assertEquals($expected, $definition->getArgument(0)); |
50 | 40 | }
|
51 | 41 |
|
52 | 42 | public function testThatCheckersCanBeMissing()
|
|
0 commit comments