mercureact/tests/Http/Middleware/NotFoundHandlerTest.php

29 lines
795 B
PHP
Raw Normal View History

2024-03-13 00:28:14 +00:00
<?php
namespace NoccyLabs\Mercureact\Http\Middleware;
use PHPUnit\Framework\Attributes\CoversClass;
use Psr\Http\Message\ResponseInterface;
use React\Http\Message\ServerRequest;
use React\Promise\Promise;
#[CoversClass(NotFoundHandler::class)]
class NotFoundHandlerTest extends \PHPUnit\Framework\TestCase
{
public function testAlwaysResolvesTo404Response()
{
$handler = new NotFoundHandler();
$request = new ServerRequest("GET", "/");
$result = null;
$promise = $handler->__invoke($request)->then(function ($r) use (&$result) {
$result = $r;
});
$this->assertInstanceOf(ResponseInterface::class, $result);
/** @var ResponseInterface $result */
$this->assertEquals(404, $result->getStatusCode());
}
}