UnusedPrivateMethodTest   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 215
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 215
rs 10
c 0
b 0
f 0
wmc 16
lcom 1
cbo 2

16 Methods

Rating   Name   Duplication   Size   Complexity  
A testRuleAppliesToUnusedPrivateMethod() 0 6 1
A testRuleAppliesToUnusedStaticPrivateMethod() 0 6 1
A testRuleAppliesToParentReferencedUnusedPrivateMethod() 0 6 1
A testRuleAppliesWhenMethodIsReferencedOnDifferentObject() 0 6 1
A testRuleAppliesWhenMethodIsReferencedOnDifferentClass() 0 6 1
A testRuleAppliesWhenPropertyWithSimilarNameIsReferenced() 0 6 1
A testRuleAppliesWhenMethodWithSimilarNameIsInInvocationChain() 0 6 1
A testRuleDoesNotApplyToPrivateConstructor() 0 6 1
A testRuleDoesNotApplyToPrivatePhp4Constructor() 0 6 1
A testRuleDoesNotApplyToPrivateCloneMethod() 0 6 1
A testRuleDoesNotApplyToThisReferencedMethod() 0 6 1
A testRuleDoesNotApplyToSelfReferencedMethod() 0 6 1
A testRuleDoesNotApplyToStaticReferencedMethod() 0 6 1
A testRuleDoesNotApplyToClassNameReferencedMethod() 0 6 1
A testRuleDoesNotApplyToPrivateMethodInChainedMethodCall() 0 6 1
A testRuleDoesNotApplyToPrivateMethodInChainedMethodCallInNumberBiggerThanTwo() 0 6 1
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;
19
20
use PHPMD\AbstractTest;
21
22
/**
23
 * Test case for the unused private method rule.
24
 *
25
 * @covers \PHPMD\Rule\UnusedPrivateMethod
26
 */
27
class UnusedPrivateMethodTest extends AbstractTest
28
{
29
    /**
30
     * testRuleAppliesToUnusedPrivateMethod
31
     *
32
     * @return void
33
     */
34
    public function testRuleAppliesToUnusedPrivateMethod()
35
    {
36
        $rule = new UnusedPrivateMethod();
37
        $rule->setReport($this->getReportMock(1));
38
        $rule->apply($this->getClass());
39
    }
40
41
    /**
42
     * testRuleAppliesToUnusedStaticPrivateMethod
43
     *
44
     * @return void
45
     */
46
    public function testRuleAppliesToUnusedStaticPrivateMethod()
47
    {
48
        $rule = new UnusedPrivateMethod();
49
        $rule->setReport($this->getReportMock(1));
50
        $rule->apply($this->getClass());
51
    }
52
53
    /**
54
     * testRuleAppliesToParentReferencedUnusedPrivateMethod
55
     *
56
     * @return void
57
     */
58
    public function testRuleAppliesToParentReferencedUnusedPrivateMethod()
59
    {
60
        $rule = new UnusedPrivateMethod();
61
        $rule->setReport($this->getReportMock(1));
62
        $rule->apply($this->getClass());
63
    }
64
65
    /**
66
     * testRuleAppliesWhenMethodIsReferencedOnDifferentObject
67
     *
68
     * @return void
69
     */
70
    public function testRuleAppliesWhenMethodIsReferencedOnDifferentObject()
71
    {
72
        $rule = new UnusedPrivateMethod();
73
        $rule->setReport($this->getReportMock(1));
74
        $rule->apply($this->getClass());
75
    }
76
77
    /**
78
     * testRuleAppliesWhenMethodIsReferencedOnDifferentClass
79
     *
80
     * @return void
81
     */
82
    public function testRuleAppliesWhenMethodIsReferencedOnDifferentClass()
83
    {
84
        $rule = new UnusedPrivateMethod();
85
        $rule->setReport($this->getReportMock(1));
86
        $rule->apply($this->getClass());
87
    }
88
89
    /**
90
     * testRuleAppliesWhenPropertyWithSimilarNameIsReferenced
91
     *
92
     * @return void
93
     */
94
    public function testRuleAppliesWhenPropertyWithSimilarNameIsReferenced()
95
    {
96
        $rule = new UnusedPrivateMethod();
97
        $rule->setReport($this->getReportMock(1));
98
        $rule->apply($this->getClass());
99
    }
100
101
    /**
102
     * testRuleAppliesWhenMethodWithSimilarNameIsInInvocationChain
103
     *
104
     * <code>
105
     * class Foo {
106
     *     protected $bar;
107
     *     private function baz();
108
     *     public function doIt() {
109
     *         $this->bar->baz();
110
     *     }
111
     * }
112
     * </code>
113
     *
114
     * @return void
115
     */
116
    public function testRuleAppliesWhenMethodWithSimilarNameIsInInvocationChain()
117
    {
118
        $rule = new UnusedPrivateMethod();
119
        $rule->setReport($this->getReportMock(1));
120
        $rule->apply($this->getClass());
121
    }
122
123
    /**
124
     * testRuleDoesNotApplyToPrivateConstructor
125
     *
126
     * @return void
127
     */
128
    public function testRuleDoesNotApplyToPrivateConstructor()
129
    {
130
        $rule = new UnusedPrivateMethod();
131
        $rule->setReport($this->getReportMock(0));
132
        $rule->apply($this->getClass());
133
    }
134
135
    /**
136
     * testRuleDoesNotApplyToPrivatePhp4Constructor
137
     *
138
     * @return void
139
     */
140
    public function testRuleDoesNotApplyToPrivatePhp4Constructor()
141
    {
142
        $rule = new UnusedPrivateMethod();
143
        $rule->setReport($this->getReportMock(0));
144
        $rule->apply($this->getClass());
145
    }
146
147
    /**
148
     * testRuleDoesNotApplyToPrivateCloneMethod
149
     *
150
     * @return void
151
     */
152
    public function testRuleDoesNotApplyToPrivateCloneMethod()
153
    {
154
        $rule = new UnusedPrivateMethod();
155
        $rule->setReport($this->getReportMock(0));
156
        $rule->apply($this->getClass());
157
    }
158
159
    /**
160
     * testRuleDoesNotApplyToThisReferencedMethod
161
     *
162
     * @return void
163
     */
164
    public function testRuleDoesNotApplyToThisReferencedMethod()
165
    {
166
        $rule = new UnusedPrivateMethod();
167
        $rule->setReport($this->getReportMock(0));
168
        $rule->apply($this->getClass());
169
    }
170
171
    /**
172
     * testRuleDoesNotApplyToSelfReferencedMethod
173
     *
174
     * @return void
175
     */
176
    public function testRuleDoesNotApplyToSelfReferencedMethod()
177
    {
178
        $rule = new UnusedPrivateMethod();
179
        $rule->setReport($this->getReportMock(0));
180
        $rule->apply($this->getClass());
181
    }
182
183
    /**
184
     * testRuleDoesNotApplyToStaticReferencedMethod
185
     *
186
     * @return void
187
     */
188
    public function testRuleDoesNotApplyToStaticReferencedMethod()
189
    {
190
        $rule = new UnusedPrivateMethod();
191
        $rule->setReport($this->getReportMock(0));
192
        $rule->apply($this->getClass());
193
    }
194
195
    /**
196
     * testRuleDoesNotApplyToClassNameReferencedMethod
197
     *
198
     * @return void
199
     */
200
    public function testRuleDoesNotApplyToClassNameReferencedMethod()
201
    {
202
        $rule = new UnusedPrivateMethod();
203
        $rule->setReport($this->getReportMock(0));
204
        $rule->apply($this->getClass());
205
    }
206
207
    /**
208
     * testRuleDoesNotApplyToPrivateMethodInChainedMethodCall
209
     *
210
     * <code>
211
     * class Foo {
212
     *     private function bar() {
213
     *         return new \SplObjectStorage();
214
     *     }
215
     *     public function add($object) {
216
     *         $this->bar()->attach($object);
217
     *     }
218
     * }
219
     * </code>
220
     *
221
     * @return void
222
     */
223
    public function testRuleDoesNotApplyToPrivateMethodInChainedMethodCall()
224
    {
225
        $rule = new UnusedPrivateMethod();
226
        $rule->setReport($this->getReportMock(0));
227
        $rule->apply($this->getClass());
228
    }
229
230
    /**
231
     * testRuleDoesNotApplyToPrivateMethodInChainedMethodCallInNumberBiggerThanTwo
232
     *
233
     * @return void
234
     */
235
    public function testRuleDoesNotApplyToPrivateMethodInChainedMethodCallInNumberBiggerThanTwo()
236
    {
237
        $rule = new UnusedPrivateMethod();
238
        $rule->setReport($this->getReportMock(0));
239
        $rule->apply($this->getClass());
240
    }
241
}
242