예제 #1
0
 public function test_can_iterate_the_collection()
 {
     $route = new Route(['GET'], '/', function () {
     });
     $collection = new RouteCollection();
     $collection->add($route);
     foreach ($collection as $cRoute) {
         $this->assertEquals($route, $cRoute);
     }
 }
예제 #2
0
 public function test_cannot_dispatch_post_route_as_get()
 {
     $request = \Mockery::mock(Request::class);
     $request->shouldReceive('method')->once()->andReturn('POST');
     $request->shouldReceive('path')->once()->andReturn('/');
     $collection = new RouteCollection();
     $collection->add($givenRoute = new Route(['GET'], '/', 'HomeController@index'));
     $this->setExpectedException(MethodNotAllowedException::class, 'Method [GET, HEAD] is not allowed');
     $this->dispatcher->dispatch($request, $collection);
 }
예제 #3
0
파일: Router.php 프로젝트: Mosaic/Mosaic
 /**
  * Add a route to the underlying route collection.
  *
  * @param array|string          $methods
  * @param string                $uri
  * @param \Closure|array|string $action
  *
  * @return Route
  */
 protected function addRoute($methods, $uri, $action)
 {
     return $this->routes->add(new Route($methods, $uri, $action));
 }