Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
30 lines
1.0 KiB
PHP
30 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Library;
|
|
|
|
use LIT\MCP\Integrations\Divi\Library\DiviRoles;
|
|
use LIT\MCP\Tests\Unit\TestCase;
|
|
|
|
final class DiviRolesTest extends TestCase
|
|
{
|
|
public function testAsksTheCheckAndExplainsARefusal(): void
|
|
{
|
|
$roles = new DiviRoles(static fn (string $cap): bool => $cap !== 'edit_global_library');
|
|
|
|
self::assertTrue($roles->allows('divi_library'));
|
|
self::assertNull($roles->refusal('divi_library'));
|
|
$refusal = $roles->refusal('edit_global_library');
|
|
self::assertToolError($refusal, 'forbidden');
|
|
self::assertStringContainsString('Globale Bibliothekselemente bearbeiten', $refusal->get_error_message());
|
|
self::assertStringContainsString('Rollen-Editor', $refusal->get_error_message());
|
|
}
|
|
|
|
public function testWithoutDiviNothingIsAllowed(): void
|
|
{
|
|
// Unit tests have no et_pb_is_allowed(): a missing Divi function never means "allowed".
|
|
self::assertFalse((new DiviRoles())->allows('divi_library'));
|
|
}
|
|
}
|