Example #1
0
 public function testShouldGenerateAutoSave()
 {
     $generator = new Generator();
     $generator->setOutputDir($this->outputDir);
     $generator->setHostname('http://www.example.com');
     $generator->setMaxAllowedUrls(2);
     $generator->setAutoSave(true);
     $generator->setOverwrite(true);
     $generator->boot();
     $firstSitemap = $generator->getCurrentSitemap();
     $generator->addUrl(new Url('/'));
     $generator->addUrl(new Url('/path1'));
     $generator->addUrl(new Url('/path2', '2014-01-01'));
     $this->assertFileExists($this->outputDir . '/sitemap.xml');
     $this->assertFileExists($this->outputDir . '/sitemap1.xml');
     $this->assertFileNotExists($this->outputDir . '/sitemap2.xml');
     $this->assertEquals($this->readFixture('sitemap.autosave.index.xml'), $generator->getIndexSitemap()->getOutput());
     $this->assertEquals($this->readFixture('sitemap.autosave.map1.xml'), $firstSitemap->getOutput());
     // $this->putFixture('sitemap.autosave.index.xml', $generator->getIndexSitemap()->getOutput());
     // $this->putFixture('sitemap.autosave.map1.xml',  $firstSitemap->getOutput());
     // $this->putFixture('sitemap.autosave.map2.xml', $generator->getCurrentSitemap()->getOutput());
     $generator->generate();
     $this->assertFileExists($this->outputDir . '/sitemap2.xml');
     $this->assertEquals($this->readFixture('sitemap.autosave.map2.xml'), $generator->getCurrentSitemap()->getOutput());
 }