(a) public/O-CHAT.html nach BEISPIELE/ verschoben, Test 93 hält den Webroot sauber. (b) bank/fints.php in Teil-Views + public/static/js/fints.js aufgeteilt. (c) settings/bankimport.php in Teil-Views + public/static/js/bankimport.js aufgeteilt. (d) src/Request.php angelegt, BankController als erster Controller umgestellt.
78 lines
3 KiB
PHP
78 lines
3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Test 95: Struktur von bank/fints.php (Fix #161b)
|
|
*
|
|
* fints.php war mit 986 Zeilen (davon 517 JavaScript) die zweitgrößte View
|
|
* der Anwendung. Dieser Test hält die im Zuge der Aufteilung entstandene
|
|
* Struktur fest, analog zu Test 86 für belege/detail.php: fints.php ist nur
|
|
* noch ein Gerüst aus Includes und einem <script src>-Tag, das Markup steckt
|
|
* in Teil-Views, die Logik in einer eigenständigen JS-Datei.
|
|
*/
|
|
class FinTsViewStrukturTest extends TestCase
|
|
{
|
|
protected string $testName = 'Test 95: Struktur von bank/fints.php';
|
|
|
|
public function run(): void
|
|
{
|
|
$viewDir = __DIR__ . '/../src/Views/bank';
|
|
$jsDir = __DIR__ . '/../public/static/js';
|
|
$viewFile = $viewDir . '/fints.php';
|
|
$content = file_get_contents($viewFile);
|
|
|
|
$this->assert($content !== false, 'bank/fints.php ist lesbar');
|
|
|
|
$lines = substr_count($content, "\n") + 1;
|
|
$this->assert(
|
|
$lines < 300,
|
|
"bank/fints.php bleibt unter 300 Zeilen (erhalten: $lines)"
|
|
);
|
|
|
|
$this->assert(
|
|
preg_match('/<script>/', $content) === 0,
|
|
'Keine inline <script>-Blöcke mehr in fints.php'
|
|
);
|
|
|
|
preg_match_all('/<script\b[^>]*>/', $content, $scriptTags);
|
|
$this->assertGreaterThan(0, count($scriptTags[0]), 'fints.php bindet mindestens eine externe JS-Datei ein');
|
|
foreach ($scriptTags[0] as $tag) {
|
|
$this->assert(
|
|
str_contains($tag, 'src='),
|
|
"Script-Tag lädt eine externe Datei statt Inline-JS: $tag"
|
|
);
|
|
}
|
|
|
|
preg_match_all('/include\s+__DIR__\s*\.\s*\'\/([^\']+)\'/', $content, $includes);
|
|
$this->assertGreaterThan(0, count($includes[1]), 'fints.php bindet Teil-Views per include ein');
|
|
foreach ($includes[1] as $partial) {
|
|
$this->assert(
|
|
is_file($viewDir . '/' . $partial),
|
|
"Teil-View $partial existiert in src/Views/bank/"
|
|
);
|
|
}
|
|
|
|
preg_match_all('/<script\s+src="\/static\/js\/([^"?]+)/', $content, $scripts);
|
|
$this->assertGreaterThan(0, count($scripts[1]), 'fints.php bindet JS-Dateien per <script src> ein');
|
|
foreach ($scripts[1] as $js) {
|
|
$this->assert(
|
|
is_file($jsDir . '/' . $js),
|
|
"JS-Datei $js existiert in public/static/js/"
|
|
);
|
|
}
|
|
|
|
foreach (['_connection_grid.php', '_modal_new_connection.php', '_modal_edit_connection.php',
|
|
'_modal_account_select.php', '_modal_tan_input.php', '_modal_run_log.php'] as $partial) {
|
|
$this->assert(is_file($viewDir . '/' . $partial), "Teil-View $partial existiert");
|
|
}
|
|
|
|
$this->assert(is_file($jsDir . '/fints.js'), 'JS-Datei fints.js existiert');
|
|
|
|
$jsContent = file_get_contents($jsDir . '/fints.js');
|
|
$this->assert(
|
|
$jsContent !== false && !str_contains($jsContent, '<?php') && !str_contains($jsContent, '<?='),
|
|
'fints.js enthält keine PHP-Interpolation'
|
|
);
|
|
}
|
|
}
|