Level 50
Jun 20, 2018
2
Level 1
phpunit file upload: size 0 (zero)
My test makes a post request:
// FileUploadTest.php
$this->post(
'uri',
['file' => \Illuminate\Http\UploadedFile::fake()->image('file.jpg')->size(200)]
);
The controller detects the filesize:
// FileUploadController.php
if ($request->hasFile('file')) {
\Log::debug('bytes: ' . \File::size($request->file));
}
When I upload a file manually, the correct size of the file would be logged. When I run a phpunit test, the size is always 0.
Any idea what is going on?
Please or to participate in this conversation.