. */ 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 PHPUnit\Framework\Attributes\CoversClass; use Psr\Http\Server\RequestHandlerInterface; use function response; #[CoversClass(BootModules::class)] class BootModulesTest extends TestCase { public function testMiddleware(): void { $theme = new WebtreesTheme(); $handler = $this->createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('It works!')); $module_service = $this->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()); } }