1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DmCommonTest\Helper; |
4
|
|
|
|
5
|
|
|
use DmCommon\View\Helper\UserText; |
6
|
|
|
use DmCommon\DefinedConstant; |
7
|
|
|
|
8
|
|
|
class UserTextTest extends \PHPUnit_Framework_TestCase |
9
|
|
|
{ |
10
|
|
|
const ENTITY_KEY = 'template'; |
11
|
|
|
const ENTITY_SINGLUAR = 'Template'; |
12
|
|
|
const ENTITY_PLURAL = 'Templates'; |
13
|
|
|
|
14
|
|
|
/** @var UserText */ |
15
|
|
|
protected $sut; |
16
|
|
|
|
17
|
|
|
protected function setUp() |
18
|
|
|
{ |
19
|
|
|
$this->sut = new UserText(); |
20
|
|
|
|
21
|
|
|
$entities = [ |
22
|
|
|
UserText::SINGULAR => [ |
23
|
|
|
self::ENTITY_KEY => self::ENTITY_SINGLUAR, |
24
|
|
|
], |
25
|
|
|
UserText::PLURAL => [ |
26
|
|
|
self::ENTITY_KEY => self::ENTITY_PLURAL, |
27
|
|
|
] |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
$this->sut->addEntityNames($entities); |
31
|
|
|
|
32
|
|
|
$this->sut->addActions(DefinedConstant\Action::getMessages()); |
33
|
|
|
|
34
|
|
|
$this->sut->addMessages(DefinedConstant\Message::getMessages()); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @covers DmCommon\View\Helper\UserText |
39
|
|
|
*/ |
40
|
|
|
public function testGetTitleIndex() |
41
|
|
|
{ |
42
|
|
|
$result = $this->sut->getTitle(self::ENTITY_KEY, DefinedConstant\Action::INDEX); |
43
|
|
|
|
44
|
|
|
$this->assertEquals('Templates', $result); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @covers DmCommon\View\Helper\UserText |
49
|
|
|
*/ |
50
|
|
|
public function testGetTitleNonIndex() |
51
|
|
|
{ |
52
|
|
|
$result = $this->sut->getTitle(self::ENTITY_KEY, DefinedConstant\Action::UPDATE); |
53
|
|
|
|
54
|
|
|
$this->assertEquals('Update Template', $result); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @covers DmCommon\View\Helper\UserText |
59
|
|
|
*/ |
60
|
|
|
public function testGetMessage() |
61
|
|
|
{ |
62
|
|
|
$result = $this->sut->getMessage(self::ENTITY_KEY, DefinedConstant\Message::SAVE_FAILED); |
63
|
|
|
|
64
|
|
|
$this->assertEquals('Saving Template failed.', $result); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|