Files
SkinbaseNova/tests/Feature/ArtworkFeatureTest.php
2026-02-07 08:23:18 +01:00

44 lines
1.3 KiB
PHP

<?php
use App\Models\Artwork;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('public browsing scopes include only public approved not-deleted artworks', function () {
Artwork::factory()->create(); // public + approved
Artwork::factory()->private()->create();
Artwork::factory()->unapproved()->create();
expect(Artwork::public()->count())->toBe(1);
});
test('slug-based route generation produces SEO friendly url', function () {
$art = Artwork::factory()->create(['slug' => 'my-unique-art']);
$url = route('artworks.show', [
'contentTypeSlug' => 'photography',
'categoryPath' => 'abstract',
'artwork' => $art->slug,
]);
expect($url)->toContain('/photography/abstract/my-unique-art');
});
test('soft delete hides artwork from public scope', function () {
$art = Artwork::factory()->create();
$art->delete();
expect(Artwork::public()->where('id', $art->id)->exists())->toBeFalse();
});
test('approval filtering works via approved scope', function () {
Artwork::factory()->create();
Artwork::factory()->unapproved()->create();
expect(Artwork::approved()->count())->toBe(1);
});
test('admin routes are protected from unauthenticated users', function () {
$this->get('/admin/artworks')->assertRedirect('/login');
});