<?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);
    }
}
