Ejemplo n.º 1
0
 public function test_cannot_dispatch_when_method_does_not_exist()
 {
     $this->setExpectedException(NotFoundHttpException::class);
     $controller = new ControllerStub();
     $this->container->shouldReceive('make')->with('Mosaic\\Tests\\Routing\\Dispatchers\\ControllerStub')->once()->andReturn($controller);
     $route = new Route(['GET'], '/', ['uses' => 'Mosaic\\Tests\\Routing\\Dispatchers\\ControllerStub@nonExisting']);
     $this->dispatcher->dispatch($route);
 }
Ejemplo n.º 2
0
 /**
  * Dispatch the request
  *
  * @param Request $request
  *
  * @return Response
  */
 public function __invoke(Request $request)
 {
     $route = $this->dispatcher->dispatch($request, $this->router->all());
     if ($this->closure->isSatisfiedBy($route)) {
         $response = $this->closure->dispatch($route);
     } else {
         $response = $this->controller->dispatch($route);
     }
     return $this->factory->make($response);
 }