Skip to content

Commit 214fe0c

Browse files
committed
Avoid double evaluation
1 parent 486663a commit 214fe0c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Codeception/Module/Filesystem.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ protected function absolutizePath(string $path): string
7979
*/
8080
public function openFile(string $filename): void
8181
{
82-
if (!file_exists($this->absolutizePath($filename))) {
82+
$absolutePath = $this->absolutizePath($filename);
83+
if (!file_exists($absolutePath)) {
8384
TestCase::fail('file not found');
8485
}
85-
$this->file = file_get_contents($this->absolutizePath($filename));
86+
$this->file = file_get_contents($absolutePath);
8687
$this->filePath = $filename;
8788
}
8889

@@ -96,11 +97,12 @@ public function openFile(string $filename): void
9697
*/
9798
public function deleteFile(string $filename): void
9899
{
99-
if (!file_exists($this->absolutizePath($filename))) {
100+
$absolutePath = $this->absolutizePath($filename);
101+
if (!file_exists($absolutePath)) {
100102
TestCase::fail('file not found');
101103
}
102104

103-
unlink($this->absolutizePath($filename));
105+
unlink($absolutePath);
104106
}
105107

106108
/**

0 commit comments

Comments
 (0)