|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* (c) FSi sp. z o.o. <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace spec\FSi\Bundle\AdminBundle\DependencyInjection\Compiler; |
|
11
|
|
|
|
|
12
|
|
|
use PhpSpec\ObjectBehavior; |
|
13
|
|
|
|
|
14
|
|
|
class ContextPassSpec extends ObjectBehavior |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
|
18
|
|
|
* @param \Symfony\Component\DependencyInjection\Definition $def |
|
19
|
|
|
*/ |
|
20
|
|
|
function let($container, $def) |
|
21
|
|
|
{ |
|
22
|
|
|
$container->hasDefinition('admin.context.manager')->willReturn(true); |
|
23
|
|
|
$container->findDefinition('admin.context.manager')->willReturn($def); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
|
28
|
|
|
* @param \Symfony\Component\DependencyInjection\Definition $def |
|
29
|
|
|
* @param \Symfony\Component\DependencyInjection\Definition $fooDef |
|
30
|
|
|
*/ |
|
31
|
|
|
function it_add_context_builders_into_context_manager($container, $def, $fooDef) |
|
32
|
|
|
{ |
|
33
|
|
|
$container->findTaggedServiceIds('admin.context')->willReturn(array( |
|
34
|
|
|
'builder_foo' => array(array()), |
|
35
|
|
|
)); |
|
36
|
|
|
|
|
37
|
|
|
$container->findDefinition('builder_foo')->willReturn($fooDef); |
|
38
|
|
|
$def->replaceArgument(0, array($fooDef))->shouldBeCalled(); |
|
39
|
|
|
|
|
40
|
|
|
$this->process($container); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
|
45
|
|
|
* @param \Symfony\Component\DependencyInjection\Definition $def |
|
46
|
|
|
* @param \Symfony\Component\DependencyInjection\Definition $fooDef |
|
47
|
|
|
* @param \Symfony\Component\DependencyInjection\Definition $barDef |
|
48
|
|
|
* @param \Symfony\Component\DependencyInjection\Definition $bazDef |
|
49
|
|
|
*/ |
|
50
|
|
|
public function it_add_builders_in_priority_order($container, $def, $fooDef, $barDef, $bazDef) |
|
51
|
|
|
{ |
|
52
|
|
|
$container->findTaggedServiceIds('admin.context')->willReturn(array( |
|
53
|
|
|
'builder_baz' => array(array('priority' => -10)), |
|
54
|
|
|
'builder_bar' => array(array()), |
|
55
|
|
|
'builder_foo' => array(array('priority' => 5)), |
|
56
|
|
|
)); |
|
57
|
|
|
|
|
58
|
|
|
$container->findDefinition('builder_foo')->willReturn($fooDef); |
|
59
|
|
|
$container->findDefinition('builder_bar')->willReturn($barDef); |
|
60
|
|
|
$container->findDefinition('builder_baz')->willReturn($bazDef); |
|
61
|
|
|
$def->replaceArgument(0, array($fooDef, $barDef, $bazDef))->shouldBeCalled(); |
|
62
|
|
|
|
|
63
|
|
|
$this->process($container); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|