result = false; SimpleRouter::group(['prefix' => '/group'], function () { $this->result = true; }); try { SimpleRouter::start(); } catch (Exception $e) { // ignore RouteNotFound exception } $this->assertTrue($this->result); } public function testNestedGroup() { SimpleRouter::router()->reset(); SimpleRouter::request()->setUri('/api/v1/test'); SimpleRouter::request()->setMethod('get'); SimpleRouter::group(['prefix' => '/api'], function () { SimpleRouter::group(['prefix' => '/v1'], function () { SimpleRouter::get('/test', 'DummyController@start'); }); }); SimpleRouter::start(); } public function testManyRoutes() { SimpleRouter::router()->reset(); SimpleRouter::request()->setUri('/my/match'); SimpleRouter::request()->setMethod('get'); SimpleRouter::group(['prefix' => '/api'], function () { SimpleRouter::group(['prefix' => '/v1'], function () { SimpleRouter::get('/test', 'DummyController@start'); }); }); SimpleRouter::get('/my/match', 'DummyController@start'); SimpleRouter::group(['prefix' => '/service'], function () { SimpleRouter::group(['prefix' => '/v1'], function () { SimpleRouter::get('/no-match', 'DummyController@start'); }); }); SimpleRouter::start(); } public function testUrls() { SimpleRouter::router()->reset(); SimpleRouter::request()->setUri('/my/fancy/url/1'); SimpleRouter::request()->setMethod('get'); SimpleRouter::get('/my/fancy/url/1', 'DummyController@start', ['as' => 'fancy1']); SimpleRouter::get('/my/fancy/url/2', 'DummyController@start')->setAlias('fancy2'); SimpleRouter::start(); $this->assertTrue((SimpleRouter::getRoute('fancy1') === '/my/fancy/url/1/')); $this->assertTrue((SimpleRouter::getRoute('fancy2') === '/my/fancy/url/2/')); } }