Skip to content

Commit be18ba6

Browse files
committed
Test that it can read constants
1 parent deefe60 commit be18ba6

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,27 @@ public function testFileDoesNotExistUsingClassConst(): void
5454
],
5555
]);
5656
}
57+
58+
public function testFileExistsUsingConst(): void
59+
{
60+
define('FILE_EXISTS', __DIR__ . '/data/include-me-to-prove-you-work.txt');
61+
62+
$this->analyse([__DIR__ . '/data/file-exists-using-constant.php'], []);
63+
}
64+
65+
public function testFileDoesNotExistUsingConst(): void
66+
{
67+
define('FILE_DOES_NOT_EXIST', 'a-file-that-does-not-exist.txt');
68+
69+
$this->analyse([__DIR__ . '/data/required-file-does-not-exist-using-constant.php'], [
70+
[
71+
'Required file "a-file-that-does-not-exist.txt" does not exist.',
72+
7,
73+
],
74+
[
75+
'Required file "a-file-that-does-not-exist.txt" does not exist.',
76+
8,
77+
],
78+
]);
79+
}
5780
}
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 FILE_EXISTS;
4+
include_once FILE_EXISTS;
5+
require FILE_EXISTS;
6+
require_once FILE_EXISTS;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
include FILE_DOES_NOT_EXIST;
6+
include_once FILE_DOES_NOT_EXIST;
7+
require FILE_DOES_NOT_EXIST;
8+
require_once FILE_DOES_NOT_EXIST;

0 commit comments

Comments
 (0)