[new ApiKeyRole('invalid', [], $apiKey), true, Spec::andX()]; yield 'not inline invalid role' => [new ApiKeyRole('invalid', [], $apiKey), false, Spec::andX()]; yield 'inline author role' => [ new ApiKeyRole(Role::AUTHORED_SHORT_URLS, [], $apiKey), true, new BelongsToApiKeyInlined($apiKey), ]; yield 'not inline author role' => [ new ApiKeyRole(Role::AUTHORED_SHORT_URLS, [], $apiKey), false, new BelongsToApiKey($apiKey), ]; yield 'inline domain role' => [ new ApiKeyRole(Role::DOMAIN_SPECIFIC, ['domain_id' => '123'], $apiKey), true, new BelongsToDomainInlined('123'), ]; yield 'not inline domain role' => [ new ApiKeyRole(Role::DOMAIN_SPECIFIC, ['domain_id' => '456'], $apiKey), false, new BelongsToDomain('456'), ]; } /** * @test * @dataProvider provideMetas */ public function getsExpectedDomainIdFromMeta(array $meta, string $expectedDomainId): void { self::assertEquals($expectedDomainId, Role::domainIdFromMeta($meta)); } public function provideMetas(): iterable { yield 'empty meta' => [[], '-1']; yield 'meta without domain_id' => [['foo' => 'bar'], '-1']; yield 'meta with domain_id' => [['domain_id' => '123'], '123']; } }