. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\Middleware; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Module\WebtreesTheme; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\TestCase; use Psr\Http\Server\RequestHandlerInterface; use function response; /** * Test the BootModules middleware. * * @covers \Fisharebest\Webtrees\Http\Middleware\BootModules */ class BootModulesTest extends TestCase { /** * @return void */ public function testMiddleware(): void { $theme = new WebtreesTheme(); $handler = self::createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('It works!')); $module_service = self::createMock(ModuleService::class); $module_service ->expects(self::once()) ->method('bootModules') ->with($theme); $request = self::createRequest(); $middleware = new BootModules($module_service, $theme); $response = $middleware->process($request, $handler); self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); self::assertSame('It works!', (string) $response->getBody()); } }