Level 75
Don't know if this will help, but have a look: https://laravel-news.com/testing-file-uploads-with-laravel
Hi,
I've got an app with a laravel backend where i like to upload some images and video using my Larvel api/backend. I would like to add a test that hits the boundries of my system eka, the ini_get('upload_max_filesize')
To this extend I added a test like:
/**
* @test
*/
public function it_should_throw_an_error_when_uploading_an_image_that_is_too_big()
{
$path = base_path('storage/app/images/test/big_file.jpg');
$image = new UploadedFile($path, '34610974.jpg', filesize($path), 'image/jpg', null, false);
$response = $this->makeAuthCall(
'some_route_name',
[
'intended_upload_id' => 25,
'input' => $image,
]
);
$this->assertEquals('uploaded file is to big' ,$response->decodeResponseJson()['error']);
}
Where makeAuthCall to 'some_route_name is a helper to set the correct credenitals etc.
(PS in real world the request seems empty, during testing the file gets uploaded, Both is not what i want.)
Martin
Please or to participate in this conversation.