diff --git a/framework/core/tests/integration/extenders/RoutesTest.php b/framework/core/tests/integration/extenders/RoutesTest.php new file mode 100644 index 000000000..f72569e8c --- /dev/null +++ b/framework/core/tests/integration/extenders/RoutesTest.php @@ -0,0 +1,58 @@ +send( + $this->request('GET', '/custom') + ); + + $this->assertEquals(404, $response->getStatusCode()); + } + + /** + * @test + */ + public function custom_route_can_be_added_by_extender() + { + $this->extend( + (new Extend\Routes('forum')) + ->get('/custom', 'custom', CustomRoute::class) + ); + + $response = $this->send( + $this->request('GET', '/custom') + ); + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('Hello Flarumites!', $response->getBody()); + } +} + +class CustomRoute implements RequestHandlerInterface +{ + public function handle(ServerRequestInterface $request): ResponseInterface + { + return new TextResponse('Hello Flarumites!'); + } +}