public function testTextSitemapWriterWritingUrls()
 {
     $path = Helper::createTempDir() . '/name.txt';
     $writer = new TextSitemapWriter($path);
     $writer->add('http://someurl');
     $writer->close();
     $this->assertFileExists($path);
     $this->assertEquals('http://someurl' . PHP_EOL, file_get_contents($path));
 }
    public function testCustomPrefixForIndexFile()
    {
        $creator = new \SitemapGenerator\SitemapCreator();
        $tmpPath = \tests\Helper::createTempDir();
        $creator->setPath($tmpPath);
        $creator->setFileName('customname');
        $creator->setDomain("http://xxx.com");
        $url = new \SitemapGenerator\Url();
        $url->loc = '/link1';
        $creator->addUrl($url);
        $indexCreator = $creator->buildIndexCreator();
        $indexCreator->setFileNameForIndex('differentnamethansitemap');
        $indexCreator->createIndex("http://xxx.com/");
        $this->assertFileExists($tmpPath . DIRECTORY_SEPARATOR . 'differentnamethansitemap-index-1.xml');
        $contents = file_get_contents($tmpPath . DIRECTORY_SEPARATOR . 'differentnamethansitemap-index-1.xml');
        $expectedContent = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 <sitemap>
  <loc>http://xxx.com/customname-1.xml</loc>
 </sitemap>
</sitemapindex>

XML;
        $this->assertEquals($expectedContent, $contents);
    }