Passed
Push — issue#767 ( 011dde...50feef )
by Guilherme
05:46
created

LoggableTest::testGetAliasName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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\APIBundle\Tests\Security\Audit\Annotation;
12
13
use LoginCidadao\APIBundle\Entity\ActionLog;
14
use LoginCidadao\APIBundle\Security\Audit\Annotation\Loggable;
15
16
class LoggableTest extends \PHPUnit_Framework_TestCase
17
{
18
19
    public function testActionLogId()
20
    {
21
        $id = 'actionLogId';
22
        $loggable = new Loggable([]);
23
        $loggable->setActionLogId($id);
24
25
        $this->assertSame($id, $loggable->getActionLogId());
26
    }
27
28
    public function testType()
29
    {
30
        $loggable = new Loggable(['type' => ActionLog::TYPE_CREATE]);
31
        $this->assertSame(ActionLog::TYPE_CREATE, $loggable->getType());
32
33
        $validTypes = [
34
            ActionLog::TYPE_CREATE,
35
            ActionLog::TYPE_DELETE,
36
            ActionLog::TYPE_SELECT,
37
            ActionLog::TYPE_UPDATE,
38
            ActionLog::TYPE_LOGIN,
39
        ];
40
41
        foreach ($validTypes as $type) {
42
            $loggable->setType($type);
43
            $this->assertSame($type, $loggable->getType());
44
        }
45
46
        $loggable->setType('InvalidType');
47
        $this->assertSame('UNKNOWN', $loggable->getType());
48
    }
49
50
    public function testAllowArray()
51
    {
52
        $loggable = new Loggable([]);
53
        $this->assertTrue($loggable->allowArray());
54
    }
55
56
    public function testGetAliasName()
57
    {
58
        $loggable = new Loggable([]);
59
        $this->assertSame('loggable', $loggable->getAliasName());
60
    }
61
}
62