Current state

This commit is contained in:
2026-02-07 08:23:18 +01:00
commit 0a4372c40d
22479 changed files with 1553543 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
<?php
namespace Tests\Feature;
use App\Models\Artwork;
use App\Models\Category;
use App\Models\ContentType;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
use Tests\TestCase;
class BrowseApiTest extends TestCase
{
use RefreshDatabase;
public function test_api_browse_returns_public_artworks(): void
{
$user = User::factory()->create(['name' => 'Author One']);
$contentType = ContentType::create([
'name' => 'Wallpapers',
'slug' => 'wallpapers',
'description' => 'Wallpapers content type',
]);
$category = Category::create([
'content_type_id' => $contentType->id,
'name' => 'Abstract',
'slug' => 'abstract',
'description' => 'Abstract wallpapers',
'is_active' => true,
'sort_order' => 1,
]);
$artwork = Artwork::factory()
->for($user)
->create([
'slug' => 'neon-city',
'published_at' => now()->subDay(),
]);
$artwork->categories()->attach($category->id);
$response = $this->getJson('/api/v1/browse');
$response->assertOk()
->assertJsonPath('data.0.slug', 'neon-city')
->assertJsonPath('data.0.category.slug', 'abstract')
->assertJsonPath('data.0.author.name', 'Author One');
}
public function test_web_browse_shows_artworks(): void
{
$user = User::factory()->create(['name' => 'Author Two']);
$contentType = ContentType::create([
'name' => 'Photography',
'slug' => 'photography',
'description' => 'Photos',
]);
$category = Category::create([
'content_type_id' => $contentType->id,
'name' => 'Nature',
'slug' => 'nature',
'description' => 'Nature photos',
'is_active' => true,
'sort_order' => 1,
]);
$artwork = Artwork::factory()
->for($user)
->create([
'title' => 'Forest Light',
'slug' => 'forest-light',
'published_at' => now()->subDay(),
]);
$artwork->categories()->attach($category->id);
$response = $this->get('/browse');
$response->assertOk();
$response->assertSee('Forest Light');
$response->assertSee('Author Two');
}
}