Passed
Push — master ( d68e51...3a82ea )
by Kyle
02:50
created

testRuleAppliesToFunctionWithNotImportedDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of PHP Mess Detector.
4
 *
5
 * Copyright (c) Manuel Pichler <[email protected]>.
6
 * All rights reserved.
7
 *
8
 * Licensed under BSD License
9
 * For full copyright and license information, please see the LICENSE file.
10
 * Redistributions of files must retain the above copyright notice.
11
 *
12
 * @author Manuel Pichler <[email protected]>
13
 * @copyright Manuel Pichler. All rights reserved.
14
 * @license https://opensource.org/licenses/bsd-license.php BSD License
15
 * @link http://phpmd.org/
16
 */
17
18
namespace PHPMD\Rule\CleanCode;
19
20
use PHPMD\AbstractTest;
21
22
/**
23
 * MissingImport Tests
24
 *
25
 * @coversDefaultClass \PHPMD\Rule\CleanCode\MissingImport
26
 */
27
class MissingImportTest extends AbstractTest
28
{
29
    /**
30
     * Tests that it does not apply to a class without any class dependencies
31
     *
32
     * @return void
33
     * @covers ::apply
34
     */
35
    public function testRuleNotAppliesToClassWithoutAnyDependencies()
36
    {
37
        $rule = new MissingImport();
38
        $rule->setReport($this->getReportMock(0));
39
        $rule->apply($this->getMethod());
40
    }
41
42
    /**
43
     * Tests that it does not apply to a class with only imported classes
44
     *
45
     * @return void
46
     * @covers ::apply
47
     * @covers ::isSelfReference
48
     */
49
    public function testRuleNotAppliesToClassWithOnlyImportedDependencies()
50
    {
51
        $rule = new MissingImport();
52
        $rule->setReport($this->getReportMock(0));
53
        $rule->apply($this->getMethod());
54
    }
55
56
    /**
57
     * Tests that it applies to a class that has fully qualified class names
58
     *
59
     * @return void
60
     * @covers ::apply
61
     * @covers ::isSelfReference
62
     */
63
    public function testRuleAppliesToClassWithNotImportedDependencies()
64
    {
65
        $rule = new MissingImport();
66
        $rule->setReport($this->getReportMock(2));
67
        $rule->apply($this->getMethod());
68
    }
69
70
    /**
71
     * Tests that it does not apply to a class that uses self references
72
     *
73
     * @return void
74
     * @covers ::apply
75
     * @covers ::isSelfReference
76
     */
77
    public function testRuleNotAppliesToClassWithSelfAndStaticCalls()
78
    {
79
        $rule = new MissingImport();
80
        $rule->setReport($this->getReportMock(0));
81
        $rule->apply($this->getMethod());
82
    }
83
84
    /**
85
     * Tests that it does not apply to a function without any class dependencies
86
     *
87
     * @return void
88
     * @covers ::apply
89
     */
90
    public function testRuleNotAppliesToFunctionWithoutAnyDependencies()
91
    {
92
        $rule = new MissingImport();
93
        $rule->setReport($this->getReportMock(0));
94
        $rule->apply($this->getFunction());
95
    }
96
97
    /**
98
     * Tests that it does not apply to a function with only imported classes
99
     *
100
     * @return void
101
     * @covers ::apply
102
     * @covers ::isSelfReference
103
     */
104
    public function testRuleNotAppliesToFunctionWithOnlyImportedDependencies()
105
    {
106
        $rule = new MissingImport();
107
        $rule->setReport($this->getReportMock(0));
108
        $rule->apply($this->getFunction());
109
    }
110
111
    /**
112
     * Tests that it applies to a function that has fully qualified class names
113
     *
114
     * @return void
115
     * @covers ::apply
116
     * @covers ::isSelfReference
117
     */
118
    public function testRuleAppliesToFunctionWithNotImportedDependencies()
119
    {
120
        $rule = new MissingImport();
121
        $rule->setReport($this->getReportMock(1));
122
        $rule->apply($this->getFunction());
123
    }
124
}
125