1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the PHP_CodeCoverage package. |
4
|
|
|
* |
5
|
|
|
* (c) Sebastian Bergmann <[email protected]> |
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
|
|
|
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestCase.php'; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Tests for the PHP_CodeCoverage class. |
15
|
|
|
* |
16
|
|
|
* @since Class available since Release 1.0.0 |
17
|
|
|
*/ |
18
|
|
|
class PHP_CodeCoverageTest extends PHP_CodeCoverage_TestCase |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var PHP_CodeCoverage |
22
|
|
|
*/ |
23
|
|
|
private $coverage; |
24
|
|
|
|
25
|
|
|
protected function setUp() |
26
|
|
|
{ |
27
|
|
|
$this->coverage = new PHP_CodeCoverage; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @covers PHP_CodeCoverage::__construct |
32
|
|
|
* @covers PHP_CodeCoverage::filter |
33
|
|
|
*/ |
34
|
|
|
public function testConstructor() |
35
|
|
|
{ |
36
|
|
|
$this->assertAttributeInstanceOf( |
37
|
|
|
'PHP_CodeCoverage_Driver_Xdebug', |
38
|
|
|
'driver', |
39
|
|
|
$this->coverage |
40
|
|
|
); |
41
|
|
|
|
42
|
|
|
$this->assertAttributeInstanceOf( |
43
|
|
|
'PHP_CodeCoverage_Filter', |
44
|
|
|
'filter', |
45
|
|
|
$this->coverage |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @covers PHP_CodeCoverage::__construct |
51
|
|
|
* @covers PHP_CodeCoverage::filter |
52
|
|
|
*/ |
53
|
|
|
public function testConstructor2() |
54
|
|
|
{ |
55
|
|
|
$filter = new PHP_CodeCoverage_Filter; |
56
|
|
|
$coverage = new PHP_CodeCoverage(null, $filter); |
57
|
|
|
|
58
|
|
|
$this->assertAttributeInstanceOf( |
59
|
|
|
'PHP_CodeCoverage_Driver_Xdebug', |
60
|
|
|
'driver', |
61
|
|
|
$coverage |
62
|
|
|
); |
63
|
|
|
|
64
|
|
|
$this->assertSame($filter, $coverage->filter()); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @covers PHP_CodeCoverage::start |
69
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
70
|
|
|
*/ |
71
|
|
|
public function testStartThrowsExceptionForInvalidArgument() |
72
|
|
|
{ |
73
|
|
|
$this->coverage->start(null, [], null); |
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @covers PHP_CodeCoverage::stop |
78
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
79
|
|
|
*/ |
80
|
|
|
public function testStopThrowsExceptionForInvalidArgument() |
81
|
|
|
{ |
82
|
|
|
$this->coverage->stop(null); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @covers PHP_CodeCoverage::stop |
87
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
88
|
|
|
*/ |
89
|
|
|
public function testStopThrowsExceptionForInvalidArgument2() |
90
|
|
|
{ |
91
|
|
|
$this->coverage->stop(true, null); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @covers PHP_CodeCoverage::append |
96
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
97
|
|
|
*/ |
98
|
|
|
public function testAppendThrowsExceptionForInvalidArgument() |
99
|
|
|
{ |
100
|
|
|
$this->coverage->append([], null); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @covers PHP_CodeCoverage::setCacheTokens |
105
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
106
|
|
|
*/ |
107
|
|
|
public function testSetCacheTokensThrowsExceptionForInvalidArgument() |
108
|
|
|
{ |
109
|
|
|
$this->coverage->setCacheTokens(null); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @covers PHP_CodeCoverage::setCacheTokens |
114
|
|
|
*/ |
115
|
|
|
public function testSetCacheTokens() |
116
|
|
|
{ |
117
|
|
|
$this->coverage->setCacheTokens(true); |
118
|
|
|
$this->assertAttributeEquals(true, 'cacheTokens', $this->coverage); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @covers PHP_CodeCoverage::setCheckForUnintentionallyCoveredCode |
123
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
124
|
|
|
*/ |
125
|
|
|
public function testSetCheckForUnintentionallyCoveredCodeThrowsExceptionForInvalidArgument() |
126
|
|
|
{ |
127
|
|
|
$this->coverage->setCheckForUnintentionallyCoveredCode(null); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @covers PHP_CodeCoverage::setCheckForUnintentionallyCoveredCode |
132
|
|
|
*/ |
133
|
|
|
public function testSetCheckForUnintentionallyCoveredCode() |
134
|
|
|
{ |
135
|
|
|
$this->coverage->setCheckForUnintentionallyCoveredCode(true); |
136
|
|
|
$this->assertAttributeEquals( |
137
|
|
|
true, |
138
|
|
|
'checkForUnintentionallyCoveredCode', |
139
|
|
|
$this->coverage |
140
|
|
|
); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @covers PHP_CodeCoverage::setForceCoversAnnotation |
145
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
146
|
|
|
*/ |
147
|
|
|
public function testSetForceCoversAnnotationThrowsExceptionForInvalidArgument() |
148
|
|
|
{ |
149
|
|
|
$this->coverage->setForceCoversAnnotation(null); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @covers PHP_CodeCoverage::setForceCoversAnnotation |
154
|
|
|
*/ |
155
|
|
|
public function testSetForceCoversAnnotation() |
156
|
|
|
{ |
157
|
|
|
$this->coverage->setForceCoversAnnotation(true); |
158
|
|
|
$this->assertAttributeEquals( |
159
|
|
|
true, |
160
|
|
|
'forceCoversAnnotation', |
161
|
|
|
$this->coverage |
162
|
|
|
); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @covers PHP_CodeCoverage::setCheckForUnexecutedCoveredCode |
167
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
168
|
|
|
*/ |
169
|
|
|
public function testSetCheckForUnexecutedCoveredCodeThrowsExceptionForInvalidArgument() |
170
|
|
|
{ |
171
|
|
|
$this->coverage->setCheckForUnexecutedCoveredCode(null); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @covers PHP_CodeCoverage::setCheckForUnexecutedCoveredCode |
176
|
|
|
*/ |
177
|
|
|
public function testSetCheckForUnexecutedCoveredCode() |
178
|
|
|
{ |
179
|
|
|
$this->coverage->setCheckForUnexecutedCoveredCode(true); |
180
|
|
|
$this->assertAttributeEquals( |
181
|
|
|
true, |
182
|
|
|
'checkForUnexecutedCoveredCode', |
183
|
|
|
$this->coverage |
184
|
|
|
); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @covers PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist |
189
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
190
|
|
|
*/ |
191
|
|
|
public function testSetAddUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument() |
192
|
|
|
{ |
193
|
|
|
$this->coverage->setAddUncoveredFilesFromWhitelist(null); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @covers PHP_CodeCoverage::setAddUncoveredFilesFromWhitelist |
198
|
|
|
*/ |
199
|
|
|
public function testSetAddUncoveredFilesFromWhitelist() |
200
|
|
|
{ |
201
|
|
|
$this->coverage->setAddUncoveredFilesFromWhitelist(true); |
202
|
|
|
$this->assertAttributeEquals( |
203
|
|
|
true, |
204
|
|
|
'addUncoveredFilesFromWhitelist', |
205
|
|
|
$this->coverage |
206
|
|
|
); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @covers PHP_CodeCoverage::setProcessUncoveredFilesFromWhitelist |
211
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
212
|
|
|
*/ |
213
|
|
|
public function testSetProcessUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument() |
214
|
|
|
{ |
215
|
|
|
$this->coverage->setProcessUncoveredFilesFromWhitelist(null); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @covers PHP_CodeCoverage::setProcessUncoveredFilesFromWhitelist |
220
|
|
|
*/ |
221
|
|
|
public function testSetProcessUncoveredFilesFromWhitelist() |
222
|
|
|
{ |
223
|
|
|
$this->coverage->setProcessUncoveredFilesFromWhitelist(true); |
224
|
|
|
$this->assertAttributeEquals( |
225
|
|
|
true, |
226
|
|
|
'processUncoveredFilesFromWhitelist', |
227
|
|
|
$this->coverage |
228
|
|
|
); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @covers PHP_CodeCoverage::setIgnoreDeprecatedCode |
233
|
|
|
*/ |
234
|
|
|
public function testSetIgnoreDeprecatedCode() |
235
|
|
|
{ |
236
|
|
|
$this->coverage->setIgnoreDeprecatedCode(true); |
237
|
|
|
$this->assertAttributeEquals( |
238
|
|
|
true, |
239
|
|
|
'ignoreDeprecatedCode', |
240
|
|
|
$this->coverage |
241
|
|
|
); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @covers PHP_CodeCoverage::setIgnoreDeprecatedCode |
246
|
|
|
* @expectedException PHP_CodeCoverage_Exception |
247
|
|
|
*/ |
248
|
|
|
public function testSetIgnoreDeprecatedCodeThrowsExceptionForInvalidArgument() |
249
|
|
|
{ |
250
|
|
|
$this->coverage->setIgnoreDeprecatedCode(null); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @covers PHP_CodeCoverage::clear |
255
|
|
|
*/ |
256
|
|
|
public function testClear() |
257
|
|
|
{ |
258
|
|
|
$this->coverage->clear(); |
259
|
|
|
|
260
|
|
|
$this->assertAttributeEquals(null, 'currentId', $this->coverage); |
261
|
|
|
$this->assertAttributeEquals([], 'data', $this->coverage); |
262
|
|
|
$this->assertAttributeEquals([], 'tests', $this->coverage); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* @covers PHP_CodeCoverage::start |
267
|
|
|
* @covers PHP_CodeCoverage::stop |
268
|
|
|
* @covers PHP_CodeCoverage::append |
269
|
|
|
* @covers PHP_CodeCoverage::applyListsFilter |
270
|
|
|
* @covers PHP_CodeCoverage::initializeFilesThatAreSeenTheFirstTime |
271
|
|
|
* @covers PHP_CodeCoverage::applyCoversAnnotationFilter |
272
|
|
|
* @covers PHP_CodeCoverage::getTests |
273
|
|
|
*/ |
274
|
|
|
public function testCollect() |
275
|
|
|
{ |
276
|
|
|
$coverage = $this->getCoverageForBankAccount(); |
277
|
|
|
|
278
|
|
|
$this->assertEquals( |
279
|
|
|
$this->getExpectedDataArrayForBankAccount(), |
280
|
|
|
$coverage->getData() |
281
|
|
|
); |
282
|
|
|
|
283
|
|
|
if (version_compare(PHPUnit_Runner_Version::id(), '4.7', '>=')) { |
284
|
|
|
$size = 'unknown'; |
285
|
|
|
} else { |
286
|
|
|
$size = 'small'; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
$this->assertEquals( |
290
|
|
|
[ |
291
|
|
|
'BankAccountTest::testBalanceIsInitiallyZero' => ['size' => $size, 'status' => null], |
292
|
|
|
'BankAccountTest::testBalanceCannotBecomeNegative' => ['size' => $size, 'status' => null], |
293
|
|
|
'BankAccountTest::testBalanceCannotBecomeNegative2' => ['size' => $size, 'status' => null], |
294
|
|
|
'BankAccountTest::testDepositWithdrawMoney' => ['size' => $size, 'status' => null] |
295
|
|
|
], |
296
|
|
|
$coverage->getTests() |
297
|
|
|
); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @covers PHP_CodeCoverage::getData |
302
|
|
|
* @covers PHP_CodeCoverage::merge |
303
|
|
|
*/ |
304
|
|
|
public function testMerge() |
305
|
|
|
{ |
306
|
|
|
$coverage = $this->getCoverageForBankAccountForFirstTwoTests(); |
307
|
|
|
$coverage->merge($this->getCoverageForBankAccountForLastTwoTests()); |
308
|
|
|
|
309
|
|
|
$this->assertEquals( |
310
|
|
|
$this->getExpectedDataArrayForBankAccount(), |
311
|
|
|
$coverage->getData() |
312
|
|
|
); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @covers PHP_CodeCoverage::getData |
317
|
|
|
* @covers PHP_CodeCoverage::merge |
318
|
|
|
*/ |
319
|
|
|
public function testMerge2() |
320
|
|
|
{ |
321
|
|
|
$coverage = new PHP_CodeCoverage( |
322
|
|
|
$this->getMock('PHP_CodeCoverage_Driver_Xdebug'), |
323
|
|
|
new PHP_CodeCoverage_Filter |
324
|
|
|
); |
325
|
|
|
|
326
|
|
|
$coverage->merge($this->getCoverageForBankAccount()); |
327
|
|
|
|
328
|
|
|
$this->assertEquals( |
329
|
|
|
$this->getExpectedDataArrayForBankAccount(), |
330
|
|
|
$coverage->getData() |
331
|
|
|
); |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @covers PHP_CodeCoverage::getLinesToBeIgnored |
336
|
|
|
*/ |
337
|
|
|
public function testGetLinesToBeIgnored() |
338
|
|
|
{ |
339
|
|
|
$this->assertEquals( |
340
|
|
|
[ |
341
|
|
|
1, |
342
|
|
|
3, |
343
|
|
|
4, |
344
|
|
|
5, |
345
|
|
|
7, |
346
|
|
|
8, |
347
|
|
|
9, |
348
|
|
|
10, |
349
|
|
|
11, |
350
|
|
|
12, |
351
|
|
|
13, |
352
|
|
|
14, |
353
|
|
|
15, |
354
|
|
|
16, |
355
|
|
|
17, |
356
|
|
|
18, |
357
|
|
|
19, |
358
|
|
|
20, |
359
|
|
|
21, |
360
|
|
|
22, |
361
|
|
|
23, |
362
|
|
|
24, |
363
|
|
|
25, |
364
|
|
|
26, |
365
|
|
|
27, |
366
|
|
|
28, |
367
|
|
|
30, |
368
|
|
|
32, |
369
|
|
|
33, |
370
|
|
|
34, |
371
|
|
|
35, |
372
|
|
|
36, |
373
|
|
|
37, |
374
|
|
|
38 |
375
|
|
|
], |
376
|
|
|
$this->getLinesToBeIgnored()->invoke( |
377
|
|
|
$this->coverage, |
378
|
|
|
TEST_FILES_PATH . 'source_with_ignore.php' |
379
|
|
|
) |
380
|
|
|
); |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* @covers PHP_CodeCoverage::getLinesToBeIgnored |
385
|
|
|
*/ |
386
|
|
|
public function testGetLinesToBeIgnored2() |
387
|
|
|
{ |
388
|
|
|
$this->assertEquals( |
389
|
|
|
[1, 5], |
390
|
|
|
$this->getLinesToBeIgnored()->invoke( |
391
|
|
|
$this->coverage, |
392
|
|
|
TEST_FILES_PATH . 'source_without_ignore.php' |
393
|
|
|
) |
394
|
|
|
); |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* @covers PHP_CodeCoverage::getLinesToBeIgnored |
399
|
|
|
*/ |
400
|
|
|
public function testGetLinesToBeIgnored3() |
401
|
|
|
{ |
402
|
|
|
$this->assertEquals( |
403
|
|
|
[ |
404
|
|
|
1, |
405
|
|
|
2, |
406
|
|
|
3, |
407
|
|
|
4, |
408
|
|
|
5, |
409
|
|
|
8, |
410
|
|
|
11, |
411
|
|
|
15, |
412
|
|
|
16, |
413
|
|
|
19, |
414
|
|
|
20 |
415
|
|
|
], |
416
|
|
|
$this->getLinesToBeIgnored()->invoke( |
417
|
|
|
$this->coverage, |
418
|
|
|
TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php' |
419
|
|
|
) |
420
|
|
|
); |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
/** |
424
|
|
|
* @covers PHP_CodeCoverage::getLinesToBeIgnored |
425
|
|
|
*/ |
426
|
|
|
public function testGetLinesToBeIgnoredOneLineAnnotations() |
427
|
|
|
{ |
428
|
|
|
$this->assertEquals( |
429
|
|
|
[ |
430
|
|
|
1, |
431
|
|
|
2, |
432
|
|
|
3, |
433
|
|
|
4, |
434
|
|
|
5, |
435
|
|
|
6, |
436
|
|
|
7, |
437
|
|
|
8, |
438
|
|
|
9, |
439
|
|
|
10, |
440
|
|
|
11, |
441
|
|
|
12, |
442
|
|
|
13, |
443
|
|
|
14, |
444
|
|
|
15, |
445
|
|
|
16, |
446
|
|
|
18, |
447
|
|
|
20, |
448
|
|
|
21, |
449
|
|
|
23, |
450
|
|
|
24, |
451
|
|
|
25, |
452
|
|
|
27, |
453
|
|
|
28, |
454
|
|
|
29, |
455
|
|
|
30, |
456
|
|
|
31, |
457
|
|
|
32, |
458
|
|
|
33, |
459
|
|
|
34, |
460
|
|
|
37 |
461
|
|
|
], |
462
|
|
|
$this->getLinesToBeIgnored()->invoke( |
463
|
|
|
$this->coverage, |
464
|
|
|
TEST_FILES_PATH . 'source_with_oneline_annotations.php' |
465
|
|
|
) |
466
|
|
|
); |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* @return ReflectionMethod |
471
|
|
|
*/ |
472
|
|
|
private function getLinesToBeIgnored() |
473
|
|
|
{ |
474
|
|
|
$getLinesToBeIgnored = new ReflectionMethod( |
475
|
|
|
'PHP_CodeCoverage', |
476
|
|
|
'getLinesToBeIgnored' |
477
|
|
|
); |
478
|
|
|
|
479
|
|
|
$getLinesToBeIgnored->setAccessible(true); |
480
|
|
|
|
481
|
|
|
return $getLinesToBeIgnored; |
482
|
|
|
} |
483
|
|
|
|
484
|
|
|
/** |
485
|
|
|
* @covers PHP_CodeCoverage::getLinesToBeIgnored |
486
|
|
|
*/ |
487
|
|
|
public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled() |
488
|
|
|
{ |
489
|
|
|
$this->coverage->setDisableIgnoredLines(true); |
490
|
|
|
|
491
|
|
|
$this->assertEquals( |
492
|
|
|
[], |
493
|
|
|
$this->getLinesToBeIgnored()->invoke( |
494
|
|
|
$this->coverage, |
495
|
|
|
TEST_FILES_PATH . 'source_with_ignore.php' |
496
|
|
|
) |
497
|
|
|
); |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
/** |
501
|
|
|
* @covers PHP_CodeCoverage::performUnexecutedCoveredCodeCheck |
502
|
|
|
* @expectedException PHP_CodeCoverage_CoveredCodeNotExecutedException |
503
|
|
|
*/ |
504
|
|
|
public function testAppendThrowsExceptionIfCoveredCodeWasNotExecuted() |
505
|
|
|
{ |
506
|
|
|
$this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH); |
507
|
|
|
$this->coverage->setCheckForUnexecutedCoveredCode(true); |
508
|
|
|
$data = [ |
509
|
|
|
TEST_FILES_PATH . 'BankAccount.php' => [ |
510
|
|
|
29 => -1, |
511
|
|
|
31 => -1 |
512
|
|
|
] |
513
|
|
|
]; |
514
|
|
|
$linesToBeCovered = [ |
515
|
|
|
TEST_FILES_PATH . 'BankAccount.php' => [ |
516
|
|
|
22, |
517
|
|
|
24 |
518
|
|
|
] |
519
|
|
|
]; |
520
|
|
|
$linesToBeUsed = []; |
521
|
|
|
|
522
|
|
|
$this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed); |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
/** |
526
|
|
|
* @covers PHP_CodeCoverage::performUnexecutedCoveredCodeCheck |
527
|
|
|
* @expectedException PHP_CodeCoverage_CoveredCodeNotExecutedException |
528
|
|
|
*/ |
529
|
|
|
public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted() |
530
|
|
|
{ |
531
|
|
|
$this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH); |
532
|
|
|
$this->coverage->setCheckForUnexecutedCoveredCode(true); |
533
|
|
|
$data = [ |
534
|
|
|
TEST_FILES_PATH . 'BankAccount.php' => [ |
535
|
|
|
29 => -1, |
536
|
|
|
31 => -1 |
537
|
|
|
] |
538
|
|
|
]; |
539
|
|
|
$linesToBeCovered = [ |
540
|
|
|
TEST_FILES_PATH . 'BankAccount.php' => [ |
541
|
|
|
29, |
542
|
|
|
31 |
543
|
|
|
] |
544
|
|
|
]; |
545
|
|
|
$linesToBeUsed = [ |
546
|
|
|
TEST_FILES_PATH . 'BankAccount.php' => [ |
547
|
|
|
22, |
548
|
|
|
24 |
549
|
|
|
] |
550
|
|
|
]; |
551
|
|
|
|
552
|
|
|
$this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed); |
553
|
|
|
} |
554
|
|
|
} |
555
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.