functionBody($js, '_showKiBadgeDone'); $this->assertNotEmpty($body, '_showKiBadgeDone() in beleg-ki.js gefunden'); $this->assert(!str_contains($body, 'innerHTML'), '_showKiBadgeDone() setzt kein innerHTML'); $this->assert(!str_contains($body, 'onclick'), '_showKiBadgeDone() erzeugt keinen Inline-Handler'); $this->assert(str_contains($body, 'textContent'), '_showKiBadgeDone() fügt Werte per textContent ein'); $this->assert( !preg_match('/querySelector\([^)]*\+\s*v\./', $js), 'KI-Werte werden nicht in CSS-Selektoren eingesetzt' ); $app = (string)file_get_contents($root . '/public/static/js/app.js'); $this->assert( !str_contains($app, '${item.bezeichnung} assert(!str_contains($content, '}">${msg}'), "$view: Statusmeldung nicht per innerHTML"); } $settings = (string)file_get_contents($root . '/src/Views/settings/form.php'); $this->assert( !str_contains($settings, "'
' + l + '
'"), 'settings/form.php: Ollama-Fehlerdetails nicht per innerHTML' ); } /** Liefert den Rumpf einer JS-Funktion (bis zur passenden schließenden Klammer). */ private function functionBody(string $js, string $name): string { $pos = strpos($js, 'function ' . $name . '('); if ($pos === false) { return ''; } $start = strpos($js, '{', $pos); if ($start === false) { return ''; } $depth = 0; $len = strlen($js); for ($i = $start; $i < $len; $i++) { if ($js[$i] === '{') { $depth++; } elseif ($js[$i] === '}') { $depth--; if ($depth === 0) { return substr($js, $start, $i - $start + 1); } } } return ''; } }