‪TYPO3CMS  10.4
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 
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
22 
27 {
31  protected ‪$coreExtensionsToLoad = [
32  'core', 'frontend', 'seo'
33  ];
34 
35  protected function ‪setUp(): void
36  {
37  parent::setUp();
38  $this->importDataSet('EXT:seo/Tests/Functional/Fixtures/pages-sitemap.xml');
39  $this->setUpFrontendRootPage(
40  1,
41  [
42  'constants' => ['EXT:seo/Configuration/TypoScript/XmlSitemap/constants.typoscript'],
43  'setup' => ['EXT:seo/Configuration/TypoScript/XmlSitemap/setup.typoscript']
44  ]
45  );
46  }
47 
51  public function ‪checkIfSiteMapIndexContainsPagesSitemap(): void
52  {
54  'website-local',
55  $this->‪buildSiteConfiguration(1, 'http://localhost/'),
56  [
57  $this->‪buildDefaultLanguageConfiguration('EN', '/')
58  ]
59  );
60 
61  $response = $this->executeFrontendRequest(
62  (new InternalRequest('http://localhost/'))->withQueryParameters([
63  'id' => 1,
64  'type' => 1533906435
65  ])
66  );
67 
68  self::assertEquals(200, $response->getStatusCode());
69  self::assertArrayHasKey('Content-Length', $response->getHeaders());
70  self::assertGreaterThan(0, $response->getHeader('Content-Length')[0]);
71  self::assertArrayHasKey('Content-Type', $response->getHeaders());
72  self::assertEquals('application/xml;charset=utf-8', $response->getHeader('Content-Type')[0]);
73  self::assertArrayHasKey('X-Robots-Tag', $response->getHeaders());
74  self::assertEquals('noindex', $response->getHeader('X-Robots-Tag')[0]);
75  self::assertRegExp('/<loc>http:\/\/localhost\/\?sitemap=pages&amp;type=1533906435&amp;cHash=[^<]+<\/loc>/', (string)$response->getBody());
76  }
77 }
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapIndexTest\checkIfSiteMapIndexContainsPagesSitemap
‪checkIfSiteMapIndexContainsPagesSitemap()
Definition: XmlSitemapIndexTest.php:50
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapIndexTest
Definition: XmlSitemapIndexTest.php:27
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapIndexTest\setUp
‪setUp()
Definition: XmlSitemapIndexTest.php:34
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:58
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\AbstractTestCase
Definition: AbstractTestCase.php:29
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap
Definition: AbstractXmlSitemapPagesTest.php:18
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapIndexTest\$coreExtensionsToLoad
‪string[] $coreExtensionsToLoad
Definition: XmlSitemapIndexTest.php:30
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:124
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:109