|
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 |
|
|
|
|
|
|
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() |
|
|
|
|
|
|
23
|
|
|
{ |
|
24
|
|
|
$this->shouldBeAnInstanceOf('Twig_ExtensionInterface'); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
function it_should_be_named_flash() |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
$this->getName()->shouldReturn('flash'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
function it_should_register_a_flashes_token_parser() |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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
|
|
|
|
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
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.