Files
SkinbaseNova/tests/Feature/Web/FeaturedArtworksPageTest.php

69 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\Artwork;
use App\Models\ContentType;
use App\Models\Category;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
uses(RefreshDatabase::class);
it('renders featured artworks without lazy loading category content types', function (): void {
$contentType = ContentType::query()->create([
'name' => 'Digital Art',
'slug' => 'digital-art',
'description' => 'Digital art content type',
'order' => 1,
'hide_from_menu' => false,
]);
$category = Category::query()->create([
'content_type_id' => $contentType->id,
'parent_id' => null,
'name' => 'Featured Category',
'slug' => 'featured-category',
'description' => 'Featured category',
'is_active' => true,
'sort_order' => 1,
]);
$artwork = Artwork::factory()->create([
'title' => 'Featured Route Artwork',
'slug' => 'featured-route-artwork-' . Str::lower((string) Str::uuid()),
'is_public' => true,
'is_approved' => true,
'published_at' => now()->subHour(),
'has_missing_thumbnails' => false,
]);
$artwork->categories()->attach($category->id);
DB::table('artwork_features')->insert([
'artwork_id' => $artwork->id,
'priority' => 100,
'featured_at' => now()->subHour(),
'expires_at' => null,
'label' => null,
'note' => null,
'is_active' => true,
'created_by' => null,
'created_at' => now(),
'updated_at' => now(),
'deleted_at' => null,
]);
Model::preventLazyLoading();
try {
$this->withoutExceptionHandling()
->get(route('featured'))
->assertOk()
->assertSee('Featured Route Artwork');
} finally {
Model::preventLazyLoading(false);
}
});