Bogdan Koliesnik
Bogdan Koliesnik

Reputation: 900

Lumen testing. UploadedFile validation failed

In my controller's action to upload file I have a validation rule['file' => 'image']; I create a test UploadedFile instace like this: $uploadedFile = new UploadedFile(base_path(self::UPLOAD_PATH), $name, $mimeType, null, null, true); As you can see, the 6th parameter ($test) is true, it's required for testing. But, during tests, when the $uploadedFile come to Validator, parameter $test is false and the rest of the instance is the same as was created. Is there's another way to test file uploading? Or how can I fix this?

Upvotes: 3

Views: 1194

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111839

You should now use:

\Illuminate\Http\UploadedFile

instead of

\Symfony\Component\HttpFoundation\File\UploadedFile

to create UploadedFile object. If you want take a look at detailed explanation for this.

Upvotes: 2

Related Questions