3

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?

Bogdan Koliesnik
  • 780
  • 6
  • 14
  • This seems a bug in Symphony. The last parameter is indeed for setting 'test' to true, but the object sees it as false. I've the same problem now with my uploaded test in Laravel – schellingerht Apr 25 '16 at 17:06

1 Answers1

2

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.

Community
  • 1
  • 1
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291