/**
  * @test
  */
 public function buildResponseIfApplicableRetunsHttpRequestIfApplicableRedirectIsFound()
 {
     $this->mockHttpRequest->expects($this->atLeastOnce())->method('getRelativePath')->willReturn('some/relative/path');
     $mockRedirect = $this->getMockBuilder(Redirect::class)->disableOriginalConstructor()->getMock();
     $mockRedirect->expects($this->atLeastOnce())->method('getStatusCode')->willReturn(301);
     $this->mockRedirectStorage->expects($this->once())->method('getOneBySourceUriPathAndHost')->with('some/relative/path')->willReturn($mockRedirect);
     $this->inject($this->redirectService, 'redirectStorage', $this->mockRedirectStorage);
     $request = $this->redirectService->buildResponseIfApplicable($this->mockHttpRequest);
     $this->assertInstanceOf(Response::class, $request);
 }
 /**
  * Check if the current request match a redirect
  *
  * @param ComponentContext $componentContext
  * @return void
  */
 public function handle(ComponentContext $componentContext)
 {
     $routingMatchResults = $componentContext->getParameter(RoutingComponent::class, 'matchResults');
     if ($routingMatchResults !== NULL) {
         return;
     }
     $httpRequest = $componentContext->getHttpRequest();
     $response = $this->redirectService->buildResponseIfApplicable($httpRequest);
     if ($response !== null) {
         $componentContext->replaceHttpResponse($response);
         $componentContext->setParameter(ComponentChain::class, 'cancel', true);
     }
 }