mirror of
https://github.com/flarum/core.git
synced 2025-07-30 21:20:24 +02:00
Allow overriding routes (#2577)
This commit is contained in:
@@ -47,6 +47,41 @@ class RoutesTest extends TestCase
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals('Hello Flarumites!', $response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function existing_route_can_be_removed()
|
||||
{
|
||||
$this->extend(
|
||||
(new Extend\Routes('api'))
|
||||
->remove('GET', 'forum.show')
|
||||
);
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api')
|
||||
);
|
||||
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function custom_route_can_override_existing_route_if_removed()
|
||||
{
|
||||
$this->extend(
|
||||
(new Extend\Routes('api'))
|
||||
->remove('GET', 'forum.show')
|
||||
->get('/', 'forum.show', CustomRoute::class)
|
||||
);
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api')
|
||||
);
|
||||
|
||||
$this->assertEquals('Hello Flarumites!', $response->getBody());
|
||||
}
|
||||
}
|
||||
|
||||
class CustomRoute implements RequestHandlerInterface
|
||||
|
Reference in New Issue
Block a user