mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-27 12:01:49 +03:00
Improved list domains api test to cover different API key cases
This commit is contained in:
parent
5283ee2c6b
commit
c8eb956778
1 changed files with 37 additions and 17 deletions
|
@ -8,30 +8,50 @@ use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
||||||
|
|
||||||
class ListDomainsTest extends ApiTestCase
|
class ListDomainsTest extends ApiTestCase
|
||||||
{
|
{
|
||||||
/** @test */
|
/**
|
||||||
public function domainsAreProperlyListed(): void
|
* @test
|
||||||
|
* @dataProvider provideApiKeysAndDomains
|
||||||
|
*/
|
||||||
|
public function domainsAreProperlyListed(string $apiKey, array $expectedDomains): void
|
||||||
{
|
{
|
||||||
$resp = $this->callApiWithKey(self::METHOD_GET, '/domains');
|
$resp = $this->callApiWithKey(self::METHOD_GET, '/domains', [], $apiKey);
|
||||||
$respPayload = $this->getJsonResponsePayload($resp);
|
$respPayload = $this->getJsonResponsePayload($resp);
|
||||||
|
|
||||||
self::assertEquals(self::STATUS_OK, $resp->getStatusCode());
|
self::assertEquals(self::STATUS_OK, $resp->getStatusCode());
|
||||||
self::assertEquals([
|
self::assertEquals([
|
||||||
'domains' => [
|
'domains' => [
|
||||||
'data' => [
|
'data' => $expectedDomains,
|
||||||
[
|
|
||||||
'domain' => 'doma.in',
|
|
||||||
'isDefault' => true,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'domain' => 'example.com',
|
|
||||||
'isDefault' => false,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'domain' => 'some-domain.com',
|
|
||||||
'isDefault' => false,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
], $respPayload);
|
], $respPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provideApiKeysAndDomains(): iterable
|
||||||
|
{
|
||||||
|
yield 'admin API key' => ['valid_api_key', [
|
||||||
|
[
|
||||||
|
'domain' => 'doma.in',
|
||||||
|
'isDefault' => true,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'domain' => 'example.com',
|
||||||
|
'isDefault' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'domain' => 'some-domain.com',
|
||||||
|
'isDefault' => false,
|
||||||
|
],
|
||||||
|
]];
|
||||||
|
yield 'author API key' => ['author_api_key', [
|
||||||
|
[
|
||||||
|
'domain' => 'doma.in',
|
||||||
|
'isDefault' => true,
|
||||||
|
],
|
||||||
|
]];
|
||||||
|
yield 'domain API key' => ['domain_api_key', [
|
||||||
|
[
|
||||||
|
'domain' => 'example.com',
|
||||||
|
'isDefault' => false,
|
||||||
|
],
|
||||||
|
]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue