testMethodWithNamespaceNewOperator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace MS\PHPMD\Tests\Unit\Symfony2;
4
5
use MS\PHPMD\Rule\Symfony2\ConstructorNewOperator;
6
use MS\PHPMD\Tests\Unit\AbstractApplyTest;
7
8
/**
9
 * Class ConstructorNewOperatorTest
10
 *
11
 * @package MS\PHPMD\Tests\Unit\Symfony2
12
 */
13
class ConstructorNewOperatorTest extends AbstractApplyTest
14
{
15
    /**
16
     * @covers MS\PHPMD\Rule\Symfony2\ConstructorNewOperator
17
     */
18 View Code Duplication
    public function testConstructorWithNewOperator()
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...
19
    {
20
        $node = $this->getMethodNode('TestService', '__construct', [
21
            'ClassReference' => array_fill(0, 1, $this->getNode('Reader'))
22
        ]);
23
24
        $this->assertRule($node, 1);
25
    }
26
27
    /**
28
     * @covers MS\PHPMD\Rule\Symfony2\ConstructorNewOperator
29
     */
30 View Code Duplication
    public function testConstructorWithNewAllowedClassName()
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...
31
    {
32
        $node = $this->getMethodNode('TestService', '__construct', [
33
            'ClassReference' => array_fill(0, 1, $this->getNode('\DateTime'))
34
        ]);
35
36
        $this->assertRule($node, 0);
37
    }
38
39
    /**
40
     * @covers MS\PHPMD\Rule\Symfony2\ConstructorNewOperator
41
     */
42
    public function testConstructorWithoutNewOperator()
43
    {
44
        $node = $this->getMethodNode('TestService', '__construct', [
45
            'ClassReference' => []
46
        ]);
47
48
        $this->assertRule($node, 0);
49
    }
50
51
    /**
52
     * @covers MS\PHPMD\Rule\Symfony2\ConstructorNewOperator
53
     */
54 View Code Duplication
    public function testMethodWithNewOperator()
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...
55
    {
56
        $node = $this->getMethodNode('TestService', 'doThings', [
57
            'ClassReference' => array_fill(0, 1, $this->getNode('Reader'))
58
        ]);
59
60
        $this->assertRule($node, 0);
61
    }
62
63
    /**
64
     * @covers MS\PHPMD\Rule\Symfony2\ConstructorNewOperator
65
     */
66 View Code Duplication
    public function testMethodWithNamespaceNewOperator()
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...
67
    {
68
        $node = $this->getMethodNode('TestService', 'doThings', [
69
            'ClassReference' => array_fill(0, 1, $this->getNode('Doctrine\ArrayCollection'))
70
        ]);
71
72
        $this->assertRule($node, 0);
73
    }
74
75
    /**
76
     * @return ConstructorNewOperator
77
     */
78
    protected function getRule()
79
    {
80
        $rule = new ConstructorNewOperator();
81
        $rule->addProperty('delimiter', ',');
82
        $rule->addProperty('allowedClassNames', '\DateTime,ArrayCollection');
83
84
        return $rule;
85
    }
86
}
87