Completed
Pull Request — 3.1 (#347)
by Łukasz
16:49 queued 11:36
created

ContextManagerSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_builds_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 FSi\Bundle\AdminBundle\Admin\Context\ContextInterface;
13
use FSi\Bundle\AdminBundle\Admin\Element;
14
use PhpSpec\ObjectBehavior;
15
16
class ContextManagerSpec extends ObjectBehavior
17
{
18
    function let(ContextInterface $context)
19
    {
20
        $this->beConstructedWith([$context]);
21
    }
22
23
    function it_builds_context_for_element(Element $element, ContextInterface $context)
24
    {
25
        $context->supports('route_name', $element)->willReturn(true);
26
        $context->setElement($element)->shouldBeCalled();
27
28
        $this->createContext('route_name', $element)->shouldReturn($context);
29
    }
30
31
    function it_return_null_when_context_builders_do_not_support_element(Element $element, ContextInterface $context)
32
    {
33
        $context->supports('route_name', $element)->willReturn(false);
34
        $context->setElement($element)->shouldNotBeCalled();
35
36
        $this->createContext('route_name', $element)->shouldReturn(null);
37
    }
38
}
39