Beispiel #1
0
 function it_matches_and_dispatches_route(RouteMatcher $matcher, MiddlewarePipelineFactory $pipelineFactory, RouteCollection $routes, RouteDispatcherFactory $dispatcherFactory, RequestRouteCollectionFactory $requestRouteCollectionFactory, Route $route, MiddlewarePipeline $pipeline, RouteDispatcher $routeDispatcher, ServerRequestInterface $request, ResponseInterface $response)
 {
     $matcher->match($request, $routes)->willReturn($route);
     $route->getMiddlewares()->willReturn(['middleware']);
     $pipelineFactory->create(['middleware'])->willReturn($pipeline->getWrappedObject());
     $dispatcherFactory->create($route)->willReturn($routeDispatcher);
     $pipeline->process($request, $routeDispatcher)->willReturn($response);
     $requestRouteCollectionFactory->create($routes, $request)->willReturn($routes);
     $this->next($request)->shouldBe($response);
 }
Beispiel #2
0
 /**
  * @inheritDoc
  */
 public function next(ServerRequestInterface $request) : ResponseInterface
 {
     $requestRouteCollection = $this->routeCollectionFactory->create($this->routes, $request);
     // Find matching route against provided request.
     $route = $this->matcher->match($request, $requestRouteCollection);
     // Create route middleware pipeline.
     $pipeline = $this->pipelineFactory->create($route->getMiddlewares());
     // Create the last delegate, which calls route handler.
     $routeDispatcher = $this->dispatcherFactory->create($route);
     return $pipeline->process($request, $routeDispatcher);
 }