public function testMultipleSitemapsExecute() { $templating = m::mock('Symfony\\Component\\Templating\\EngineInterface'); $templating->shouldReceive('render')->times(3); $router = m::mock('Symfony\\Component\\Routing\\RouterInterface'); $router->shouldReceive('getContext')->once()->andReturn(new RequestContext()); $manager = new SitemapManager(array(), 5, $templating); $manager->addGenerator(new TestGenerator(10)); $application = new Application(); $application->add(new DumpCommand($manager, $router, sys_get_temp_dir())); $command = $application->find('dpn:xml-sitemap:dump'); $commandTester = new CommandTester($command); $this->assertFileNotExists($this->getSitemapIndexFile()); $this->assertFileNotExists($this->getSitemapFile()); $this->assertFileNotExists($this->getSitemap1File()); $this->assertFileNotExists($this->getSitemap2File()); $commandTester->execute(array('command' => $command->getName(), 'host' => 'http://localhost', '--target' => sys_get_temp_dir())); $this->assertFileExists($this->getSitemapIndexFile()); $this->assertFileNotExists($this->getSitemapFile()); $this->assertFileExists($this->getSitemap1File()); $this->assertFileExists($this->getSitemap2File()); $this->assertContains(sprintf('[file+] %s', $this->getSitemapIndexFile()), $commandTester->getDisplay()); $this->assertContains(sprintf('[file+] %s', $this->getSitemap1File()), $commandTester->getDisplay()); $this->assertContains(sprintf('[file+] %s', $this->getSitemap2File()), $commandTester->getDisplay()); }
/** * @param $numberOfEntries * @param $maxPerSitemap * * @return SitemapManager */ private function getManager($numberOfEntries, $maxPerSitemap) { $manager = new SitemapManager(array(), $maxPerSitemap, m::mock('Symfony\\Component\\Templating\\EngineInterface')); $manager->addGenerator(new TestGenerator($numberOfEntries)); return $manager; }
/** * @param Request $request * * @return \Symfony\Component\HttpFoundation\Response */ public function sitemapIndexAction(Request $request) { return $this->createResponse($this->manager->renderSitemapIndex($request->getSchemeAndHttpHost())); }