Files
breadcrumb-the-shire/tests/Architecture/PublicPageRoutingContractTest.php

44 lines
1.3 KiB
PHP
Raw Normal View History

2026-03-12 14:09:06 +01:00
<?php
namespace MintyPHP\Tests\Architecture;
use PHPUnit\Framework\TestCase;
2026-03-19 18:48:16 +01:00
class PublicPageRoutingContractTest extends TestCase
2026-03-12 14:09:06 +01:00
{
use ProjectFileAssertionSupport;
public function testPublicStaticPageRoutesPointToPublicPageTargets(): void
{
2026-03-19 18:48:16 +01:00
$routes = include dirname(__DIR__, 2) . '/config/routes.php';
2026-03-12 14:09:06 +01:00
$this->assertIsArray($routes);
$byPath = [];
foreach ($routes as $route) {
if (!is_array($route)) {
continue;
}
$path = trim((string) ($route['path'] ?? ''));
if ($path === '') {
continue;
}
$byPath[$path] = $route;
}
foreach (['imprint', 'privacy', 'terms'] as $slug) {
$this->assertArrayHasKey($slug, $byPath);
$this->assertSame('public-page/' . $slug, (string) ($byPath[$slug]['target'] ?? ''));
$this->assertTrue((bool) ($byPath[$slug]['public'] ?? false));
}
}
public function testPageTemplatesAreSeparatedByContext(): void
{
2026-03-19 18:48:16 +01:00
$root = dirname(__DIR__, 2);
2026-03-12 14:09:06 +01:00
$this->assertFileExists($root . '/pages/page/index(default).phtml');
$this->assertFileDoesNotExist($root . '/pages/page/index(page).phtml');
$this->assertFileExists($root . '/pages/public-page/index(page).phtml');
}
}