Setzt Phase 1 aus Visualization.md um: Vanilla-PHP-REST-API mit SQLite-Persistenz, statischen API-Keys pro Agent, Codeberg-Sync fuer Backlog/Done, PHPUnit-Tests und vollstaendiger API.md-Dokumentation - Vorgaben aus Detailantworten.md (F1-F16) umgesetzt. Entwicklung/Build/Test laufen komplett in Docker-Compose-Containern (PHP 8.2 + SQLite + Composer + PHPUnit/pcov), analog zum NC-Gantt-Projekt ist auf dem Host kein PHP/Composer noetig. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
40 lines
1 KiB
PHP
40 lines
1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Monitor\Api\Tests\Db;
|
|
|
|
use Monitor\Api\Db\Database;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class DatabaseTest extends TestCase
|
|
{
|
|
public function testMigrateCreatesAllTables(): void
|
|
{
|
|
$db = Database::inMemory();
|
|
|
|
$stmt = $db->pdo()->query("SELECT name FROM sqlite_master WHERE type = 'table'");
|
|
$tables = array_column($stmt->fetchAll(), 'name');
|
|
|
|
foreach (['agents', 'tickets', 'events', 'systems', 'kpis', 'kpi_values'] as $expected) {
|
|
self::assertContains($expected, $tables);
|
|
}
|
|
}
|
|
|
|
public function testMigrateIsIdempotent(): void
|
|
{
|
|
$db = Database::inMemory();
|
|
|
|
// Zweiter Aufruf darf nicht fehlschlagen (CREATE TABLE IF NOT EXISTS).
|
|
$db->migrate();
|
|
|
|
self::assertTrue(true);
|
|
}
|
|
|
|
public function testNowReturnsIso8601Utc(): void
|
|
{
|
|
$db = Database::inMemory();
|
|
|
|
self::assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/', $db->now());
|
|
}
|
|
}
|