[FEATURE] Add properties changefreq and priority to XML sitemap entries
[Packages/TYPO3.CMS.git] / typo3 / sysext / seo / Tests / Functional / XmlSitemap / XmlSitemapIndexTest.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Seo\Tests\Functional\XmlSitemap;
5
6 /*
7 * This file is part of the TYPO3 CMS project.
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\AbstractTestCase;
20 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
21
22 /**
23 * Contains functional tests for the XmlSitemap Index
24 */
25 class XmlSitemapIndexTest extends AbstractTestCase
26 {
27 /**
28 * @var string[]
29 */
30 protected $coreExtensionsToLoad = [
31 'core', 'frontend', 'seo'
32 ];
33
34 protected function setUp()
35 {
36 parent::setUp();
37 $this->importDataSet('EXT:seo/Tests/Functional/Fixtures/pages-sitemap.xml');
38 $this->setUpFrontendRootPage(
39 1,
40 [
41 'constants' => ['EXT:seo/Configuration/TypoScript/XmlSitemap/constants.typoscript'],
42 'setup' => ['EXT:seo/Configuration/TypoScript/XmlSitemap/setup.typoscript']
43 ]
44 );
45 }
46
47 /**
48 * @test
49 */
50 public function checkIfSiteMapIndexContainsPagesSitemap(): void
51 {
52 $this->writeSiteConfiguration(
53 'website-local',
54 $this->buildSiteConfiguration(1, 'http://localhost/'),
55 [
56 $this->buildDefaultLanguageConfiguration('EN', '/')
57 ]
58 );
59
60 $response = $this->executeFrontendRequest(
61 (new InternalRequest('http://localhost/'))->withQueryParameters([
62 'id' => 1,
63 'type' => 1533906435
64 ])
65 );
66
67 $this->assertEquals(200, $response->getStatusCode());
68 $this->assertArrayHasKey('Content-Length', $response->getHeaders());
69 $this->assertGreaterThan(0, $response->getHeader('Content-Length')[0]);
70 $this->assertRegExp('/<loc>http:\/\/localhost\/\?sitemap=pages&amp;type=1533906435&amp;cHash=[^<]+<\/loc>/', (string)$response->getBody());
71 }
72 }