public function testGenerateWithPageAliasFromHybridPage()
 {
     $page = $this->getMock('Sonata\\PageBundle\\Model\\PageInterface');
     $page->expects($this->exactly(5))->method('isHybrid')->will($this->returnValue(true));
     $page->expects($this->exactly(5))->method('getRouteName')->will($this->returnValue('test_route'));
     $site = $this->getMock('Sonata\\PageBundle\\Model\\SiteInterface');
     $this->siteSelector->expects($this->exactly(5))->method('retrieve')->will($this->returnValue($site));
     $cmsManager = $this->getMock('Sonata\\PageBundle\\CmsManager\\CmsManagerInterface');
     $cmsManager->expects($this->exactly(5))->method('getPageByPageAlias')->will($this->returnValue($page));
     $this->cmsSelector->expects($this->exactly(5))->method('retrieve')->will($this->returnValue($cmsManager));
     $this->defaultRouter->expects($this->at(0))->method('generate')->with($this->equalTo('test_route'), $this->equalTo(array('key' => 'value')), $this->equalTo(UrlGeneratorInterface::ABSOLUTE_PATH))->will($this->returnValue('/test/key/value'));
     $this->defaultRouter->expects($this->at(1))->method('generate')->with($this->equalTo('test_route'), $this->equalTo(array('key' => 'value')), $this->equalTo(UrlGeneratorInterface::ABSOLUTE_PATH))->will($this->returnValue('/test/key/value'));
     $this->defaultRouter->expects($this->at(2))->method('generate')->with($this->equalTo('test_route'), $this->equalTo(array('key' => 'value')), $this->equalTo(UrlGeneratorInterface::RELATIVE_PATH))->will($this->returnValue('test/key/value'));
     $this->defaultRouter->expects($this->at(3))->method('generate')->with($this->equalTo('test_route'), $this->equalTo(array('key' => 'value')), $this->equalTo(UrlGeneratorInterface::ABSOLUTE_URL))->will($this->returnValue('http://localhost/test/key/value'));
     $this->defaultRouter->expects($this->at(4))->method('generate')->with($this->equalTo('test_route'), $this->equalTo(array('key' => 'value')), $this->equalTo(UrlGeneratorInterface::NETWORK_PATH))->will($this->returnValue('//localhost/test/key/value'));
     $url = $this->router->generate('_page_alias_homepage', array('key' => 'value'));
     $this->assertEquals('/test/key/value', $url);
     $url = $this->router->generate('_page_alias_homepage', array('key' => 'value'), UrlGeneratorInterface::ABSOLUTE_PATH);
     $this->assertEquals('/test/key/value', $url);
     $url = $this->router->generate('_page_alias_homepage', array('key' => 'value'), UrlGeneratorInterface::RELATIVE_PATH);
     $this->assertEquals('test/key/value', $url);
     $url = $this->router->generate('_page_alias_homepage', array('key' => 'value'), UrlGeneratorInterface::ABSOLUTE_URL);
     $this->assertEquals('http://localhost/test/key/value', $url);
     $url = $this->router->generate('_page_alias_homepage', array('key' => 'value'), UrlGeneratorInterface::NETWORK_PATH);
     $this->assertEquals('//localhost/test/key/value', $url);
 }
 public function testGenerateWithPageAliasFromHybridPage()
 {
     $page = $this->getMock('Sonata\\PageBundle\\Model\\PageInterface');
     $page->expects($this->any())->method('isHybrid')->will($this->returnValue(true));
     $page->expects($this->once())->method('getRouteName')->will($this->returnValue('test_route'));
     $site = $this->getMock('Sonata\\PageBundle\\Model\\SiteInterface');
     $this->siteSelector->expects($this->once())->method('retrieve')->will($this->returnValue($site));
     $cmsManager = $this->getMock('Sonata\\PageBundle\\CmsManager\\CmsManagerInterface');
     $cmsManager->expects($this->once())->method('getPageByPageAlias')->will($this->returnValue($page));
     $this->cmsSelector->expects($this->once())->method('retrieve')->will($this->returnValue($cmsManager));
     $this->defaultRouter->expects($this->once())->method('generate')->with($this->equalTo('test_route'), $this->equalTo(array('key' => 'value')), $this->equalTo(true))->will($this->returnValue('http://localhost/test/key/value'));
     $url = $this->router->generate('_page_alias_homepage', array('key' => 'value'), true);
     $this->assertEquals('http://localhost/test/key/value', $url);
 }