Skip to content

Commit 7ef1bbd

Browse files
authored
fix: uploaded files should have test flag set to true (#26)
1 parent 9515c17 commit 7ef1bbd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Codeception/Lib/Connector/Laravel.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,32 @@ public function clearApplicationHandlers(): void
463463
{
464464
$this->applicationHandlers = [];
465465
}
466+
467+
/**
468+
* Make sure files are \Illuminate\Http\UploadedFile instances with the private $test property set to true.
469+
* Fixes issue https://github.com/Codeception/Codeception/pull/3417.
470+
*
471+
* @param array $files
472+
* @return array
473+
*/
474+
protected function filterFiles(array $files): array
475+
{
476+
$files = parent::filterFiles($files);
477+
return $this->convertToTestFiles($files);
478+
}
479+
480+
private function convertToTestFiles(array $files): array
481+
{
482+
$filtered = [];
483+
484+
foreach ($files as $key => $value) {
485+
if (is_array($value)) {
486+
$filtered[$key] = $this->convertToTestFiles($value);
487+
} else {
488+
$filtered[$key] = UploadedFile::createFromBase($value, true);
489+
}
490+
}
491+
492+
return $filtered;
493+
}
466494
}

0 commit comments

Comments
 (0)