mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 15:23:12 +08:00
Replace traits with external data providers in API tests
This commit is contained in:
@@ -7,16 +7,16 @@ namespace ShlinkioApiTest\Shlink\Rest\Action;
|
||||
use Cake\Chronos\Chronos;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\DataProviderExternal;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
||||
use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait;
|
||||
use ShlinkioApiTest\Shlink\Rest\Utils\ApiTestDataProviders;
|
||||
use ShlinkioApiTest\Shlink\Rest\Utils\UrlBuilder;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class ResolveShortUrlTest extends ApiTestCase
|
||||
{
|
||||
use NotFoundUrlHelpersTrait;
|
||||
|
||||
#[Test, DataProvider('provideDisabledMeta')]
|
||||
public function shortUrlIsProperlyResolvedEvenWhenNotEnabled(array $disabledMeta): void
|
||||
{
|
||||
@@ -42,14 +42,18 @@ class ResolveShortUrlTest extends ApiTestCase
|
||||
yield 'maxVisits reached' => [['maxVisits' => 1]];
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideInvalidUrls')]
|
||||
#[Test, DataProviderExternal(ApiTestDataProviders::class, 'invalidUrlsProvider')]
|
||||
public function tryingToResolveInvalidUrlReturnsNotFoundError(
|
||||
string $shortCode,
|
||||
?string $domain,
|
||||
string $expectedDetail,
|
||||
string $apiKey,
|
||||
): void {
|
||||
$resp = $this->callApiWithKey(self::METHOD_GET, $this->buildShortUrlPath($shortCode, $domain), [], $apiKey);
|
||||
$resp = $this->callApiWithKey(
|
||||
self::METHOD_GET,
|
||||
UrlBuilder::buildShortUrlPath($shortCode, $domain),
|
||||
apiKey: $apiKey,
|
||||
);
|
||||
$payload = $this->getJsonResponsePayload($resp);
|
||||
|
||||
self::assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
|
||||
|
||||
Reference in New Issue
Block a user