UserTextTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 4
c 5
b 1
f 0
lcom 1
cbo 0
dl 0
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 19 1
A testGetTitleIndex() 0 6 1
A testGetTitleNonIndex() 0 6 1
A testGetMessage() 0 6 1
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