shlink/module/Rest/test/ApiKey/Model/RoleDefinitionTest.php

35 lines
1 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Rest\ApiKey\Model;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
use Shlinkio\Shlink\Rest\ApiKey\Model\RoleDefinition;
use Shlinkio\Shlink\Rest\ApiKey\Role;
class RoleDefinitionTest extends TestCase
{
#[Test]
public function forAuthoredShortUrlsCreatesRoleDefinitionAsExpected(): void
{
$definition = RoleDefinition::forAuthoredShortUrls();
2022-04-23 19:41:16 +03:00
self::assertEquals(Role::AUTHORED_SHORT_URLS, $definition->role);
self::assertEquals([], $definition->meta);
}
#[Test]
public function forDomainCreatesRoleDefinitionAsExpected(): void
{
2022-10-24 21:11:25 +03:00
$domain = Domain::withAuthority('foo.com');
$domain->setId('123');
$definition = RoleDefinition::forDomain($domain);
2022-04-23 19:41:16 +03:00
self::assertEquals(Role::DOMAIN_SPECIFIC, $definition->role);
self::assertEquals(['domain_id' => '123', 'authority' => 'foo.com'], $definition->meta);
}
}