示例#1
0
 public function test_class_can_correctly_format_multiple_routes()
 {
     $this->GET_SUPER_GLOBAL_MOCK(["uno", "deux"]);
     $this->POST_SUPER_GLOBAL_MOCK(["drei", "cztery"]);
     $correctRouteList = [["uri" => '/photos', "wildcard" => false, "controller" => 'Route\\Photo', "method" => 'index', "params" => ["uno", "deux"], "request_method" => 'GET'], ["uri" => '/photos/:id', "wildcard" => '/photos/{wildcard}', "controller" => 'Route\\Photo', "method" => 'show', "params" => ["uno", "deux"], "request_method" => 'GET'], ["uri" => '/photos', "wildcard" => false, "controller" => 'Route\\Photo', "method" => 'create', "params" => ["drei", "cztery"], "request_method" => 'POST'], ["uri" => '/photos/:id', "wildcard" => '/photos/{wildcard}', "controller" => 'Route\\Photo', "method" => 'edit', "params" => null, "request_method" => 'PUT'], ["uri" => '/photos/:id', "wildcard" => '/photos/{wildcard}', "controller" => 'Route\\Photo', "method" => 'destroy', "params" => null, "request_method" => 'DELETE']];
     $router = new Router();
     $router->get('/photos', 'Route\\Photo@index');
     $router->get('/photos/:id', 'Route\\Photo@show');
     $router->post('/photos', 'Route\\Photo@create');
     $router->put('/photos/:id', 'Route\\Photo@edit');
     $router->delete('/photos/:id', 'Route\\Photo@destroy');
     $routeList = $router->getRouteList();
     for ($i = 0; $i < count($routeList); $i++) {
         foreach ($routeList[$i] as $key => $value) {
             $this->assertEquals($correctRouteList[$i][$key], $value);
         }
     }
 }