Пример #1
0
 public function testShorthandAll()
 {
     // Create Router
     $router = new \Bramus\Router\Router();
     $router->all('/', function () {
         echo 'all';
     });
     $_SERVER['REQUEST_URI'] = '/';
     // Test GET
     ob_start();
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $router->run();
     $this->assertEquals('all', ob_get_contents());
     // Test POST
     ob_clean();
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $router->run();
     $this->assertEquals('all', ob_get_contents());
     // Test PUT
     ob_clean();
     $_SERVER['REQUEST_METHOD'] = 'PUT';
     $router->run();
     $this->assertEquals('all', ob_get_contents());
     // Test DELETE
     ob_clean();
     $_SERVER['REQUEST_METHOD'] = 'DELETE';
     $router->run();
     $this->assertEquals('all', ob_get_contents());
     // Test OPTIONS
     ob_clean();
     $_SERVER['REQUEST_METHOD'] = 'OPTIONS';
     $router->run();
     $this->assertEquals('all', ob_get_contents());
     // Test PATCH
     ob_clean();
     $_SERVER['REQUEST_METHOD'] = 'PATCH';
     $router->run();
     $this->assertEquals('all', ob_get_contents());
     // Test HEAD
     ob_clean();
     $_SERVER['REQUEST_METHOD'] = 'HEAD';
     $router->run();
     $this->assertEquals('', ob_get_contents());
     // Cleanup
     ob_end_clean();
 }