‪TYPO3CMS  ‪main
XmlSitemapIndexTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\Test;
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
23 
28 {
29  protected array ‪$coreExtensionsToLoad = ['seo'];
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->importCSVDataSet(__DIR__ . '/../Fixtures/pages-sitemap.csv');
35  $this->setUpFrontendRootPage(
36  1,
37  [
38  'constants' => ['EXT:seo/Configuration/TypoScript/XmlSitemap/constants.typoscript'],
39  'setup' => ['EXT:seo/Configuration/TypoScript/XmlSitemap/setup.typoscript'],
40  ]
41  );
42  }
43 
44  #[Test]
46  {
48  'website-local',
49  $this->‪buildSiteConfiguration(1, 'http://localhost/'),
50  [
51  $this->‪buildDefaultLanguageConfiguration('EN', '/'),
52  ]
53  );
54 
55  $response = $this->executeFrontendSubRequest(
56  (new InternalRequest('http://localhost/'))->withQueryParameters([
57  'id' => 1,
58  'type' => 1533906435,
59  ])
60  );
61 
62  self::assertEquals(200, $response->getStatusCode());
63  self::assertArrayHasKey('Content-Length', $response->getHeaders());
64  self::assertGreaterThan(0, $response->getHeader('Content-Length')[0]);
65  self::assertArrayHasKey('Content-Type', $response->getHeaders());
66  self::assertEquals('application/xml;charset=utf-8', $response->getHeader('Content-Type')[0]);
67  self::assertArrayHasKey('X-Robots-Tag', $response->getHeaders());
68  self::assertEquals('noindex', $response->getHeader('X-Robots-Tag')[0]);
69  self::assertMatchesRegularExpression('/<loc>http:\/\/localhost\/\?sitemap=pages&amp;type=1533906435&amp;cHash=[^<]+<\/loc>/', (string)$response->getBody());
70  }
71 }
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapIndexTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: XmlSitemapIndexTest.php:29
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapIndexTest\checkIfSiteMapIndexContainsPagesSitemap
‪checkIfSiteMapIndexContainsPagesSitemap()
Definition: XmlSitemapIndexTest.php:45
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapIndexTest
Definition: XmlSitemapIndexTest.php:28
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapIndexTest\setUp
‪setUp()
Definition: XmlSitemapIndexTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:50
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\AbstractTestCase
Definition: AbstractTestCase.php:29
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:88
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap
Definition: AbstractXmlSitemapPagesTestCase.php:18
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:98