2020-05-01 12:40:02 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkioApiTest\Shlink\Rest\Action;
|
|
|
|
|
|
|
|
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
|
|
|
|
2021-01-24 11:25:36 +03:00
|
|
|
class GlobalVisitsTest extends ApiTestCase
|
2020-05-01 12:40:02 +03:00
|
|
|
{
|
2021-01-10 11:36:10 +03:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @dataProvider provideApiKeys
|
|
|
|
*/
|
|
|
|
public function returnsExpectedVisitsStats(string $apiKey, int $expectedVisits): void
|
2020-05-01 12:40:02 +03:00
|
|
|
{
|
2021-01-10 11:36:10 +03:00
|
|
|
$resp = $this->callApiWithKey(self::METHOD_GET, '/visits', [], $apiKey);
|
2020-05-01 12:40:02 +03:00
|
|
|
$payload = $this->getJsonResponsePayload($resp);
|
|
|
|
|
2020-10-04 01:35:14 +03:00
|
|
|
self::assertArrayHasKey('visits', $payload);
|
|
|
|
self::assertArrayHasKey('visitsCount', $payload['visits']);
|
2021-02-09 00:44:58 +03:00
|
|
|
self::assertArrayHasKey('orphanVisitsCount', $payload['visits']);
|
2021-01-10 11:36:10 +03:00
|
|
|
self::assertEquals($expectedVisits, $payload['visits']['visitsCount']);
|
2021-02-09 00:44:58 +03:00
|
|
|
self::assertEquals(3, $payload['visits']['orphanVisitsCount']);
|
2021-01-10 11:36:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function provideApiKeys(): iterable
|
|
|
|
{
|
|
|
|
yield 'admin API key' => ['valid_api_key', 7];
|
|
|
|
yield 'domain API key' => ['domain_api_key', 0];
|
|
|
|
yield 'author API key' => ['author_api_key', 5];
|
2020-05-01 12:40:02 +03:00
|
|
|
}
|
|
|
|
}
|