Completed
Pull Request — master (#244)
by Łukasz
11:47
created

ContextManagerSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_build_context_for_element() 0 7 1
A it_return_null_when_context_builders_do_not_support_element() 0 7 1
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace spec\FSi\Bundle\AdminBundle\Admin\Context;
11
12
use PhpSpec\ObjectBehavior;
13
14
class ContextManagerSpec extends ObjectBehavior
15
{
16
    /**
17
     * @param \FSi\Bundle\AdminBundle\Admin\Context\ContextInterface $context
18
     */
19
    function let($context)
20
    {
21
        $this->beConstructedWith(array($context));
22
    }
23
24
    /**
25
     * @param \FSi\Bundle\AdminBundle\Admin\Element $element
26
     * @param \FSi\Bundle\AdminBundle\Admin\Context\ContextInterface $context
27
     */
28
    function it_build_context_for_element($element, $context)
29
    {
30
        $context->supports('route_name', $element)->willReturn(true);
31
        $context->setElement($element)->shouldBeCalled();
32
33
        $this->createContext('route_name', $element)->shouldReturn($context);
34
    }
35
36
    /**
37
     * @param \FSi\Bundle\AdminBundle\Admin\Element $element
38
     * @param \FSi\Bundle\AdminBundle\Admin\Context\ContextInterface $context
39
     */
40
    function it_return_null_when_context_builders_do_not_support_element($element, $context)
41
    {
42
        $context->supports('route_name', $element)->willReturn(false);
43
        $context->setElement($element)->shouldNotBeCalled();
44
45
        $this->createContext('route_name', $element)->shouldReturn(null);
46
    }
47
}
48