Plugin-System; Neuigkeiten und Termine als mitgelieferte Plugins
- Plugins nach WordPress-Prinzip: plugin.json-Manifest mit Versions- und Abhängigkeitsprüfung, eigenes PSR-4-Autoloading, register()/boot(), activate()/deactivate()/uninstall(), Migrationen, Routen und Views je Plugin - plugins-core/ (mitgeliefert, aktiv bis zur Deaktivierung) und plugins/ (Kunden-Plugins, geschützt vor Updates, inaktiv bis zur Aktivierung) - Zustand in storage/app/plugins.json – Laden ohne Datenbankabfrage - Wiederherstellungsmodus: Ausnahmen und Fatal Errors beim Laden deaktivieren das Plugin, das Portal bleibt erreichbar - Hooks (Actions/Filter mit Prioritäten) und Registries für Navigation, Startseiten-Kacheln, Rechte und Admin-Seiten (Filament-Discovery) - Admin-Seite „Plugins“: aktivieren, deaktivieren, per ZIP installieren (ZIP-Slip-Schutz), löschen mit oder ohne Daten; abschaltbar per INHAUS_DISALLOW_FILE_MODS - Startseite komplett aus Kacheln; Plugin-Seiten als „slug::Seite“ - Version 0.3.0 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cc0020458f
commit
28ef1e4a20
155 changed files with 2762 additions and 573 deletions
99
tests/Feature/Plugins/EventsTest.php
Normal file
99
tests/Feature/Plugins/EventsTest.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Plugins;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EventsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_upcoming_and_running_events_are_listed_in_order(): void
|
||||
{
|
||||
$later = Event::factory()->create(['starts_at' => now()->addDays(10), 'ends_at' => now()->addDays(10)->addHour()]);
|
||||
$soon = Event::factory()->create(['starts_at' => now()->addDay(), 'ends_at' => now()->addDay()->addHour()]);
|
||||
$running = Event::factory()->create(['starts_at' => now()->subHour(), 'ends_at' => now()->addHour()]);
|
||||
Event::factory()->create(['starts_at' => now()->subDays(3), 'ends_at' => now()->subDays(3)->addHour()]);
|
||||
Event::factory()->create(['is_published' => false]);
|
||||
|
||||
$this->actingAs(User::factory()->create())
|
||||
->get('/termine')
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('events::Index')
|
||||
->has('events.data', 3)
|
||||
->where('events.data.0.id', $running->id)
|
||||
->where('events.data.1.id', $soon->id)
|
||||
->where('events.data.2.id', $later->id));
|
||||
}
|
||||
|
||||
public function test_all_day_events_stay_visible_for_the_whole_day(): void
|
||||
{
|
||||
$today = Event::factory()->create(['starts_at' => now()->startOfDay(), 'ends_at' => null, 'all_day' => true]);
|
||||
|
||||
$this->actingAs(User::factory()->create())
|
||||
->get('/termine')
|
||||
->assertInertia(fn (Assert $page) => $page->where('events.data.0.id', $today->id));
|
||||
}
|
||||
|
||||
public function test_event_detail_and_unpublished_events(): void
|
||||
{
|
||||
$event = Event::factory()->create(['title' => 'Betriebsfest']);
|
||||
$hidden = Event::factory()->create(['is_published' => false]);
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)->get("/termine/{$event->id}")
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page->component('events::Show')->where('event.title', 'Betriebsfest'));
|
||||
|
||||
$this->actingAs($user)->get("/termine/{$hidden->id}")->assertNotFound();
|
||||
$this->actingAs($user)->get("/termine/{$hidden->id}/kalender.ics")->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_event_can_be_downloaded_as_ics(): void
|
||||
{
|
||||
$event = Event::factory()->create([
|
||||
'title' => 'Teamschulung; Führung, Kommunikation',
|
||||
'location' => 'Raum 1.04',
|
||||
'starts_at' => '2026-10-05 10:00:00',
|
||||
'ends_at' => '2026-10-05 15:00:00',
|
||||
]);
|
||||
|
||||
$response = $this->actingAs(User::factory()->create())->get("/termine/{$event->id}/kalender.ics");
|
||||
|
||||
$response->assertOk()->assertHeader('Content-Type', 'text/calendar; charset=utf-8');
|
||||
$ics = $response->getContent();
|
||||
|
||||
$this->assertStringStartsWith("BEGIN:VCALENDAR\r\n", $ics);
|
||||
$this->assertStringContainsString('SUMMARY:Teamschulung\; Führung\, Kommunikation', $ics);
|
||||
$this->assertStringContainsString('LOCATION:Raum 1.04', $ics);
|
||||
$this->assertMatchesRegularExpression('/DTSTART:20261005T\d{6}Z/', $ics);
|
||||
|
||||
foreach (explode("\r\n", $ics) as $line) {
|
||||
$this->assertLessThanOrEqual(75, strlen($line));
|
||||
}
|
||||
}
|
||||
|
||||
public function test_all_day_ics_uses_dates(): void
|
||||
{
|
||||
$event = Event::factory()->create(['starts_at' => '2026-11-11 00:00:00', 'ends_at' => null, 'all_day' => true]);
|
||||
|
||||
$ics = $this->actingAs(User::factory()->create())->get("/termine/{$event->id}/kalender.ics")->getContent();
|
||||
|
||||
$this->assertStringContainsString('DTSTART;VALUE=DATE:20261111', $ics);
|
||||
$this->assertStringContainsString('DTEND;VALUE=DATE:20261112', $ics);
|
||||
}
|
||||
|
||||
public function test_dashboard_shows_next_four_events(): void
|
||||
{
|
||||
Event::factory()->count(6)->create();
|
||||
|
||||
$events = $this->dashboardWidget($this->actingAs(User::factory()->create())->get('/'), 'events.upcoming')['events'];
|
||||
|
||||
$this->assertCount(4, $events);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue