65 lines
2.6 KiB
PHP
65 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Test 58: Auto-Reload der Ereignisanzeige (Nextcloud-Import)
|
|
*
|
|
* Prüft, dass die Ereignisanzeige einen Ein-/Aus-Button für automatisches
|
|
* Neuladen besitzt, per JavaScript periodisch aktualisiert wird und
|
|
* dass der zugehörige JSON-Endpunkt sowie die Route existieren.
|
|
*/
|
|
class EreignisAutoReloadTest extends TestCase
|
|
{
|
|
protected string $testName = 'Test 58: Ereignisanzeige aktualisiert sich automatisch (Ein-/Aus-Button)';
|
|
|
|
public function run(): void
|
|
{
|
|
$viewFile = __DIR__ . '/../src/Views/ereignisse/nextcloud_import.php';
|
|
$view = file_get_contents($viewFile);
|
|
$this->assert($view !== false, 'View-Datei ereignisse/nextcloud_import.php ist lesbar');
|
|
|
|
$this->assert(
|
|
str_contains($view, 'id="events-autoreload-toggle"'),
|
|
'Ein-/Aus-Button für Auto-Reload ist vorhanden'
|
|
);
|
|
|
|
$this->assert(
|
|
str_contains($view, 'localStorage'),
|
|
'Zustand des Auto-Reload-Buttons wird persistiert (localStorage)'
|
|
);
|
|
|
|
$this->assert(
|
|
str_contains($view, 'setInterval') && str_contains($view, "'/ereignisse/nextcloud-import/data'"),
|
|
'JavaScript pollt periodisch den Daten-Endpunkt'
|
|
);
|
|
|
|
$this->assert(
|
|
str_contains($view, "toggle.addEventListener('click'"),
|
|
'Button schaltet Auto-Reload per Klick ein/aus'
|
|
);
|
|
|
|
// Partial für Tabellen-Body existiert und wird sowohl beim initialen
|
|
// Laden als auch für den Daten-Endpunkt verwendet
|
|
$partialFile = __DIR__ . '/../src/Views/ereignisse/_nextcloud_import_body.php';
|
|
$this->assert(file_exists($partialFile), 'Partial _nextcloud_import_body.php existiert');
|
|
|
|
$controllerFile = __DIR__ . '/../src/Controllers/EventController.php';
|
|
$controller = file_get_contents($controllerFile);
|
|
$this->assert(
|
|
str_contains($controller, 'function nextcloudImportData'),
|
|
'EventController::nextcloudImportData() ist implementiert'
|
|
);
|
|
$this->assert(
|
|
str_contains($controller, "'ereignisse/_nextcloud_import_body'"),
|
|
'Daten-Endpunkt rendert dasselbe Partial wie die initiale Seite'
|
|
);
|
|
|
|
$routesFile = __DIR__ . '/../public/index.php';
|
|
$routes = file_get_contents($routesFile);
|
|
$this->assert(
|
|
str_contains($routes, "'/ereignisse/nextcloud-import/data'") && str_contains($routes, 'nextcloudImportData'),
|
|
'Route /ereignisse/nextcloud-import/data ist registriert'
|
|
);
|
|
}
|
|
}
|