Skip to content

Commit

Permalink
Refactor RequireFileExistsRuleTest to work like all other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 23, 2024
1 parent a72f752 commit 4605833
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@
class RequireFileExistsRuleTest extends RuleTestCase
{

private RequireFileExistsRule $rule;

public function setUp(): void
{
parent::setUp();

$this->rule = $this->getDefaultRule();
}
private string $currentWorkingDirectory = __DIR__ . '/../';

protected function getRule(): Rule
{
return $this->rule;
return new RequireFileExistsRule($this->currentWorkingDirectory);
}

public static function getAdditionalConfigFiles(): array
Expand All @@ -37,11 +30,6 @@ public static function getAdditionalConfigFiles(): array
];
}

private function getDefaultRule(): RequireFileExistsRule
{
return new RequireFileExistsRule(__DIR__ . '/../');
}

public function testBasicCase(): void
{
$this->analyse([__DIR__ . '/data/require-file-simple-case.php'], [
Expand Down Expand Up @@ -124,13 +112,8 @@ public function testRelativePathWithIncludePath(): void

public function testRelativePathWithSameWorkingDirectory(): void
{
$this->rule = new RequireFileExistsRule(__DIR__);

try {
$this->analyse([__DIR__ . '/data/require-file-relative-path.php'], []);
} finally {
$this->rule = $this->getDefaultRule();
}
$this->currentWorkingDirectory = __DIR__;
$this->analyse([__DIR__ . '/data/require-file-relative-path.php'], []);
}

}

0 comments on commit 4605833

Please sign in to comment.