mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Converted Role constants to enum
This commit is contained in:
@@ -16,7 +16,7 @@ class RoleDefinitionTest extends TestCase
|
||||
{
|
||||
$definition = RoleDefinition::forAuthoredShortUrls();
|
||||
|
||||
self::assertEquals(Role::AUTHORED_SHORT_URLS, $definition->roleName);
|
||||
self::assertEquals(Role::AUTHORED_SHORT_URLS, $definition->role);
|
||||
self::assertEquals([], $definition->meta);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class RoleDefinitionTest extends TestCase
|
||||
$domain = Domain::withAuthority('foo.com')->setId('123');
|
||||
$definition = RoleDefinition::forDomain($domain);
|
||||
|
||||
self::assertEquals(Role::DOMAIN_SPECIFIC, $definition->roleName);
|
||||
self::assertEquals(Role::DOMAIN_SPECIFIC, $definition->role);
|
||||
self::assertEquals(['domain_id' => '123', 'authority' => 'foo.com'], $definition->meta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ class RoleTest extends TestCase
|
||||
{
|
||||
$apiKey = ApiKey::create();
|
||||
|
||||
yield 'invalid role' => [new ApiKeyRole('invalid', [], $apiKey), Spec::andX()];
|
||||
yield 'author role' => [
|
||||
new ApiKeyRole(Role::AUTHORED_SHORT_URLS, [], $apiKey),
|
||||
new BelongsToApiKey($apiKey),
|
||||
@@ -54,7 +53,6 @@ class RoleTest extends TestCase
|
||||
{
|
||||
$apiKey = ApiKey::create();
|
||||
|
||||
yield 'invalid role' => [new ApiKeyRole('invalid', [], $apiKey), Spec::andX()];
|
||||
yield 'author role' => [
|
||||
new ApiKeyRole(Role::AUTHORED_SHORT_URLS, [], $apiKey),
|
||||
Spec::andX(new BelongsToApiKeyInlined($apiKey)),
|
||||
@@ -101,15 +99,14 @@ class RoleTest extends TestCase
|
||||
* @test
|
||||
* @dataProvider provideRoleNames
|
||||
*/
|
||||
public function getsExpectedRoleFriendlyName(string $roleName, string $expectedFriendlyName): void
|
||||
public function getsExpectedRoleFriendlyName(Role $roleName, string $expectedFriendlyName): void
|
||||
{
|
||||
self::assertEquals($expectedFriendlyName, Role::toFriendlyName($roleName));
|
||||
}
|
||||
|
||||
public function provideRoleNames(): iterable
|
||||
{
|
||||
yield 'unknown' => ['unknown', ''];
|
||||
yield Role::AUTHORED_SHORT_URLS => [Role::AUTHORED_SHORT_URLS, 'Author only'];
|
||||
yield Role::DOMAIN_SPECIFIC => [Role::DOMAIN_SPECIFIC, 'Domain only'];
|
||||
yield Role::AUTHORED_SHORT_URLS->value => [Role::AUTHORED_SHORT_URLS, 'Author only'];
|
||||
yield Role::DOMAIN_SPECIFIC->value => [Role::DOMAIN_SPECIFIC, 'Domain only'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user