How does your test submit the $requestData? Please share that code.
Apr 25, 2019
4
Level 15
Faking a File Upload
Hi All,
Im having a few issues with faking an image upload.
In my controller I have the following
if (isset($data['emailCustomisation'])) {
$emailCustomisation = new EmailCustomisation();
$emailCustomisation->logo = $request
->file('emailCustomisation.logo')
->store('logos', config('filesystems.cloud'));
$emailCustomisation->company_id = $company->id;
$emailCustomisation->color = $data['emailCustomisation']['color'];
$emailCustomisation->save();
This is the test that I run on the controller, but it always fails
$requestData = [
'company' => [
'label' => 'foo',
'name' => $company->name,
'home_page' => $company->home_page,
'phone_number' => $company->phone_number,
'timezone' => $company->timezone
],
'emailCustomisation' => [
'logo' => UploadedFile::fake()->image('avatar.jpg'),
'color' => $hexColour
]
];
It is failing with the error:
Error: Call to a member function store() on null
Does anyone know what may be causing this?
Thanks :)
Please or to participate in this conversation.