public function testOnKernelRequestRedirectPrependSiteaccess()
{
$queryParameters = array('some' => 'thing');
$cookieParameters = array('cookie' => 'value');
$siteaccessMatcher = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\URILexer');
$siteaccess = new SiteAccess('test', 'foo', $siteaccessMatcher);
$semanticPathinfo = '/foo/something';
$request = Request::create('/test_sa/foo/bar', 'GET', $queryParameters, $cookieParameters);
$request->attributes->set('semanticPathinfo', $semanticPathinfo);
$request->attributes->set('needsRedirect', true);
$request->attributes->set('siteaccess', $siteaccess);
$request->attributes->set('prependSiteaccessOnRedirect', true);
$expectedURI = "/test{$semanticPathinfo}";
$siteaccessMatcher->expects($this->once())->method('analyseLink')->with($semanticPathinfo)->will($this->returnValue($expectedURI));
$event = new GetResponseEvent($this->httpKernel, $request, HttpKernelInterface::MASTER_REQUEST);
$this->requestEventListener->onKernelRequestRedirect($event);
$this->assertTrue($event->hasResponse());
/** @var RedirectResponse $response */
$response = $event->getResponse();
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $response);
$this->assertSame("{$expectedURI}?some=thing", $response->getTargetUrl());
$this->assertSame(301, $response->getStatusCode());
$this->assertTrue($event->isPropagationStopped());
}