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