. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\Middleware; use Fisharebest\Webtrees\TestCase; use Psr\Http\Server\RequestHandlerInterface; use function response; /** * Test the CheckCsrf middleware. * * @covers \Fisharebest\Webtrees\Http\Middleware\CheckCsrf */ class CheckCsrfTest extends TestCase { /** * @return void */ public function testMiddleware(): void { $handler = $this->createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response()); $request = self::createRequest(self::METHOD_POST) ->withAttribute('request_uri', 'http://example.com'); $middleware = new CheckCsrf(); $response = $middleware->process($request, $handler); $this->assertSame(self::STATUS_FOUND, $response->getStatusCode()); $this->assertSame('http://example.com', $response->getHeaderLine('Location')); } }