create(); $other = User::factory()->create(); $notificationId = (string) Str::uuid(); $otherNotificationId = (string) Str::uuid(); foreach ([[$notificationId, $user], [$otherNotificationId, $other]] as [$id, $recipient]) { DB::table('notifications')->insert([ 'id' => $id, 'type' => 'test', 'notifiable_type' => $recipient->getMorphClass(), 'notifiable_id' => $recipient->id, 'data' => json_encode(['message' => 'Atualização de teste.', 'url' => '/requisicoes']), 'created_at' => now(), 'updated_at' => now(), ]); } $this->actingAs($user) ->get('/notificacoes') ->assertOk() ->assertInertia(fn (Assert $page) => $page ->component('notifications/index') ->has('notifications.data', 1) ->where('notifications.data.0.id', $notificationId)); $this->post("/notificacoes/{$notificationId}/ler") ->assertRedirect('/requisicoes'); $this->assertDatabaseMissing('notifications', [ 'id' => $notificationId, 'read_at' => null, ]); $this->post("/notificacoes/{$otherNotificationId}/ler")->assertNotFound(); });