Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m8s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m5s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m6s
CI / Build-Artefakte aktuell (pull_request) Failing after 43s
- Neuigkeiten mit Kategorien, Titelbild (WebP-Varianten), Lesezeit, geplanter Veröffentlichung und Hervorhebung; Text wird beim Speichern bereinigt - Termine mit Ort, Online-Link, ganztägigen Terminen und .ics-Export - Startseite nach Intranet-Vorbild: Slider, Neuigkeiten, Termine, Aktuelles aus den Bereichen; mobil in sinnvoller Reihenfolge - Admin: Beiträge, Kategorien und Termine - Bildverarbeitung für Shared Hosting: nur eine Vollbild-Kopie im Speicher, Speicherlimit bei Bedarf auf 256 MB angehoben (wie WordPress) - Demo-Inhalte für die Entwicklung Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
84 lines
2.9 KiB
PHP
84 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Admin;
|
|
|
|
use App\Filament\Resources\Events\Pages\CreateEvent;
|
|
use App\Filament\Resources\NewsPosts\Pages\CreateNewsPost;
|
|
use App\Models\Event;
|
|
use App\Models\NewsCategory;
|
|
use App\Models\NewsPost;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class ContentAdminTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_content_pages_are_reachable_for_admins_only(): void
|
|
{
|
|
$admin = User::factory()->admin()->create();
|
|
$post = NewsPost::factory()->create();
|
|
$event = Event::factory()->create();
|
|
|
|
foreach (['/admin/neuigkeiten', '/admin/neuigkeiten/neu', "/admin/neuigkeiten/{$post->id}/bearbeiten", '/admin/kategorien', '/admin/termine', '/admin/termine/neu', "/admin/termine/{$event->id}/bearbeiten"] as $url) {
|
|
$this->actingAs($admin)->get($url)->assertOk();
|
|
$this->actingAs(User::factory()->create())->get($url)->assertForbidden();
|
|
}
|
|
}
|
|
|
|
public function test_admin_can_write_a_post(): void
|
|
{
|
|
$admin = User::factory()->admin()->create();
|
|
$category = NewsCategory::factory()->create();
|
|
$this->actingAs($admin);
|
|
|
|
Livewire::test(CreateNewsPost::class)
|
|
->fillForm([
|
|
'title' => 'Neue Kantine eröffnet',
|
|
'teaser' => 'Ab Montag gibt es frisches Essen im Erdgeschoss.',
|
|
'category_id' => $category->id,
|
|
'published_at' => now()->subMinute()->format('Y-m-d H:i'),
|
|
])
|
|
->call('create')
|
|
->assertHasNoFormErrors();
|
|
|
|
$post = NewsPost::query()->firstOrFail();
|
|
$this->assertSame('neue-kantine-eroeffnet', $post->slug);
|
|
$this->assertSame($admin->id, $post->author_id);
|
|
$this->assertTrue($post->isPublished());
|
|
}
|
|
|
|
public function test_admin_can_create_an_event(): void
|
|
{
|
|
$this->actingAs(User::factory()->admin()->create());
|
|
|
|
Livewire::test(CreateEvent::class)
|
|
->fillForm([
|
|
'title' => 'Sommerfest',
|
|
'starts_at' => now()->addWeek()->format('Y-m-d 14:00'),
|
|
'ends_at' => now()->addWeek()->format('Y-m-d 18:00'),
|
|
'location' => 'Garten',
|
|
'is_published' => true,
|
|
])
|
|
->call('create')
|
|
->assertHasNoFormErrors();
|
|
|
|
$this->assertSame('Garten', Event::query()->firstOrFail()->location);
|
|
}
|
|
|
|
public function test_event_end_must_not_be_before_start(): void
|
|
{
|
|
$this->actingAs(User::factory()->admin()->create());
|
|
|
|
Livewire::test(CreateEvent::class)
|
|
->fillForm([
|
|
'title' => 'Falsch herum',
|
|
'starts_at' => now()->addWeek()->format('Y-m-d 14:00'),
|
|
'ends_at' => now()->addWeek()->format('Y-m-d 10:00'),
|
|
])
|
|
->call('create')
|
|
->assertHasFormErrors(['ends_at']);
|
|
}
|
|
}
|