Skip to content

Commit

Permalink
add PingHandler Test
Browse files Browse the repository at this point in the history
  • Loading branch information
BibaltiK committed Oct 17, 2023
1 parent ddcf2ac commit 9bf237f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/AppTest/Handler/PingHandlerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace AppTest\Handler;

use App\Handler\PingHandler;
use Laminas\Diactoros\Response\JsonResponse;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ServerRequestInterface;

use function json_decode;
use function property_exists;

use const JSON_THROW_ON_ERROR;

class PingHandlerTest extends TestCase
{
public function testResponse(): void
{
$pingHandler = new PingHandler();
$response = $pingHandler->handle(
$this->createMock(ServerRequestInterface::class)
);

$json = json_decode((string) $response->getBody(), null, 512, JSON_THROW_ON_ERROR);

self::assertInstanceOf(JsonResponse::class, $response);
self::assertTrue(property_exists($json, 'ack') && $json->ack !== null);
}
}

0 comments on commit 9bf237f

Please sign in to comment.