. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\Middleware; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\TestCase; use PHPUnit\Framework\Attributes\CoversClass; use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Server\RequestHandlerInterface; use function response; #[CoversClass(CheckCsrf::class)] class CheckCsrfTest extends TestCase { public function testMiddleware(): void { $handler = $this->createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response()); $request = self::createRequest(RequestMethodInterface::METHOD_POST) ->withUri(Registry::container()->get(UriFactoryInterface::class)->createUri('https://example.com')); $middleware = new CheckCsrf(); $response = $middleware->process($request, $handler); self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); self::assertSame('https://example.com', $response->getHeaderLine('Location')); } }