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