mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-31 19:03:43 +01:00
The review step's import ran inside the view, after the layout header was
sent. Its redirect to the list was refused ("headers already sent"), so the
page ended as an empty shell: the streams were imported, and nothing said so.
The import now runs in ReviewController before render(), as Stream Review
does, and an import that fails shows an alert instead of the upload form
alone.
32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* A view BaseAdminController::render() shows comes after the layout header:
|
|
* the headers are sent by then, so a redirect from one is refused and the page
|
|
* stops at an empty shell. Import & Review ran its import, and the redirect
|
|
* that follows it, there.
|
|
*/
|
|
class AdminViewsDoNotRedirectTest extends TestCase {
|
|
public function testNoViewShownInsideTheLayoutRedirects(): void {
|
|
$rViews = [];
|
|
foreach (glob(MAIN_HOME . 'Public/Controllers/Admin/*.php') as $rFile) {
|
|
preg_match_all('/->render\(\s*\'([\w\/]+)\'/', (string) file_get_contents($rFile), $rMatches);
|
|
$rViews = array_merge($rViews, $rMatches[1]);
|
|
}
|
|
$rViews = array_unique($rViews);
|
|
|
|
$rRedirecting = [];
|
|
foreach ($rViews as $rView) {
|
|
$rFile = MAIN_HOME . 'Public/Views/admin/' . $rView . '.php';
|
|
if (is_file($rFile) && preg_match('/\bheader\(\s*[\'"]Location/i', (string) file_get_contents($rFile))) {
|
|
$rRedirecting[] = $rView;
|
|
}
|
|
}
|
|
|
|
$this->assertGreaterThan(100, count($rViews));
|
|
$this->assertSame([], $rRedirecting);
|
|
}
|
|
}
|