|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Knp\RadBundle\DependencyInjection\Definition; |
|
4
|
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
|
6
|
|
|
|
|
7
|
|
|
class SecurityVoterFactorySpec extends ObjectBehavior |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @param Knp\RadBundle\Reflection\ReflectionFactory $reflectionFactory |
|
11
|
|
|
* @param Knp\RadBundle\DependencyInjection\ReferenceFactory $referenceFactory |
|
12
|
|
|
* @param ReflectionClass $reflClass |
|
13
|
|
|
* @param Symfony\Component\DependencyInjection\Reference $containerRef |
|
14
|
|
|
*/ |
|
15
|
|
|
function let($reflectionFactory, $referenceFactory, $reflClass, $containerRef) |
|
16
|
|
|
{ |
|
17
|
|
|
$this->beConstructedWith($reflectionFactory, $referenceFactory); |
|
18
|
|
|
|
|
19
|
|
|
$reflectionFactory->createReflectionClass('App\Security\CheeseVoter')->willReturn($reflClass); |
|
20
|
|
|
$referenceFactory->createReference('service_container')->willReturn($containerRef); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
function it_should_create_a_service_definition_for_the_specified_security_voter_class($reflClass) |
|
|
|
|
|
|
24
|
|
|
{ |
|
25
|
|
|
$reflClass->implementsInterface('Symfony\Component\DependencyInjection\ContainerAwareInterface')->willReturn(false); |
|
26
|
|
|
|
|
27
|
|
|
$definition = $this->createDefinition('App\Security\CheeseVoter'); |
|
28
|
|
|
$definition->shouldBeAnInstanceOf('Symfony\Component\DependencyInjection\Definition'); |
|
29
|
|
|
$definition->getClass()->shouldReturn('App\Security\CheeseVoter'); |
|
30
|
|
|
$definition->getMethodCalls()->shouldReturn(array()); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
function it_should_add_method_call_to_inject_container_to_container_aware_voters($reflClass, $containerRef) |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
$reflClass->implementsInterface('Symfony\Component\DependencyInjection\ContainerAwareInterface')->willReturn(true); |
|
36
|
|
|
|
|
37
|
|
|
$definition = $this->createDefinition('App\Security\CheeseVoter'); |
|
38
|
|
|
$definition->shouldBeAnInstanceOf('Symfony\Component\DependencyInjection\Definition'); |
|
39
|
|
|
$definition->getClass()->shouldReturn('App\Security\CheeseVoter'); |
|
40
|
|
|
$definition->getMethodCalls()->shouldReturn(array(array('setContainer', array($containerRef->getWrappedObject())))); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|