Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m51s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 6m48s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m16s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m21s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 9m30s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 9m44s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 8m49s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m37s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m8s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
51 lines
2.2 KiB
PHP
51 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Editorial\Editorial;
|
|
use App\Models\Role;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use Tests\TestCase;
|
|
|
|
class EditorialAreasTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_overview_lists_areas_with_icons_todos_and_create_links(): void
|
|
{
|
|
$admin = User::factory()->admin()->create();
|
|
|
|
$this->actingAs($admin)->get('/redaktion')->assertOk()->assertInertia(fn (Assert $p) => $p
|
|
->component('Editorial/Index')
|
|
->where('section', null)
|
|
->where('areas', fn ($areas) => collect($areas)->every(fn ($a) => filled($a['icon']))
|
|
&& collect($areas)->firstWhere('key', 'news')['create']['href'] === route('news.editor.create')
|
|
&& collect($areas)->firstWhere('key', 'media')['icon'] === 'images'));
|
|
}
|
|
|
|
public function test_single_area_and_unknown_or_forbidden_areas(): void
|
|
{
|
|
$role = Role::query()->create(['name' => 'Termine']);
|
|
$role->grants()->create(['ability' => 'events.manage']);
|
|
$user = User::factory()->withRoles([$role])->create();
|
|
|
|
$this->actingAs($user)->get('/redaktion?bereich=events')->assertOk()->assertInertia(fn (Assert $p) => $p->where('section.key', 'events')->where('active', 'events'));
|
|
$this->actingAs($user)->get('/redaktion?bereich=news')->assertNotFound();
|
|
$this->actingAs($user)->get('/redaktion?bereich=gibt-es-nicht')->assertNotFound();
|
|
}
|
|
|
|
public function test_plugins_without_meta_get_a_default_icon_and_failing_todos_are_ignored(): void
|
|
{
|
|
$editorial = app(Editorial::class);
|
|
$editorial->add('kleinanzeigen', 'Kleinanzeigen', 'x::Y', 50, fn () => true, fn () => []);
|
|
$editorial->add('eigenes', 'Eigenes', 'x::Z', 51, fn () => true, fn () => []);
|
|
$editorial->meta('eigenes', todo: fn () => throw new \RuntimeException('kaputt'));
|
|
|
|
$areas = collect($editorial->menu(User::factory()->create()))->keyBy('key');
|
|
$this->assertSame('shopping-bag', $areas['kleinanzeigen']['icon']);
|
|
$this->assertSame('layout-grid', $areas['eigenes']['icon']);
|
|
$this->assertNull($areas['eigenes']['todo']);
|
|
}
|
|
}
|