Split public page contracts

This commit is contained in:
2026-03-19 18:48:16 +01:00
parent 98520dcc6a
commit ac9cc4955a
4 changed files with 32 additions and 20 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace MintyPHP\Tests\Architecture;
use PHPUnit\Framework\TestCase;
class PublicPageAdminContractTest extends TestCase
{
use ProjectFileAssertionSupport;
public function testPageMutationsUseSettingsUpdateCapabilityGuard(): void
{
$indexAction = $this->readProjectFile('pages/page/index($slug).php');
$copyAction = $this->readProjectFile('pages/page/copy-language().php');
$this->assertStringContainsString('UiAccessService::class', $indexAction);
$this->assertStringContainsString('SettingsAuthorizationPolicy::ABILITY_ADMIN_SETTINGS_UPDATE', $indexAction);
$this->assertStringNotContainsString('$canEdit = $currentUserId > 0;', $indexAction);
$this->assertStringContainsString('UiAccessService::class', $copyAction);
$this->assertStringContainsString('SettingsAuthorizationPolicy::ABILITY_ADMIN_SETTINGS_UPDATE', $copyAction);
}
}

View File

@@ -4,13 +4,13 @@ namespace MintyPHP\Tests\Architecture;
use PHPUnit\Framework\TestCase;
class PublicPageContractTest extends TestCase
class PublicPageRoutingContractTest extends TestCase
{
use ProjectFileAssertionSupport;
public function testPublicStaticPageRoutesPointToPublicPageTargets(): void
{
$routes = include $this->projectRootPath() . '/config/routes.php';
$routes = include dirname(__DIR__, 2) . '/config/routes.php';
$this->assertIsArray($routes);
$byPath = [];
@@ -34,23 +34,10 @@ class PublicPageContractTest extends TestCase
public function testPageTemplatesAreSeparatedByContext(): void
{
$root = $this->projectRootPath();
$root = dirname(__DIR__, 2);
$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');
}
public function testPageMutationsUseSettingsUpdateCapabilityGuard(): void
{
$indexAction = $this->readProjectFile('pages/page/index($slug).php');
$copyAction = $this->readProjectFile('pages/page/copy-language().php');
$this->assertStringContainsString('UiAccessService::class', $indexAction);
$this->assertStringContainsString('SettingsAuthorizationPolicy::ABILITY_ADMIN_SETTINGS_UPDATE', $indexAction);
$this->assertStringNotContainsString('$canEdit = $currentUserId > 0;', $indexAction);
$this->assertStringContainsString('UiAccessService::class', $copyAction);
$this->assertStringContainsString('SettingsAuthorizationPolicy::ABILITY_ADMIN_SETTINGS_UPDATE', $copyAction);
}
}

View File

@@ -32,8 +32,8 @@ ohne dass jede Aenderung immer die komplette Suite im Kopf behalten muss.
## Naechste Refactor-Kandidaten
- `tests/Architecture/FilterDrawerContractTest.php`
- `tests/Architecture/PublicPageContractTest.php`
- `tests/Architecture/CodexSkillsContractTest.php`
- `tests/Architecture/ModuleRegistryContractTest.php`
- `tests/Architecture/AgentSystemContractTest.php`
- `tests/Architecture/DetailValidationSummaryContractTest.php`
- `tests/Architecture/DetailActionPolicyContractTest.php`