1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Knp\RadBundle\DependencyInjection\Compiler; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Prophecy\Argument; |
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
8
|
|
|
|
9
|
|
|
class RemoveUnavailableServicesPassSpec extends ObjectBehavior |
10
|
|
|
{ |
11
|
|
|
function it_is_initializable() |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
$this->shouldHaveType('Knp\RadBundle\DependencyInjection\Compiler\RemoveUnavailableServicesPass'); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
function it_should_remove_services_when_dependant_service_does_not_exist(ContainerBuilder $container) |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
$container->findTaggedServiceIds('remove-when-missing')->willReturn(array( |
19
|
|
|
'knp_rad.form.manager' => array( |
20
|
|
|
array('service' => 'form.factory'), |
21
|
|
|
), |
22
|
|
|
)); |
23
|
|
|
|
24
|
|
|
$container->hasDefinition('form.factory')->willReturn(false); |
25
|
|
|
$container->hasAlias('form.factory')->willReturn(false); |
26
|
|
|
|
27
|
|
|
$container->removeDefinition('knp_rad.form.manager')->shouldBeCalled(); |
28
|
|
|
|
29
|
|
|
$this->process($container); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function it_should_remove_services_when_one_of_dependant_service_does_not_exist(ContainerBuilder $container) |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
$container->findTaggedServiceIds('remove-when-missing')->willReturn(array( |
35
|
|
|
'knp_rad.form.type_creator' => array( |
36
|
|
|
array('service' => 'form.factory'), |
37
|
|
|
array('service' => 'form.registry'), |
38
|
|
|
), |
39
|
|
|
)); |
40
|
|
|
|
41
|
|
|
$container->hasDefinition('form.factory')->willReturn(true); |
42
|
|
|
$container->hasAlias('form.factory')->willReturn(true); |
43
|
|
|
|
44
|
|
|
$container->hasDefinition('form.registry')->willReturn(false); |
45
|
|
|
$container->hasAlias('form.registry')->willReturn(false); |
46
|
|
|
|
47
|
|
|
$container->removeDefinition('knp_rad.form.type_creator')->shouldBeCalled(); |
48
|
|
|
|
49
|
|
|
$this->process($container); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|