MessageRendererSpec::let()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace spec\Knp\RadBundle\Flash;
4
5
use PhpSpec\ObjectBehavior;
6
7
class MessageRendererSpec extends ObjectBehavior
8
{
9
    /**
10
     * @param  Knp\RadBundle\Flash\Message                       $message
11
     * @param  Symfony\Component\Translation\TranslatorInterface $translator
12
     */
13
    function let($message, $translator)
14
    {
15
        $this->beConstructedWith($translator, 'default_catalog');
16
17
        $message->getTemplate()->willReturn('Hello {{ name }}!');
18
        $message->getParameters()->willReturn(array('{{ name }}' => 'George'));
19
        $message->getPluralization()->willReturn(123);
20
    }
21
22
    function it_should_translate_the_message_using_the_default_catalog($message, $translator)
0 ignored issues
show
Coding Style introduced by
Method name "MessageRendererSpec::it_should_translate_the_message_using_the_default_catalog" is not in camel caps format
Loading history...
23
    {
24
        $translator
25
            ->trans('Hello {{ name }}!', array('{{ name }}' => 'George'), 'default_catalog', 123)
26
            ->shouldBeCalled()
27
            ->willReturn('Bonjour George !')
28
        ;
29
30
        $this->render($message)->shouldReturn('Bonjour George !');
31
    }
32
33
    function it_should_use_the_specified_translations_catalog($message, $translator)
0 ignored issues
show
Coding Style introduced by
Method name "MessageRendererSpec::it_should_use_the_specified_translations_catalog" is not in camel caps format
Loading history...
34
    {
35
        $translator
36
            ->trans(\Prophecy\Argument::any(), \Prophecy\Argument::any(), 'custom_catalog', \Prophecy\Argument::any())
37
            ->shouldBeCalled()
38
            ->willReturn('Bonjour George !')
39
        ;
40
41
        $this->render($message, 'custom_catalog')->shouldReturn('Bonjour George !');
42
    }
43
44
    function it_should_use_the_messages_catalog_by_default($message, $translator)
0 ignored issues
show
Coding Style introduced by
Method name "MessageRendererSpec::it_should_use_the_messages_catalog_by_default" is not in camel caps format
Loading history...
45
    {
46
        $this->beConstructedWith($translator);
47
48
        $translator
49
            ->trans(\Prophecy\Argument::any(), \Prophecy\Argument::any(), 'messages', \Prophecy\Argument::any())
50
            ->shouldBeCalled()
51
            ->willReturn('Bonjour George !')
52
        ;
53
54
        $this->render($message)->shouldReturn('Bonjour George !');
55
    }
56
}
57