Files
landing-api/tests/Feature/Panel/ContentFormsTest.php
Josep Piguillem 3897113313 Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer
collective, backed by the Pireon OAuth identity server. The public site is a
separate, server-rendered application consuming /api/public/v1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 17:55:27 +02:00

67 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Panel;
use App\Filament\Resources\Members\MemberResource;
use App\Filament\Resources\Pages\PageResource;
use App\Filament\Resources\Projects\ProjectResource;
use App\Models\Member;
use App\Models\Page;
use App\Models\Project;
use Database\Seeders\RolePermissionSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use PHPUnit\Framework\Attributes\Test;
use Tests\FakesPireon;
use Tests\TestCase;
/**
* The editing forms themselves, which the resource listing tests never reach.
*/
class ContentFormsTest extends TestCase
{
use FakesPireon, RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->seed(RolePermissionSeeder::class);
Queue::fake();
$this->actingAs($this->userWithRoles('admin'));
}
#[Test]
public function every_content_form_renders_empty(): void
{
foreach ([PageResource::class, ProjectResource::class, MemberResource::class] as $resource) {
$this->get($resource::getUrl('create'))->assertSuccessful();
}
}
#[Test]
public function every_content_form_renders_with_an_image_and_its_description(): void
{
$page = Page::factory()->create([
'featured_image' => 'pages/hero.jpg',
'featured_image_alt' => ['es' => 'Una captura'],
]);
$project = Project::factory()->create([
'cover_image' => 'projects/cover.jpg',
'cover_image_alt' => ['es' => 'La portada'],
]);
$member = Member::factory()->create(['avatar' => 'members/ada.jpg']);
// The alt-text tabs only appear once there is an image to describe,
// so a form carrying one exercises a path the empty one does not.
$this->get(PageResource::getUrl('edit', ['record' => $page]))->assertSuccessful();
$this->get(ProjectResource::getUrl('edit', ['record' => $project]))->assertSuccessful();
$this->get(MemberResource::getUrl('edit', ['record' => $member]))->assertSuccessful();
}
}