1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Knp\RadBundle\DependencyInjection\Definition; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
|
7
|
|
|
class FormTypeExtensionDefinitionFactorySpec 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\Form\Extension\WhateverTypeExtension')->willReturn($reflClass); |
20
|
|
|
$referenceFactory->createReference('service_container')->willReturn($containerRef); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
function it_should_create_form_type_definition_for_the_given_class_name($reflClass) |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
$reflClass->implementsInterface('Symfony\Component\DependencyInjection\ContainerAwareInterface')->willReturn(false); |
26
|
|
|
|
27
|
|
|
$definition = $this->createDefinition('App\Form\Extension\WhateverTypeExtension'); |
28
|
|
|
|
29
|
|
|
$definition->shouldBeAnInstanceOf('Symfony\Component\DependencyInjection\Definition'); |
30
|
|
|
$definition->getClass()->shouldBe('App\Form\Extension\WhateverTypeExtension'); |
31
|
|
|
$definition->isPublic()->shouldBe(true); |
32
|
|
|
$definition->hasTag('form.type_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\Form\Extension\WhateverTypeExtension'); |
41
|
|
|
|
42
|
|
|
$definition->shouldBeAnInstanceOf('Symfony\Component\DependencyInjection\Definition'); |
43
|
|
|
$definition->getClass()->shouldBe('App\Form\Extension\WhateverTypeExtension'); |
44
|
|
|
$definition->isPublic()->shouldBe(true); |
45
|
|
|
$definition->hasTag('form.type_extension')->shouldBe(true); |
46
|
|
|
$definition->getMethodCalls()->shouldReturn(array(array('setContainer', array($containerRef->getWrappedObject())))); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|