FormTypeExtensionDefinitionFactorySpec   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 7 1
A it_should_create_form_type_definition_for_the_given_class_name() 0 12 1
A it_should_add_method_call_to_inject_container_for_container_aware_extensions() 0 12 1
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)
0 ignored issues
show
Coding Style introduced by
Method name "FormTypeExtensionDefinitionFactorySpec::it_should_create_form_type_definition_for_the_given_class_name" is not in camel caps format
Loading history...
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)
0 ignored issues
show
Coding Style introduced by
Method name "FormTypeExtensionDefinitionFactorySpec::it_should_add_method_call_to_inject_container_for_container_aware_extensions" is not in camel caps format
Loading history...
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