/**
* @dataProvider generateUriProvider
*/
public function testGenerateUri($uri, $isUriRouteName, $siteAccessUri, $expected)
{
$siteAccess = new SiteAccess('test', 'test');
if ($uri[0] === '/') {
$matcher = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\URILexer');
$matcher->expects($this->once())->method('analyseLink')->with($uri)->will($this->returnValue($siteAccessUri . $uri));
$siteAccess->matcher = $matcher;
}
$urlGenerator = $this->getMock('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface');
$httpUtils = new HttpUtils($urlGenerator);
$httpUtils->setSiteAccess($siteAccess);
$request = Request::create('http://ezpublish.dev/');
$request->attributes->set('siteaccess', $siteAccess);
$requestAttributes = array('foo' => 'bar', 'some' => 'thing');
$request->attributes->add($requestAttributes);
if ($isUriRouteName) {
$urlGenerator->expects($this->once())->method('generate')->with($uri, $requestAttributes, UrlGeneratorInterface::ABSOLUTE_URL)->will($this->returnValue($expected . '?' . http_build_query($requestAttributes)));
}
$res = $httpUtils->generateUri($request, $uri);
$this->assertSame($expected, $res);
}