2019-01-26 11:09:49 +03:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkioTest\Shlink\Common\ApiTest;
|
|
|
|
|
2019-01-26 12:19:20 +03:00
|
|
|
use Fig\Http\Message\RequestMethodInterface;
|
|
|
|
use Fig\Http\Message\StatusCodeInterface;
|
|
|
|
use GuzzleHttp\ClientInterface;
|
2019-01-26 11:09:49 +03:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-01-26 12:19:20 +03:00
|
|
|
use Psr\Http\Message\ResponseInterface;
|
2019-01-26 11:09:49 +03:00
|
|
|
|
2019-01-26 12:19:20 +03:00
|
|
|
abstract class ApiTestCase extends TestCase implements StatusCodeInterface, RequestMethodInterface
|
2019-01-26 11:09:49 +03:00
|
|
|
{
|
2019-01-26 12:19:20 +03:00
|
|
|
/** @var ClientInterface */
|
|
|
|
private static $client;
|
|
|
|
|
|
|
|
public static function setApiClient(ClientInterface $client): void
|
|
|
|
{
|
|
|
|
self::$client = $client;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
|
*/
|
|
|
|
protected function callApi(string $method, string $uri, array $options = []): ResponseInterface
|
|
|
|
{
|
|
|
|
return self::$client->request($method, $uri, $options);
|
|
|
|
}
|
2019-01-26 11:09:49 +03:00
|
|
|
}
|