Skip to content

Commit 749414a

Browse files
committed
Test that relative paths can produce problems
1 parent fb165ba commit 749414a

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,18 @@ public function testItCannotReadConstantsDefinedInTheAnalysedFile(): void
2121
{
2222
$this->analyse([__DIR__ . '/data/file-does-not-exist-but-const-is-defined-in-the-same-file.php'], []);
2323
}
24+
25+
public function testFileExistsButPathIsRelative(): void
26+
{
27+
$this->analyse([__DIR__ . '/data/file-exists-but-path-is-relative.php'], [
28+
[
29+
'Required file "include-me-to-prove-you-work.txt" does not exist.',
30+
5,
31+
],
32+
[
33+
'Required file "include-me-to-prove-you-work.txt" does not exist.',
34+
6,
35+
],
36+
]);
37+
}
2438
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php declare(strict_types=1);
2+
3+
include 'include-me-to-prove-you-work.txt';
4+
include_once 'include-me-to-prove-you-work.txt';
5+
require 'include-me-to-prove-you-work.txt';
6+
require_once 'include-me-to-prove-you-work.txt';

tests/PHPStan/Rules/Keywords/data/include-me-to-prove-you-work.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)