Passed
Pull Request — master (#339)
by Alejandro
05:38
created

ApiTestCase::setApiClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 1
dl 0
loc 3
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Common\ApiTest;
5
6
use Fig\Http\Message\RequestMethodInterface;
7
use Fig\Http\Message\StatusCodeInterface;
8
use GuzzleHttp\ClientInterface;
9
use PHPUnit\Framework\TestCase;
10
use Psr\Http\Message\ResponseInterface;
11
use function sprintf;
12
13
abstract class ApiTestCase extends TestCase implements StatusCodeInterface, RequestMethodInterface
14
{
15
    private const PATH_PREFX = '/rest/v1';
16
17
    /** @var ClientInterface */
18
    private static $client;
19
20
    public static function setApiClient(ClientInterface $client): void
21
    {
22
        self::$client = $client;
23
    }
24
25
    /**
26
     * @throws \GuzzleHttp\Exception\GuzzleException
27
     */
28
    protected function callApi(string $method, string $uri, array $options = []): ResponseInterface
29
    {
30
        return self::$client->request($method, sprintf('%s%s', self::PATH_PREFX, $uri), $options);
31
    }
32
}
33