mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-24 13:49:03 +03:00
Improved tag list api test to cover different API key cases
This commit is contained in:
parent
ff1af82ffd
commit
2be0050f3d
1 changed files with 37 additions and 4 deletions
|
@ -13,9 +13,9 @@ class ListTagsActionTest extends ApiTestCase
|
|||
* @test
|
||||
* @dataProvider provideQueries
|
||||
*/
|
||||
public function expectedListOfTagsIsReturned(array $query, array $expectedTags): void
|
||||
public function expectedListOfTagsIsReturned(string $apiKey, array $query, array $expectedTags): void
|
||||
{
|
||||
$resp = $this->callApiWithKey(self::METHOD_GET, '/tags', [RequestOptions::QUERY => $query]);
|
||||
$resp = $this->callApiWithKey(self::METHOD_GET, '/tags', [RequestOptions::QUERY => $query], $apiKey);
|
||||
$payload = $this->getJsonResponsePayload($resp);
|
||||
|
||||
self::assertEquals(['tags' => $expectedTags], $payload);
|
||||
|
@ -23,10 +23,10 @@ class ListTagsActionTest extends ApiTestCase
|
|||
|
||||
public function provideQueries(): iterable
|
||||
{
|
||||
yield 'stats not requested' => [[], [
|
||||
yield 'admin API key without stats' => ['valid_api_key', [], [
|
||||
'data' => ['bar', 'baz', 'foo'],
|
||||
]];
|
||||
yield 'stats requested' => [['withStats' => 'true'], [
|
||||
yield 'admin API key with stats' => ['valid_api_key', ['withStats' => 'true'], [
|
||||
'data' => ['bar', 'baz', 'foo'],
|
||||
'stats' => [
|
||||
[
|
||||
|
@ -46,5 +46,38 @@ class ListTagsActionTest extends ApiTestCase
|
|||
],
|
||||
],
|
||||
]];
|
||||
|
||||
yield 'author API key without stats' => ['author_api_key', [], [
|
||||
'data' => ['bar', 'foo'],
|
||||
]];
|
||||
yield 'author API key with stats' => ['author_api_key', ['withStats' => 'true'], [
|
||||
'data' => ['bar', 'foo'],
|
||||
'stats' => [
|
||||
[
|
||||
'tag' => 'bar',
|
||||
'shortUrlsCount' => 1,
|
||||
'visitsCount' => 2,
|
||||
],
|
||||
[
|
||||
'tag' => 'foo',
|
||||
'shortUrlsCount' => 2,
|
||||
'visitsCount' => 5,
|
||||
],
|
||||
],
|
||||
]];
|
||||
|
||||
yield 'domain API key without stats' => ['domain_api_key', [], [
|
||||
'data' => ['foo'],
|
||||
]];
|
||||
yield 'domain API key with stats' => ['domain_api_key', ['withStats' => 'true'], [
|
||||
'data' => ['foo'],
|
||||
'stats' => [
|
||||
[
|
||||
'tag' => 'foo',
|
||||
'shortUrlsCount' => 1,
|
||||
'visitsCount' => 0,
|
||||
],
|
||||
],
|
||||
]];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue