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