|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace LoginCidadao\CoreBundle\Tests\Helper; |
|
12
|
|
|
|
|
13
|
|
|
use LoginCidadao\CoreBundle\Helper\ExtremeNotificationsHelper; |
|
14
|
|
|
use Symfony\Component\HttpFoundation\Session\Session; |
|
15
|
|
|
use Symfony\Component\Translation\TranslatorInterface; |
|
16
|
|
|
|
|
17
|
|
|
class ExtremeNotificationsHelperTest extends \PHPUnit_Framework_TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
public function testHelper() |
|
21
|
|
|
{ |
|
22
|
|
|
$id = 'the.message.id'; |
|
23
|
|
|
$number = 3; |
|
24
|
|
|
$parameters = ['param1' => 'value1', 'param2' => 'value2']; |
|
25
|
|
|
$translated = 'the translated message'; |
|
26
|
|
|
|
|
27
|
|
|
$flashBag = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface') |
|
28
|
|
|
->disableOriginalConstructor()->getMock(); |
|
29
|
|
|
$flashBag->expects($this->exactly(2)) |
|
30
|
|
|
->method('add') |
|
31
|
|
|
->with('alert.unconfirmed.email', $translated); |
|
32
|
|
|
|
|
33
|
|
|
/** @var Session|\PHPUnit_Framework_MockObject_MockObject $session */ |
|
34
|
|
|
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session'); |
|
35
|
|
|
$session->expects($this->exactly(2))->method('getFlashBag')->willReturn($flashBag); |
|
36
|
|
|
|
|
37
|
|
|
/** @var TranslatorInterface|\PHPUnit_Framework_MockObject_MockObject $translator */ |
|
38
|
|
|
$translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); |
|
39
|
|
|
$translator->expects($this->once())->method('trans')->with($id, $parameters)->willReturn($translated); |
|
40
|
|
|
$translator->expects($this->once())->method('transChoice')->with($id, $number, $parameters) |
|
41
|
|
|
->willReturn($translated); |
|
42
|
|
|
|
|
43
|
|
|
$helper = new ExtremeNotificationsHelper($session, $translator); |
|
44
|
|
|
$helper->add($id, $parameters); |
|
45
|
|
|
$helper->addTransChoice($id, $number, $parameters); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|