From 460583333f83cbc675c9b01a54b0eae8ecf9e28c Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Mon, 23 Sep 2024 13:00:30 +0200 Subject: [PATCH] Refactor RequireFileExistsRuleTest to work like all other tests --- .../Keywords/RequireFileExistsRuleTest.php | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php index 287df6863..ee96f4046 100644 --- a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php +++ b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php @@ -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 @@ -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'], [ @@ -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'], []); } }