Skip to content

Commit 032965a

Browse files
committed
Simplify tests
1 parent f8db0ec commit 032965a

14 files changed

+24
-229
lines changed

tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php

Lines changed: 6 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PHPStan\Rules\Rule;
66
use PHPStan\Testing\RuleTestCase;
7-
use function define;
87

98
/**
109
* @extends RuleTestCase<RequireFileExistsRule>
@@ -24,118 +23,28 @@ public static function getAdditionalConfigFiles(): array
2423
];
2524
}
2625

27-
public function testFileDoesNotExistUsingConstDefinedInTheSameFolder(): void
26+
public function testBasicCase(): void
2827
{
29-
$this->analyse([__DIR__ . '/data/file-does-not-exist-using-const-defined-in-the-same-file.php'], [
28+
$this->analyse([__DIR__ . '/data/require-file-simple-case.php'], [
3029
[
3130
'Path in include() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
32-
5,
33-
],
34-
[
35-
'Path in include_once() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
36-
6,
37-
],
38-
[
39-
'Path in require() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
40-
7,
41-
],
42-
[
43-
'Path in require_once() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
44-
8,
45-
],
46-
]);
47-
}
48-
49-
public function testFileExistsButPathIsRelative(): void
50-
{
51-
$this->analyse([__DIR__ . '/data/file-exists-but-path-is-relative.php'], [
52-
[
53-
'Path in include() "include-me-to-prove-you-work.txt" is not a file or it does not exist.',
54-
3,
55-
],
56-
[
57-
'Path in include_once() "include-me-to-prove-you-work.txt" is not a file or it does not exist.',
58-
4,
59-
],
60-
[
61-
'Path in require() "include-me-to-prove-you-work.txt" is not a file or it does not exist.',
62-
5,
63-
],
64-
[
65-
'Path in require_once() "include-me-to-prove-you-work.txt" is not a file or it does not exist.',
66-
6,
67-
],
68-
]);
69-
}
70-
71-
public function testFileExistsUsingClassConst(): void
72-
{
73-
$this->analyse([__DIR__ . '/data/file-exists-using-class-const.php'], []);
74-
}
75-
76-
public function testFileDoesNotExistUsingClassConst(): void
77-
{
78-
$this->analyse([__DIR__ . '/data/file-does-not-exist-using-class-const.php'], [
79-
[
80-
'Path in include() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
81-
5,
82-
],
83-
[
84-
'Path in include_once() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
85-
6,
86-
],
87-
[
88-
'Path in require() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
89-
7,
90-
],
91-
[
92-
'Path in require_once() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
93-
8,
94-
],
95-
]);
96-
}
97-
98-
public function testFileExistsUsingConst(): void
99-
{
100-
define('FILE_EXISTS', __DIR__ . '/data/include-me-to-prove-you-work.txt');
101-
102-
$this->analyse([__DIR__ . '/data/file-exists-using-constant.php'], []);
103-
}
104-
105-
public function testFileDoesNotExistUsingConst(): void
106-
{
107-
define('FILE_DOES_NOT_EXIST', 'a-file-that-does-not-exist.php');
108-
109-
$this->analyse([__DIR__ . '/data/file-does-not-exist-using-constant.php'], [
110-
[
111-
'Path in include() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
112-
5,
31+
11,
11332
],
11433
[
11534
'Path in include_once() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
116-
6,
35+
12,
11736
],
11837
[
11938
'Path in require() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
120-
7,
39+
13,
12140
],
12241
[
12342
'Path in require_once() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
124-
8,
43+
14,
12544
],
12645
]);
12746
}
12847

129-
public function testFileExistsUsingDIR(): void
130-
{
131-
$this->analyse([__DIR__ . '/data/file-exists-using-DIR.php'], []);
132-
}
133-
134-
public function testFileExistsUsingVariables(): void
135-
{
136-
$this->analyse([__DIR__ . '/data/file-exists-using-a-variable.php'], []);
137-
}
138-
13948
public function testFileDoesNotExistConditionally(): void
14049
{
14150
$this->analyse([__DIR__ . '/data/file-does-not-exist-conditionally.php'], [
@@ -158,41 +67,4 @@ public function testFileDoesNotExistConditionally(): void
15867
]);
15968
}
16069

161-
public function testFileDoesNotExistButUsesVariables(): void
162-
{
163-
$this->analyse([__DIR__ . '/data/file-does-not-exist-but-uses-a-variable.php'], [
164-
[
165-
'Path in include() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
166-
5,
167-
],
168-
[
169-
'Path in include_once() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
170-
6,
171-
],
172-
[
173-
'Path in require() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
174-
7,
175-
],
176-
[
177-
'Path in require_once() "a-file-that-does-not-exist.php" is not a file or it does not exist.',
178-
8,
179-
],
180-
]);
181-
}
182-
183-
public function testFileDoesNotExistButUsesClassProperties(): void
184-
{
185-
$this->analyse([__DIR__ . '/data/file-does-not-exist-but-uses-a-class-property.php'], []);
186-
}
187-
188-
public function testFileDoesNotExistButUsesClassMethods(): void
189-
{
190-
$this->analyse([__DIR__ . '/data/file-does-not-exist-but-uses-a-class-method.php'], []);
191-
}
192-
193-
public function testFileDoesNotExistButUsesAFunction(): void
194-
{
195-
$this->analyse([__DIR__ . '/data/file-does-not-exist-but-uses-a-function.php'], []);
196-
}
197-
19870
}

tests/PHPStan/Rules/Keywords/data/file-does-not-exist-but-uses-a-class-method.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/PHPStan/Rules/Keywords/data/file-does-not-exist-but-uses-a-class-property.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/PHPStan/Rules/Keywords/data/file-does-not-exist-but-uses-a-function.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/PHPStan/Rules/Keywords/data/file-does-not-exist-but-uses-a-variable.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/PHPStan/Rules/Keywords/data/file-does-not-exist-using-class-const.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/PHPStan/Rules/Keywords/data/file-does-not-exist-using-const-defined-in-the-same-file.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/PHPStan/Rules/Keywords/data/file-does-not-exist-using-constant.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/PHPStan/Rules/Keywords/data/file-exists-but-path-is-relative.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/PHPStan/Rules/Keywords/data/file-exists-using-DIR.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)