|
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) |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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
|
|
|
|