[FEATURE] Add properties changefreq and priority to XML sitemap entries
[Packages/TYPO3.CMS.git] / typo3 / sysext / seo / Tests / Functional / XmlSitemap / XmlSitemapRecordsTest.php
index 8c3f5b1..1504a09 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 declare(strict_types = 1);
 
-namespace TYPO3\CMS\Frontend\Tests\Functional\XmlSitemap;
+namespace TYPO3\CMS\Seo\Tests\Functional\XmlSitemap;
 
 /*
  * This file is part of the TYPO3 CMS project.
@@ -38,13 +38,15 @@ class XmlSitemapRecordsTest extends AbstractTestCase
         parent::setUp();
         $this->importDataSet('EXT:seo/Tests/Functional/Fixtures/pages-sitemap.xml');
         $this->importDataSet('EXT:seo/Tests/Functional/Fixtures/sys_category.xml');
+        $this->importDataSet('EXT:seo/Tests/Functional/Fixtures/tt_content.xml');
         $this->setUpFrontendRootPage(
             1,
             [
                 'constants' => ['EXT:seo/Configuration/TypoScript/XmlSitemap/constants.typoscript'],
                 'setup' => [
                     'EXT:seo/Configuration/TypoScript/XmlSitemap/setup.typoscript',
-                    'EXT:seo/Tests/Functional/Fixtures/records.typoscript'
+                    'EXT:seo/Tests/Functional/Fixtures/records.typoscript',
+                    'EXT:seo/Tests/Functional/Fixtures/content.typoscript'
                 ],
             ]
         );
@@ -80,6 +82,43 @@ class XmlSitemapRecordsTest extends AbstractTestCase
         $content = $stream->getContents();
         self::assertContains('http://localhost/?tx_example_category%5Bid%5D=1&amp;', $content);
         self::assertContains('http://localhost/?tx_example_category%5Bid%5D=2&amp;', $content);
+        self::assertContains('<priority>0.5</priority>', $content);
+
+        $this->assertGreaterThan(0, $response->getHeader('Content-Length')[0]);
+    }
+
+    /**
+     * @test
+     */
+    public function checkIfSiteMapIndexContainsCustomChangeFreqAndPriorityValues(): void
+    {
+        $this->writeSiteConfiguration(
+            'website-local',
+            $this->buildSiteConfiguration(1, 'http://localhost/'),
+            [
+                $this->buildDefaultLanguageConfiguration('EN', '/'),
+            ]
+        );
+
+        $response = $this->executeFrontendRequest(
+            (new InternalRequest('http://localhost/'))->withQueryParameters(
+                [
+                    'id' => 1,
+                    'type' => 1533906435,
+                    'sitemap' => 'content',
+                ]
+            )
+        );
+
+        $this->assertEquals(200, $response->getStatusCode());
+        $this->assertArrayHasKey('Content-Length', $response->getHeaders());
+        $stream = $response->getBody();
+        $stream->rewind();
+        $content = $stream->getContents();
+
+        self::assertContains('<changefreq>hourly</changefreq>', $content);
+        self::assertContains('<priority>0.7</priority>', $content);
+
         $this->assertGreaterThan(0, $response->getHeader('Content-Length')[0]);
     }
 }