create(['published_at' => null]); $published = Service::factory()->published()->create(); $this->assertCount(1, Service::query()->published()->get()); $this->assertTrue(Service::query()->published()->first()?->is($published)); } public function test_slug_uniqueness_is_enforced(): void { Service::factory()->create(['slug' => 'casamentos']); $this->expectException(QueryException::class); Service::factory()->create(['slug' => 'casamentos']); } public function test_assistant_cannot_access_services_resource(): void { $assistant = User::factory()->assistant()->create(); $this->actingAs($assistant); Livewire::test(ListServices::class) ->assertForbidden(); } public function test_admin_can_access_services_resource(): void { $admin = User::factory()->admin()->create(); $this->actingAs($admin); Livewire::test(ListServices::class) ->assertSuccessful(); } public function test_publication_uses_published_at_timestamp(): void { $publishedAt = Carbon::parse('2026-02-01 12:00:00'); $service = Service::factory()->create([ 'published_at' => $publishedAt, ]); $this->assertTrue(Service::query()->published()->whereKey($service->id)->exists()); } }