Skip to content

Commit 0002a10

Browse files
committed
Add test cases for all forms of require/include
1 parent d8135e3 commit 0002a10

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Tests/VariableAnalysisSniff/UnusedFollowedByRequireTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ public function testUnusedFollowedByRequireDefault() {
1313
2,
1414
3,
1515
4,
16+
8,
17+
9,
18+
10,
19+
14,
20+
15,
21+
16,
22+
20,
23+
21,
24+
22,
1625
];
1726
$this->assertEquals($expectedWarnings, $lines);
1827
}
@@ -29,6 +38,9 @@ public function testUnusedFollowedByRequireWhenSet() {
2938
$lines = $this->getWarningLineNumbersFromFile($phpcsFile);
3039
$expectedWarnings = [
3140
4,
41+
10,
42+
16,
43+
22,
3244
];
3345
$this->assertEquals($expectedWarnings, $lines);
3446
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
<?php
22
function require_file_function($param) { // unused variable $param
3+
$var = 'something'; // unused variable $var
4+
activate_code($data); // undefined variable $data
5+
require __DIR__ . '/views/my-view.php';
6+
}
7+
8+
function require_once_file_function($param) { // unused variable $param
39
$var = 'something'; // unused variable $var
410
activate_code($data); // undefined variable $data
511
require_once __DIR__ . '/views/my-view.php';
612
}
13+
14+
function include_file_function($param) { // unused variable $param
15+
$var = 'something'; // unused variable $var
16+
activate_code($data); // undefined variable $data
17+
include __DIR__ . '/views/my-view.php';
18+
}
19+
20+
function include_once_file_function($param) { // unused variable $param
21+
$var = 'something'; // unused variable $var
22+
activate_code($data); // undefined variable $data
23+
include_once __DIR__ . '/views/my-view.php';
24+
}

0 commit comments

Comments
 (0)