create(['published_at' => null]); $published = PortfolioCase::factory()->published()->create(); $this->assertCount(1, PortfolioCase::query()->published()->get()); $this->assertTrue(PortfolioCase::query()->published()->first()?->is($published)); } public function test_gallery_images_are_ordered_by_sort_order(): void { $case = PortfolioCase::factory()->create(); PortfolioImage::query()->create([ 'portfolio_case_id' => $case->id, 'path' => 'content/b.jpg', 'alt_text' => 'Segunda', 'sort_order' => 2, ]); PortfolioImage::query()->create([ 'portfolio_case_id' => $case->id, 'path' => 'content/a.jpg', 'alt_text' => 'Primeira', 'sort_order' => 1, ]); $ordered = $case->fresh()->images->pluck('alt_text')->all(); $this->assertSame(['Primeira', 'Segunda'], $ordered); } public function test_deleting_case_cascades_gallery_images(): void { $case = PortfolioCase::factory()->create(); PortfolioImage::query()->create([ 'portfolio_case_id' => $case->id, 'path' => 'content/a.jpg', 'alt_text' => 'Imagem', 'sort_order' => 1, ]); $case->delete(); $this->assertDatabaseCount('portfolio_images', 0); } public function test_assistant_cannot_access_portfolio_resource(): void { $assistant = User::factory()->assistant()->create(); $this->actingAs($assistant); Livewire::test(ListPortfolioCases::class) ->assertForbidden(); } }