Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding routes #2577

Merged
merged 7 commits into from
Feb 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tweak RouteTest
  • Loading branch information
SychO9 committed Feb 19, 2021
commit 902afdbedfeb55ac2f2cc3e96dfde3b78a7cbe83
26 changes: 19 additions & 7 deletions tests/integration/extenders/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,36 @@ public function custom_route_can_be_added_by_extender()
/**
* @test
*/
public function custom_route_can_override_existing_route_if_removed()
public function existing_route_can_be_removed()
{
$this->extend(
(new Extend\Routes('api'))
->remove('GET', 'forum.show')
->get('/overridenRoute', 'forum.show', CustomRoute::class)
);

$response = $this->send(
$this->request('GET', '/api/')
$this->request('GET', '/api')
);

$response2 = $this->send(
$this->request('GET', '/api/overridenRoute')
$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)
);

$this->assertEquals(404, $response->getStatusCode());
$this->assertEquals('Hello Flarumites!', $response2->getBody());
$response = $this->send(
$this->request('GET', '/api')
);

$this->assertEquals('Hello Flarumites!', $response->getBody());
}
}

Expand Down