mezzio-api-skeleton/test/AppTest/Handler/PingHandlerTest.php

32 lines
732 B
PHP
Raw Normal View History

2020-12-25 20:41:26 +01:00
<?php
declare(strict_types=1);
namespace AppTest\Handler;
use App\Handler\PingHandler;
use Laminas\Diactoros\Response\JsonResponse;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ServerRequestInterface;
use function json_decode;
class PingHandlerTest extends TestCase
{
use ProphecyTrait;
public function testResponse()
{
$pingHandler = new PingHandler();
$response = $pingHandler->handle(
$this->prophesize(ServerRequestInterface::class)->reveal()
);
$json = json_decode((string) $response->getBody());
$this->assertInstanceOf(JsonResponse::class, $response);
$this->assertTrue(isset($json->ack));
}
}