EntityConstantsTest::testApplyEntityHasConstants()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace MS\PHPMD\Tests\Unit\Symfony2;
4
5
use MS\PHPMD\Rule\Symfony2\EntityConstants;
6
use MS\PHPMD\Tests\Unit\AbstractApplyTest;
7
8
/**
9
 * Class EntityConstantsTest
10
 *
11
 * @package MS\PHPMD\Tests\Unit\Symfony2
12
 */
13
class EntityConstantsTest extends AbstractApplyTest
14
{
15
    /**
16
     * @covers MS\PHPMD\Rule\Symfony2\EntityConstants
17
     * @covers MS\PHPMD\Rule\Symfony2\AbstractEntityRule
18
     */
19 View Code Duplication
    public function testApplyNoEntity()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
    {
21
        $node = \Mockery::mock('PHPMD\Node\ClassNode');
22
        $node->shouldReceive('getDocComment')->andReturn('');
23
        $node->shouldReceive('isAbstract')->andReturn(false);
24
25
        $this->assertRule($node, 0);
26
    }
27
28
    /**
29
     * @covers MS\PHPMD\Rule\Symfony2\EntityConstants
30
     * @covers MS\PHPMD\Rule\Symfony2\AbstractEntityRule
31
     */
32
    public function testApplyEntityHasConstants()
33
    {
34
        $node = \Mockery::mock('PHPMD\Node\ClassNode');
35
        $node->shouldReceive('getDocComment')->andReturn('* @isEntity');
36
        $node->shouldReceive('getConstants')->andReturn([1]);
37
        $node->shouldReceive('getName')->andReturn('Entity');
38
39
        $this->assertRule($node, 1);
40
    }
41
42
    /**
43
     * @return EntityConstants
44
     */
45
    protected function getRule()
46
    {
47
        $rule = new EntityConstants();
48
        $rule->addProperty('entityRegex', '(\*\s*@\S*Entity)i');
49
        $rule->addProperty('classIsEntityRegex', '(\*\s*@isEntity)i');
50
51
        return $rule;
52
    }
53
}
54