get('/dashboard/favorites')->assertRedirect('/login'); } public function test_authenticated_user_sees_favourites_and_can_remove(): void { $user = User::factory()->create(); $art = Artwork::factory()->create(['user_id' => $user->id, 'title' => 'Fav Artwork']); DB::table('artwork_favourites')->insert([ 'user_id' => $user->id, 'artwork_id' => $art->id, 'created_at' => now(), 'updated_at' => now(), ]); $response = $this->actingAs($user) ->get(route('dashboard.favorites')) ->assertOk() ->assertSee('Fav Artwork'); $html = $response->getContent(); $this->assertNotFalse($html); $this->assertStringContainsString('data-react-masonry-gallery', $html); $this->assertStringContainsString('data-artworks=', $html); $this->assertStringContainsString('data-gallery-type="dashboard-favorites"', $html); $this->actingAs($user) ->delete(route('dashboard.favorites.destroy', ['artwork' => $art->id])) ->assertRedirect(route('dashboard.favorites')); $this->assertDatabaseMissing('artwork_favourites', ['user_id' => $user->id, 'artwork_id' => $art->id]); } }