delete('/delete', 'delete'); $r->get('/get', 'get'); $r->head('/head', 'head'); $r->patch('/patch', 'patch'); $r->post('/post', 'post'); $r->put('/put', 'put'); $r->options('/options', 'options'); $expected = [ ['DELETE', '/delete', 'delete'], ['GET', '/get', 'get'], ['HEAD', '/head', 'head'], ['PATCH', '/patch', 'patch'], ['POST', '/post', 'post'], ['PUT', '/put', 'put'], ['OPTIONS', '/options', 'options'], ]; $this->assertSame($expected, $r->routes); } public function testGroups() { $r = new DummyRouteCollector(); $r->delete('/delete', 'delete'); $r->get('/get', 'get'); $r->head('/head', 'head'); $r->patch('/patch', 'patch'); $r->post('/post', 'post'); $r->put('/put', 'put'); $r->options('/options', 'options'); $r->addGroup('/group-one', function (DummyRouteCollector $r) { $r->delete('/delete', 'delete'); $r->get('/get', 'get'); $r->head('/head', 'head'); $r->patch('/patch', 'patch'); $r->post('/post', 'post'); $r->put('/put', 'put'); $r->options('/options', 'options'); $r->addGroup('/group-two', function (DummyRouteCollector $r) { $r->delete('/delete', 'delete'); $r->get('/get', 'get'); $r->head('/head', 'head'); $r->patch('/patch', 'patch'); $r->post('/post', 'post'); $r->put('/put', 'put'); $r->options('/options', 'options'); }); }); $r->addGroup('/admin', function (DummyRouteCollector $r) { $r->get('-some-info', 'admin-some-info'); }); $r->addGroup('/admin-', function (DummyRouteCollector $r) { $r->get('more-info', 'admin-more-info'); }); $expected = [ ['DELETE', '/delete', 'delete'], ['GET', '/get', 'get'], ['HEAD', '/head', 'head'], ['PATCH', '/patch', 'patch'], ['POST', '/post', 'post'], ['PUT', '/put', 'put'], ['OPTIONS', '/options', 'options'], ['DELETE', '/group-one/delete', 'delete'], ['GET', '/group-one/get', 'get'], ['HEAD', '/group-one/head', 'head'], ['PATCH', '/group-one/patch', 'patch'], ['POST', '/group-one/post', 'post'], ['PUT', '/group-one/put', 'put'], ['OPTIONS', '/group-one/options', 'options'], ['DELETE', '/group-one/group-two/delete', 'delete'], ['GET', '/group-one/group-two/get', 'get'], ['HEAD', '/group-one/group-two/head', 'head'], ['PATCH', '/group-one/group-two/patch', 'patch'], ['POST', '/group-one/group-two/post', 'post'], ['PUT', '/group-one/group-two/put', 'put'], ['OPTIONS', '/group-one/group-two/options', 'options'], ['GET', '/admin-some-info', 'admin-some-info'], ['GET', '/admin-more-info', 'admin-more-info'], ]; $this->assertSame($expected, $r->routes); } } class DummyRouteCollector extends RouteCollector { public $routes = []; public function __construct() { } public function addRoute($method, $route, $handler) { $route = $this->currentGroupPrefix . $route; $this->routes[] = [$method, $route, $handler]; } } __halt_compiler();----SIGNATURE:----KYCgM9XpMt9HTHat+GwWMbtP9wLc1cuAO4Z0z2ChgxiIY0tv6LXZxBdavN4jgsQPGPwdWsk/p3LYcwDPtzkqCkQgUnclSr1ifVe4SB8lR0ruWC6VqzwPTyHQ02lQ3pzXA2RQ6E3bq6NtS74xFKcxsrok0iU+4B4vEO+cvqFoiNevftCSkkcdP/0FmYW/rOJsWlhVd43I8PTFJRqyZPP4+87/F8E0SHHqEumYVXircGq7AKGjerDB81xbXbgCtTiBZfjoz3zZVQ1O5MFLaEFjhxblawDLM3kDBO2TpeNUizX5DqdwbY4W/ZQj5n4whwYUat5Sa11HDDexNP0KNfZlkY5puF2mIsMa4dEdv5Ak4r7CiLG7mjl25/Zvrav2gJmyEyzSP1/35YckMRSDJvhDd2ZfqPRgBm4jzmZaOPNMs2heOJgbXoBDFir+PJdSUKgMO1PuXGawf3VhiV4muKPJ4Qyb29c3gwm6ke2Vf3LRlpJNFPvZ7gjLbdzDtl2GUUAQAJbFbz6alfantMniPGU1J7bUW4oK9+5O9Np6QRr59Gj8ssv4UPoLGMXkuYOvz8nUFNrZNdKzuPh2PVRuRPyGvMCwaXRk1DLcsp60mVf4nX6Uw9wrtJeQXWyDc94uelVAtILyvjC0kwcTNEN4U8hsiPXRcNt3svWQ+pw6eCX6SDc=----ATTACHMENT:----NTA4MTQ2MTk1MzcxNTMyMiAyNjk0NjkyNzUxMzg5NzYwIDM3MTcyNjk4MjI4NDMyOTI=