shlink/module/Rest/test-api/Action/ListDomainsTest.php

58 lines
1.5 KiB
PHP
Raw Normal View History

2020-09-27 03:23:17 -05:00
<?php
declare(strict_types=1);
namespace ShlinkioApiTest\Shlink\Rest\Action;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
class ListDomainsTest extends ApiTestCase
{
/**
* @test
* @dataProvider provideApiKeysAndDomains
*/
public function domainsAreProperlyListed(string $apiKey, array $expectedDomains): void
2020-09-27 03:23:17 -05:00
{
$resp = $this->callApiWithKey(self::METHOD_GET, '/domains', [], $apiKey);
2020-09-27 03:23:17 -05:00
$respPayload = $this->getJsonResponsePayload($resp);
self::assertEquals(self::STATUS_OK, $resp->getStatusCode());
self::assertEquals([
'domains' => [
'data' => $expectedDomains,
2020-09-27 03:23:17 -05:00
],
], $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,
],
]];
}
2020-09-27 03:23:17 -05:00
}