FlashExtensionSpec   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

10 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 6 1
A it_should_be_a_twig_extension() 0 4 1
A it_should_be_named_flash() 0 4 1
A it_should_register_a_flashes_token_parser() 0 6 1
A its_renderMessage_should_render_a_message_instance() 0 6 1
A its_renderMessage_should_allow_to_specify_a_custom_catalog() 0 6 1
A its_renderMessage_should_not_change_non_message_values() 0 6 1
A its_getFlashes_should_return_all_the_flashes() 0 6 1
A its_getFlashes_should_allow_to_specify_a_single_type() 0 9 1
A its_getFlashes_should_allow_to_specify_an_array_of_types() 0 11 1
1
<?php
2
3
namespace spec\Knp\RadBundle\Twig;
4
5
use PhpSpec\ObjectBehavior;
6
7
class FlashExtensionSpec extends ObjectBehavior
8
{
9
    /**
10
     * @param  Knp\RadBundle\Flash\Message                                      $flash
0 ignored issues
show
Bug introduced by
There is no parameter named $flash. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
11
     * @param  Knp\RadBundle\Flash\MessageRenderer                              $renderer
12
     * @param  Symfony\Component\HttpFoundation\Session\Session                 $session
13
     * @param  Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface $flashes
14
     */
15
    function let($renderer, $session, $flashes)
16
    {
17
        $this->beConstructedWith($renderer, $session);
18
19
        $session->getFlashBag()->willReturn($flashes);
20
    }
21
22
    function it_should_be_a_twig_extension()
0 ignored issues
show
Coding Style introduced by
Method name "FlashExtensionSpec::it_should_be_a_twig_extension" is not in camel caps format
Loading history...
23
    {
24
        $this->shouldBeAnInstanceOf('Twig_ExtensionInterface');
25
    }
26
27
    function it_should_be_named_flash()
0 ignored issues
show
Coding Style introduced by
Method name "FlashExtensionSpec::it_should_be_named_flash" is not in camel caps format
Loading history...
28
    {
29
        $this->getName()->shouldReturn('flash');
30
    }
31
32
    function it_should_register_a_flashes_token_parser()
0 ignored issues
show
Coding Style introduced by
Method name "FlashExtensionSpec::it_should_register_a_flashes_token_parser" is not in camel caps format
Loading history...
33
    {
34
        $parsers = $this->getTokenParsers();
35
        $parsers->shouldHaveCount(1);
36
        $parsers[0]->shouldBeAnInstanceOf('Knp\RadBundle\Twig\FlashesTokenParser');
37
    }
38
39
    function its_renderMessage_should_render_a_message_instance($renderer, $flash)
0 ignored issues
show
Coding Style introduced by
Method name "FlashExtensionSpec::its_renderMessage_should_render_a_message_instance" is not in camel caps format
Loading history...
40
    {
41
        $renderer->render($flash, null)->shouldBeCalled()->willReturn('Rendered flash');
42
43
        $this->renderMessage($flash)->shouldReturn('Rendered flash');
44
    }
45
46
    function its_renderMessage_should_allow_to_specify_a_custom_catalog($renderer, $flash)
0 ignored issues
show
Coding Style introduced by
Method name "FlashExtensionSpec::its_renderMessage_should_allow_to_specify_a_custom_catalog" is not in camel caps format
Loading history...
47
    {
48
        $renderer->render($flash, 'custom_catalog')->shouldBeCalled()->willReturn('Rendered flash');
49
50
        $this->renderMessage($flash, 'custom_catalog')->shouldReturn('Rendered flash');
51
    }
52
53
    function its_renderMessage_should_not_change_non_message_values($renderer)
0 ignored issues
show
Coding Style introduced by
Method name "FlashExtensionSpec::its_renderMessage_should_not_change_non_message_values" is not in camel caps format
Loading history...
54
    {
55
        $renderer->render(\Prophecy\Argument::cetera())->shouldNotBeCalled();
56
57
        $this->renderMessage('Some string')->shouldReturn('Some string');
58
    }
59
60
    function its_getFlashes_should_return_all_the_flashes($flashes)
0 ignored issues
show
Coding Style introduced by
Method name "FlashExtensionSpec::its_getFlashes_should_return_all_the_flashes" is not in camel caps format
Loading history...
61
    {
62
        $flashes->all()->shouldBeCalled()->willReturn(array('success' => array('some success')));
63
64
        $this->getFlashes()->shouldReturn(array('success' => array('some success')));
65
    }
66
67
    function its_getFlashes_should_allow_to_specify_a_single_type($flashes)
0 ignored issues
show
Coding Style introduced by
Method name "FlashExtensionSpec::its_getFlashes_should_allow_to_specify_a_single_type" is not in camel caps format
Loading history...
68
    {
69
        $flashes->all()->shouldNotBeCalled();
70
        $flashes->get('success', array())->shouldBeCalled()->willReturn(array('first success', 'second success'));
71
72
        $this->getFlashes('success')->shouldReturn(array(
73
            'success' => array('first success', 'second success'),
74
        ));
75
    }
76
77
    function its_getFlashes_should_allow_to_specify_an_array_of_types($flashes)
0 ignored issues
show
Coding Style introduced by
Method name "FlashExtensionSpec::its_getFlashes_should_allow_to_specify_an_array_of_types" is not in camel caps format
Loading history...
78
    {
79
        $flashes->all()->shouldNotBeCalled();
80
        $flashes->get('success', array())->shouldBeCalled()->willReturn(array('first success', 'second success'));
81
        $flashes->get('failure', array())->shouldBeCalled()->willReturn(array('first failure', 'second failure'));
82
83
        $this->getFlashes(array('success', 'failure'))->shouldReturn(array(
84
            'success' => array('first success', 'second success'),
85
            'failure' => array('first failure', 'second failure')
86
        ));
87
    }
88
}
89