jeudi 12 octobre 2017

test upload image with laravel

I am testing a controller that upload and resize an image with Laravel and Intervention plugin.

Here is the controller:

        $file = request()
            ->file('file')
            ->store('images/avatar', 'public');

        Image::make(storage_path('app/public/' . $file))
            ->resize(200, 200, function ($constraint) {
                $constraint->aspectRatio();
                $constraint->upsize();
            })
            ->save();

Upload is working great, but in tests, file is uploaded to storage/framework/testing/disks/public/images/avatar/ while in dev, it is send to storage/app/public/images/avatar/

Result is that tests are failing on Image::make(storage_path('app/public/' . $file)) when running.

Anyone know how could I fix it???

Aucun commentaire:

Enregistrer un commentaire