Show what you have that does not work
Laravel 7x Testing. How to feature test with image posts
I'm quite new to Feature testing and I keep tripping up over some tests. A main part of my application is posting images along with captions, and whatever other text the post requires, this also includes updating that said post or profile.
I've been trying to research how to test whether the post renders along with the caption and post, and the most common approach does not seem to be working for me. I'm not sure what post route to use, or if how I have written it up is correct. However I'll show the areas I beleive to be important below. Please let me know I have left anything out.
I know that the error is falling under the storage::fake and hashname but since i have not used that what would i?
public function store()
{
$data = request()->validate([
'caption' => 'required',
'image' => ['required', 'image|mimes:jpeg,png,jpg,gif,svg,heic|max:2048']
]);
$imagePath = request('image')->store('uploads', 'public');
$image = Image::make
(public_path("storage/{$imagePath}"))
->fit(1200, 1200);
$image->save();
auth()->user()->posts()->create([
'caption' => $data['caption'],
'image' => $imagePath,
]);
return redirect('/profiles/' . auth()->user()->id);
}
Please or to participate in this conversation.