Пример #1
0
 public function test_register_route_using_any_method()
 {
     $router = new Router();
     $this->assertNull($router->match(HttpRequestMethod::GET, new Url('/foo')));
     $this->assertNull($router->match(HttpRequestMethod::POST, new Url('/foo')));
     $this->assertNull($router->match(HttpRequestMethod::PUT, new Url('/foo')));
     $this->assertNull($router->match(HttpRequestMethod::PATCH, new Url('/foo')));
     $this->assertNull($router->match(HttpRequestMethod::UPDATE, new Url('/foo')));
     $this->assertNull($router->match(HttpRequestMethod::DELETE, new Url('/foo')));
     $router->any('/foo', 'method');
     $route = $router->match(HttpRequestMethod::GET, new Url('/foo'));
     $this->assertTrue($route instanceof IRoute);
     $this->assertEquals($route, $router->match(HttpRequestMethod::POST, new Url('/foo')));
     $this->assertEquals($route, $router->match(HttpRequestMethod::PUT, new Url('/foo')));
     $this->assertEquals($route, $router->match(HttpRequestMethod::PATCH, new Url('/foo')));
     $this->assertEquals($route, $router->match(HttpRequestMethod::UPDATE, new Url('/foo')));
     $this->assertEquals($route, $router->match(HttpRequestMethod::DELETE, new Url('/foo')));
 }