public function setUp()
 {
     $this->provider = $this->getMockBuilder('Symfony\\Cmf\\Bundle\\SeoBundle\\Sitemap\\UrlInformationProvider')->disableOriginalConstructor()->getMock();
     $this->provider->expects($this->any())->method('getUrlInformation')->will($this->returnValue($this->createUrlInformation()));
     $this->templating = $this->getMock('Symfony\\Component\\Templating\\EngineInterface');
     $this->controller = new SitemapController($this->provider, $this->templating, array('test' => array('templates' => array('xml' => 'CmfSeoBundle:Sitemap:index.xml.twig', 'html' => 'CmfSeoBundle:Sitemap:index.html.twig'))));
 }
 public function testProvider()
 {
     $urlInformations = $this->provider->getUrlInformation();
     $this->assertCount(1, $urlInformations);
     $urlInformation = reset($urlInformations);
     $this->assertInstanceof('Symfony\\Cmf\\Bundle\\SeoBundle\\Model\\UrlInformation', $urlInformation);
     $this->assertEquals('http://symfony.com', $urlInformation->getLocation());
 }
 /**
  * @param string $_format The format of the sitemap.
  * @param string $sitemap The sitemap to show.
  *
  * @return Response
  */
 public function indexAction($_format, $sitemap)
 {
     if (!isset($this->configurations[$sitemap])) {
         throw new NotFoundHttpException(sprintf('Unknown sitemap "%s"', $sitemap));
     }
     $templates = $this->configurations[$sitemap]['templates'];
     $supportedFormats = array_merge(array('json'), array_keys($templates));
     if (!in_array($_format, $supportedFormats)) {
         $text = sprintf('Unknown format %s, use one of %s.', $_format, implode(', ', $supportedFormats));
         return new Response($text, 406);
     }
     $urlInformation = $this->sitemapProvider->getUrlInformation($sitemap);
     if (isset($templates[$_format])) {
         return new Response($this->templating->render($templates[$_format], array('urls' => $urlInformation)));
     }
     return $this->createJsonResponse($urlInformation);
 }