. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\Middleware; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Module\WebtreesTheme; use Fisharebest\Webtrees\Module\XeneaTheme; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\TestCase; use Illuminate\Support\Collection; 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 = $this->createMock(RequestHandlerInterface::class); $handler->method('handle')->willReturn(response('It works!')); $module_service = $this->createMock(ModuleService::class); $module_service ->expects($this->once()) ->method('bootModules') ->with($theme); $request = self::createRequest(); $middleware = new BootModules($module_service, $theme); $response = $middleware->process($request, $handler); $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); $this->assertSame('It works!', (string) $response->getBody()); } }