Level 47
Why not use an acceptance test?
I want to test the store method with a call, because I can't use attach method becouse I use javascript to submit the form and I don't have any button. My problem is that the controller doesn't recognizes the files that I have passed.
Test
$img = Image::make('public/img/test.jpg')->save('/tmp/test.jpg');
$file = new \Symfony\Component\HttpFoundation\File\UploadedFile('/tmp/test.jpg', 'test.jpg', 'image/jpeg', $img->filesize());
$response = $this->actingAs(App\Models\User::where('profile_type', 'Admin')->first())
->call(
'POST',
'myurl',
[],
[],
['photos' => [$file]]
);
dd($response->content());
Controller
dd($request->files); // It's empty
//dd($request->all()); // I see the files under the parameter value
Please or to participate in this conversation.