This is my store method
DB::transaction(function () use ($request) {
$imageName = LocalHubHelper::renameImageFileUpload($request->file('image'));
$request->file('image')->move(public_path('storage/uploads/flyers'), $imageName);
Flyer::create([
'title' => $request->input('title'),
'description' => $request->input('description'),
'image' => $imageName,
'order' => $request->input('order'),
'button_text' => $request->input('button_text'),
'button_link' => $request->input('button_link'),
'post_id' => $request->input('post_id'),
]);
});
and this is my factory
public function definition()
{
return [
'title' => $this->faker->words(5,true),
'description' => $this->faker->realText(50),
'order' => 1,
'post_id' => Post::factory()->create()->id,
'button_text' => null,
'button_link' => '#',
'image' => UploadedFile::fake()->image('file.png', 250, 150),
'created_at' => now(),
'updated_at' => now(),
];
}
and this is my test
public function test_flyer_image_uploaded_successfully()
{
$this->signIn();
$this->withoutExceptionHandling();
Storage::fake('local');
$file = UploadedFile::fake()->image('file.png', 250, 150);
$attributes = Flyer::factory()->raw(['image' => $file]);
$response = $this->post($this->endPoint,$attributes)
->assertStatus(302);
$imageName = Flyer::latest()->first()->image;
Storage::disk('local')->assertExists("public/uploads/flyers/".$imageName);
}
and this is the failed message
1) Tests\Feature\FlyerTest::test_flyer_image_uploaded_successfully
Unable to find a file at path [public/uploads/flyers/file_20210910.png].
Failed asserting that false is true.
but if I check storage/app/public/uploads/flyers then there is a file with this name. Am I asserting in different path?