Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/sdk-php. php sdk for openstatus www.openstatus.dev
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243<?php
declare(strict_types=1);
namespace Openstatus\Sdk\Tests\Unit\Services;
use GuzzleHttp\Psr7\HttpFactory;use GuzzleHttp\Psr7\Response;use Openstatus\Health\V1\CheckRequest;use Openstatus\Health\V1\CheckResponse\ServingStatus;use Openstatus\Sdk\Services\HealthServiceClient;use Openstatus\Sdk\Tests\Support\MockHttpClient;use Openstatus\Sdk\Transport\JsonTransport;use PHPUnit\Framework\TestCase;
final class HealthServiceClientTest extends TestCase{ public function testCheckDispatchesToHealthServiceCheck(): void { $http = new MockHttpClient(new Response(200, [], '{"status":1}')); $factory = new HttpFactory(); $transport = new JsonTransport( http: $http, requestFactory: $factory, streamFactory: $factory, baseUrl: 'https://api.openstatus.dev', defaultHeaders: ['Content-Type' => 'application/json'], );
$service = new HealthServiceClient($transport); $response = $service->check(new CheckRequest());
self::assertSame(ServingStatus::SERVING_STATUS_SERVING, $response->getStatus());
$sent = $http->lastRequest; self::assertNotNull($sent); self::assertSame( 'https://api.openstatus.dev/rpc/openstatus.health.v1.HealthService/Check', (string) $sent->getUri(), ); }}