Skip to content

Commit 4605833

Browse files
committed
Refactor RequireFileExistsRuleTest to work like all other tests
1 parent a72f752 commit 4605833

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php

+4-21
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,11 @@
1616
class RequireFileExistsRuleTest extends RuleTestCase
1717
{
1818

19-
private RequireFileExistsRule $rule;
20-
21-
public function setUp(): void
22-
{
23-
parent::setUp();
24-
25-
$this->rule = $this->getDefaultRule();
26-
}
19+
private string $currentWorkingDirectory = __DIR__ . '/../';
2720

2821
protected function getRule(): Rule
2922
{
30-
return $this->rule;
23+
return new RequireFileExistsRule($this->currentWorkingDirectory);
3124
}
3225

3326
public static function getAdditionalConfigFiles(): array
@@ -37,11 +30,6 @@ public static function getAdditionalConfigFiles(): array
3730
];
3831
}
3932

40-
private function getDefaultRule(): RequireFileExistsRule
41-
{
42-
return new RequireFileExistsRule(__DIR__ . '/../');
43-
}
44-
4533
public function testBasicCase(): void
4634
{
4735
$this->analyse([__DIR__ . '/data/require-file-simple-case.php'], [
@@ -124,13 +112,8 @@ public function testRelativePathWithIncludePath(): void
124112

125113
public function testRelativePathWithSameWorkingDirectory(): void
126114
{
127-
$this->rule = new RequireFileExistsRule(__DIR__);
128-
129-
try {
130-
$this->analyse([__DIR__ . '/data/require-file-relative-path.php'], []);
131-
} finally {
132-
$this->rule = $this->getDefaultRule();
133-
}
115+
$this->currentWorkingDirectory = __DIR__;
116+
$this->analyse([__DIR__ . '/data/require-file-relative-path.php'], []);
134117
}
135118

136119
}

0 commit comments

Comments
 (0)