MartinFolkerts's avatar

Testing upload_max_filesize

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

0 likes
2 replies
MartinFolkerts's avatar

No this does not help because it is a fake(), My problem with the uploadedFile class is that it seems to by pass the php.ini settings.

Please or to participate in this conversation.