47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Service;
|
|
|
|
use GuzzleHttp\Psr7\Uri;
|
|
use Uwil\ArcadiaApiPhpClient\Auth\ClientIdentifier;
|
|
use Uwil\ArcadiaApiPhpClient\Auth\ClientSecret;
|
|
use Uwil\ArcadiaApiPhpClient\Lib\ApiConfig;
|
|
use Uwil\ArcadiaApiPhpClient\Service\ApiService;
|
|
use Uwil\ArcadiaApiPhpClient\Service\ArcadiaApiService;
|
|
|
|
describe('ArcadiaApiService', function () {
|
|
it('implements ApiService interface', function () {
|
|
// GIVEN
|
|
$config = new ApiConfig(
|
|
endpoint: new Uri('http://127.0.0.1:54321'),
|
|
apiKey: new ClientIdentifier('test_id'),
|
|
secret: new ClientSecret('test_secret'),
|
|
);
|
|
|
|
// WHEN
|
|
$service = new ArcadiaApiService($config);
|
|
|
|
// THEN
|
|
expect($service)->toBeInstanceOf(ApiService::class);
|
|
});
|
|
|
|
it('returns false when endpoint is unreachable', function () {
|
|
// GIVEN
|
|
$config = new ApiConfig(
|
|
endpoint: new Uri('http://127.0.0.1:54321'),
|
|
apiKey: new ClientIdentifier('test_id'),
|
|
secret: new ClientSecret('test_secret'),
|
|
curlTimeOut: 1,
|
|
ignoreSelfSignedCert: true,
|
|
);
|
|
$service = new ArcadiaApiService($config);
|
|
|
|
// WHEN
|
|
$result = $service->ping();
|
|
|
|
// THEN
|
|
expect($result)->toBeFalse();
|
|
});
|
|
});
|