before the cover, so the cover and its
sit inside the main landmark
* and the skip link (#bx-content-main) lands on the page heading. The htmx partials swapped into it
* (page_54/56/58) open no of their own.
*/
class PageShellLandmarksTest extends BxDolTestCase
{
private static function read(string $sPath): string
{
$s = file_get_contents(__DIR__ . '/../../../' . $sPath);
if ($s === false)
self::fail($sPath . ' is not readable.');
return str_replace("\r\n", "\n", $s);
}
/**
* Shell => [files it is made of, in output order; cover marker; marker of the page content; marker that must come right before ].
*/
public static function shells(): array
{
$a = [
'default' => [['template/_sub_header.html', 'template/default.html', 'template/_sub_footer.html'], '', '__page_main_code__', ' '],
'application' => [['template/pt_application.html'], '__cover__', '__page_main_code__', ' '],
'artificer application' => [['modules/boonex/artificer/data/template/system/pt_application.html'], '__cover__', '__page_main_code__', ' '],
];
foreach (['ocean', 'decorous', 'protean', 'lucid'] as $sTemplate) {
$sDir = 'modules/boonex/' . $sTemplate . '/data/template/system/';
$a[$sTemplate] = [[$sDir . '_sub_header.html', 'template/default.html', $sDir . '_sub_footer.html'], '__cover__', '__page_main_code__', ' '];
$a[$sTemplate . ' application'] = [[$sDir . 'pt_application.html'], '__cover__', '__page_main_code__', ' '];
}
return $a;
}
#[\PHPUnit\Framework\Attributes\DataProvider('shells')]
public function testCoverIsInsideMain(array $aFiles, string $sCover, string $sContent, string $sBeforeClose): void
{
$s = implode("\n", array_map([self::class, 'read'], $aFiles));
$this->assertSame(1, preg_match_all('/ per page.');
$this->assertSame(1, substr_count($s, ''));
$this->assertSame(1, substr_count($s, 'id="bx-content-main"'), 'The skip link target is the itself.');
$this->assertMatchesRegularExpression('//', $s);
$iOpen = strpos($s, '');
$this->assertNotFalse($iCover);
$this->assertNotFalse($iContent);
$this->assertTrue($iOpen < $iCover && $iCover < $iContent && $iContent < $iClose, ' opens before the cover and closes after the content.');
$this->assertMatchesRegularExpression('/' . preg_quote($sBeforeClose, '/') . '\n\s*<\/main>/', $s, ' closes right after the content wrapper.');
$this->assertDoesNotMatchRegularExpression('/