Skip to content

Commit fb165ba

Browse files
committed
Test that it cannot read constants from the analyzing file
1 parent c1f3c6f commit fb165ba

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace PHPStan\Rules\Keywords;
4+
5+
use PHPStan\Testing\RuleTestCase;
6+
use PHPStan\Rules\Keywords\RequireFileExistsRule;
7+
use PHPStan\Rules\Rule;
8+
9+
10+
/**
11+
* @extends RuleTestCase<RequireFileExistsRule>
12+
*/
13+
class RequireFileExistsRuleTest extends RuleTestCase
14+
{
15+
protected function getRule(): Rule
16+
{
17+
return new RequireFileExistsRule($this->createReflectionProvider());
18+
}
19+
20+
public function testItCannotReadConstantsDefinedInTheAnalysedFile(): void
21+
{
22+
$this->analyse([__DIR__ . '/data/file-does-not-exist-but-const-is-defined-in-the-same-file.php'], []);
23+
}
24+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php declare(strict_types=1);
2+
3+
define('FILE_DOES_NOT_EXIST_INLINE', 'a_file_that_does_not_exist.txt');
4+
5+
include __DIR__ . '/' . FILE_DOES_NOT_EXIST_INLINE;
6+
include_once __DIR__ . '/' . FILE_DOES_NOT_EXIST_INLINE;
7+
require __DIR__ . '/' . FILE_DOES_NOT_EXIST_INLINE;
8+
require_once __DIR__ . '/' . FILE_DOES_NOT_EXIST_INLINE;

0 commit comments

Comments
 (0)