I am trying to create a test in laravel 5.7 that involves creating a fake image object which is further consumed by a service that moves it to a desired directory in public folder. My service works fine if I upload file through browser but if I run through tests , it creates a folder in root and uploads image there.
Service code:
$data['icon'] = time().'.'.$file->getClientOriginalExtension();
$file->move('uploads/avatar/icon', $data['icon']);
Test file code:
$file = UploadedFile::fake()->image('random.jpg');
Now if I specify path in service code , it gives desired result
$data['icon'] = time().'.'.$file->getClientOriginalExtension();
$file->move(public_path('uploads/avatar/icon'), $data['icon']);
Is there any way without hard-coding the public_path dependency?