Sonata\Exporter\Test\Writer\SitemapWriterTest::testSimpleWrite PHP Метод

testSimpleWrite() публичный Метод

public testSimpleWrite ( )
    public function testSimpleWrite()
    {
        $writer = new SitemapWriter($this->folder);
        $writer->open();
        $writer->write(array('url' => 'https://sonata-project.org/bundle/', 'lastmod' => '2012-12-26', 'change' => 'daily'));
        $writer->close();
        $generatedFiles = $this->getFiles();
        $this->assertEquals(2, count($generatedFiles));
        // this will throw an exception if the xml is invalid
        new SimpleXMLElement(file_get_contents($generatedFiles[1]));
        $expected = <<<'XML'
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url><loc>https://sonata-project.org/bundle/</loc><lastmod>2012-12-26</lastmod><changefreq>weekly</changefreq><priority>0.5</priority></url>
</urlset>
XML;
        $this->assertEquals(trim($expected), file_get_contents($generatedFiles[1]));
    }