-
-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow adding routes after applying others
- Loading branch information
Showing
2 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Tests\unit\Http; | ||
|
||
use Flarum\Http\RouteCollection; | ||
use Flarum\Tests\unit\TestCase; | ||
|
||
class RouteCollectionTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function can_add_routes() | ||
{ | ||
$routeCollection = (new RouteCollection) | ||
->addRoute('GET', '/index', 'index', function () { | ||
echo 'index'; | ||
}) | ||
->addRoute('DELETE', '/posts', 'forum.posts.delete', function () { | ||
echo 'delete posts'; | ||
}); | ||
|
||
$this->assertEquals('/index', $routeCollection->getPath('index')); | ||
$this->assertEquals('/posts', $routeCollection->getPath('forum.posts.delete')); | ||
} | ||
|
||
/** @test */ | ||
public function can_add_routes_late() | ||
{ | ||
$routeCollection = (new RouteCollection)->addRoute('GET', '/index', 'index', function () { | ||
echo 'index'; | ||
}); | ||
|
||
$this->assertEquals('/index', $routeCollection->getPath('index')); | ||
|
||
$routeCollection->addRoute('DELETE', '/posts', 'forum.posts.delete', function () { | ||
echo 'delete posts'; | ||
}); | ||
|
||
$this->assertEquals('/posts', $routeCollection->getPath('forum.posts.delete')); | ||
} | ||
} |