(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.
76 lines
2.9 KiB
PHP
76 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Test 96: Struktur von settings/bankimport.php (Fix #161c)
|
|
*
|
|
* bankimport.php war mit 797 Zeilen (davon 293 JavaScript) die drittgrößte
|
|
* View der Anwendung. Dieser Test hält die im Zuge der Aufteilung
|
|
* entstandene Struktur fest, analog zu Test 86 (belege/detail.php) und
|
|
* Test 95 (bank/fints.php).
|
|
*/
|
|
class BankimportViewStrukturTest extends TestCase
|
|
{
|
|
protected string $testName = 'Test 96: Struktur von settings/bankimport.php';
|
|
|
|
public function run(): void
|
|
{
|
|
$viewDir = __DIR__ . '/../src/Views/settings';
|
|
$jsDir = __DIR__ . '/../public/static/js';
|
|
$viewFile = $viewDir . '/bankimport.php';
|
|
$content = file_get_contents($viewFile);
|
|
|
|
$this->assert($content !== false, 'settings/bankimport.php ist lesbar');
|
|
|
|
$lines = substr_count($content, "\n") + 1;
|
|
$this->assert(
|
|
$lines < 300,
|
|
"settings/bankimport.php bleibt unter 300 Zeilen (erhalten: $lines)"
|
|
);
|
|
|
|
$this->assert(
|
|
preg_match('/<script>/', $content) === 0,
|
|
'Keine inline <script>-Blöcke mehr in bankimport.php'
|
|
);
|
|
|
|
preg_match_all('/<script\b[^>]*>/', $content, $scriptTags);
|
|
$this->assertGreaterThan(0, count($scriptTags[0]), 'bankimport.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]), 'bankimport.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/settings/"
|
|
);
|
|
}
|
|
|
|
preg_match_all('/<script\s+src="\/static\/js\/([^"?]+)/', $content, $scripts);
|
|
$this->assertGreaterThan(0, count($scripts[1]), 'bankimport.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 (['_suggestion_card.php', '_format_card.php'] as $partial) {
|
|
$this->assert(is_file($viewDir . '/' . $partial), "Teil-View $partial existiert");
|
|
}
|
|
|
|
$this->assert(is_file($jsDir . '/bankimport.js'), 'JS-Datei bankimport.js existiert');
|
|
|
|
$jsContent = file_get_contents($jsDir . '/bankimport.js');
|
|
$this->assert(
|
|
$jsContent !== false && !str_contains($jsContent, '<?php') && !str_contains($jsContent, '<?='),
|
|
'bankimport.js enthält keine PHP-Interpolation'
|
|
);
|
|
}
|
|
}
|