Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/Codeception/Module/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public function _before(TestInterface $test): void
*/
public function amInPath(string $path): void
{
chdir($this->path = $this->absolutizePath($path) . DIRECTORY_SEPARATOR);
$this->path = $this->absolutizePath($path) . DIRECTORY_SEPARATOR;
if (!file_exists($this->path)) {
TestCase::fail('directory not found');
}
chdir($this->path);
$this->debug('Moved to ' . getcwd());
}

Expand Down Expand Up @@ -75,7 +79,11 @@ protected function absolutizePath(string $path): string
*/
public function openFile(string $filename): void
{
$this->file = file_get_contents($this->absolutizePath($filename));
$absolutePath = $this->absolutizePath($filename);
if (!file_exists($absolutePath)) {
TestCase::fail('file not found');
}
$this->file = file_get_contents($absolutePath);
$this->filePath = $filename;
}

Expand All @@ -89,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