Skip to content

Commit

Permalink
Avoid double evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
Naktibalda committed Mar 14, 2022
1 parent 486663a commit 214fe0c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Codeception/Module/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ protected function absolutizePath(string $path): string
*/
public function openFile(string $filename): void
{
if (!file_exists($this->absolutizePath($filename))) {
$absolutePath = $this->absolutizePath($filename);
if (!file_exists($absolutePath)) {
TestCase::fail('file not found');
}
$this->file = file_get_contents($this->absolutizePath($filename));
$this->file = file_get_contents($absolutePath);
$this->filePath = $filename;
}

Expand All @@ -96,11 +97,12 @@ public function openFile(string $filename): void
*/
public function deleteFile(string $filename): void
{
if (!file_exists($this->absolutizePath($filename))) {
$absolutePath = $this->absolutizePath($filename);
if (!file_exists($absolutePath)) {
TestCase::fail('file not found');
}

unlink($this->absolutizePath($filename));
unlink($absolutePath);
}

/**
Expand Down

0 comments on commit 214fe0c

Please sign in to comment.