MessageRendererSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 8 1
A it_should_translate_the_message_using_the_default_catalog() 0 10 1
A it_should_use_the_specified_translations_catalog() 0 10 1
A it_should_use_the_messages_catalog_by_default() 0 12 1
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