‪TYPO3CMS  9.5
XmlSitemapIndexTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
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 
20 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
21 
26 {
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 
50  public function ‪checkIfSiteMapIndexContainsPagesSitemap(): void
51  {
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->assertArrayHasKey('Content-Type', $response->getHeaders());
71  $this->assertEquals('application/xml;charset=utf-8', $response->getHeader('Content-Type')[0]);
72  $this->assertArrayHasKey('X-Robots-Tag', $response->getHeaders());
73  $this->assertEquals('noindex', $response->getHeader('X-Robots-Tag')[0]);
74  $this->assertRegExp('/<loc>http:\/\/localhost\/\?sitemap=pages&amp;type=1533906435&amp;cHash=[^<]+<\/loc>/', (string)$response->getBody());
75  }
76 }
‪TYPO3\CMS\Frontend\Tests\Functional\XmlSitemap\XmlSitemapIndexTest\checkIfSiteMapIndexContainsPagesSitemap
‪checkIfSiteMapIndexContainsPagesSitemap()
Definition: XmlSitemapIndexTest.php:49
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:56
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\AbstractTestCase
Definition: AbstractTestCase.php:29
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:122
‪TYPO3\CMS\Frontend\Tests\Functional\XmlSitemap
Definition: XmlSitemapIndexTest.php:4
‪TYPO3\CMS\Frontend\Tests\Functional\XmlSitemap\XmlSitemapIndexTest\$coreExtensionsToLoad
‪string[] $coreExtensionsToLoad
Definition: XmlSitemapIndexTest.php:29
‪TYPO3\CMS\Frontend\Tests\Functional\XmlSitemap\XmlSitemapIndexTest\setUp
‪setUp()
Definition: XmlSitemapIndexTest.php:33
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:107
‪TYPO3\CMS\Frontend\Tests\Functional\XmlSitemap\XmlSitemapIndexTest
Definition: XmlSitemapIndexTest.php:26