- 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>
55 lines
1.9 KiB
PHP
55 lines
1.9 KiB
PHP
<?php
|
||
|
||
namespace Tests\Feature\Plugins;
|
||
|
||
use App\Models\User;
|
||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
use Inertia\Testing\AssertableInertia as Assert;
|
||
use Tests\TestCase;
|
||
|
||
/**
|
||
* Deaktivierte Plugins hinterlassen keine Spuren im Portal.
|
||
*/
|
||
class CorePluginToggleTest extends TestCase
|
||
{
|
||
use RefreshDatabase;
|
||
|
||
private ?string $previousState = null;
|
||
|
||
protected function setUp(): void
|
||
{
|
||
parent::setUp();
|
||
|
||
$file = storage_path('app/plugins.json');
|
||
$this->previousState = is_file($file) ? file_get_contents($file) : null;
|
||
file_put_contents($file, json_encode(['news' => ['enabled' => false], 'events' => ['enabled' => false]]));
|
||
|
||
// Plugins werden beim Start der Anwendung geladen – also neu starten.
|
||
$this->refreshApplication();
|
||
$this->setUpTraits();
|
||
}
|
||
|
||
protected function tearDown(): void
|
||
{
|
||
$file = storage_path('app/plugins.json');
|
||
$this->previousState === null ? @unlink($file) : file_put_contents($file, $this->previousState);
|
||
|
||
parent::tearDown();
|
||
}
|
||
|
||
public function test_disabled_plugins_disappear_from_navigation_dashboard_routes_and_admin(): void
|
||
{
|
||
$admin = User::factory()->admin()->create();
|
||
|
||
$response = $this->actingAs($admin)->get('/')->assertOk()
|
||
->assertInertia(fn (Assert $page) => $page->where('navigation', fn ($items) => collect($items)->pluck('key')->all() === ['home', 'people']));
|
||
|
||
$this->assertNull($this->dashboardWidget($response, 'news.latest'));
|
||
$this->assertNull($this->dashboardWidget($response, 'events.upcoming'));
|
||
$this->assertNotNull($this->dashboardWidget($response, 'core.quick-links'));
|
||
|
||
$this->actingAs($admin)->get('/neuigkeiten')->assertNotFound();
|
||
$this->actingAs($admin)->get('/termine')->assertNotFound();
|
||
$this->actingAs($admin)->get('/admin/neuigkeiten')->assertNotFound();
|
||
}
|
||
}
|