‪TYPO3CMS  10.4
XmlSitemapPagesTest.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 
24 {
28  protected $configurationToUseInTestInstance = [
29  'FE' => [
30  'cacheHash' => [
31  'enforceValidation' => false,
32  ],
33  ],
34  ];
35 
41  public function checkIfPagesSiteMapContainsExpectedEntries($urlPattern): void
42  {
43  $response = $this->‪getResponse();
44  self::assertEquals(200, $response->getStatusCode());
45  self::assertArrayHasKey('Content-Length', $response->getHeaders());
46  self::assertGreaterThan(0, $response->getHeader('Content-Length')[0]);
47  self::assertArrayHasKey('Content-Type', $response->getHeaders());
48  self::assertEquals('application/xml;charset=utf-8', $response->getHeader('Content-Type')[0]);
49  self::assertArrayHasKey('X-Robots-Tag', $response->getHeaders());
50  self::assertEquals('noindex', $response->getHeader('X-Robots-Tag')[0]);
51 
52  self::assertRegExp($urlPattern, (string)$response->getBody());
53  }
54 
59  {
60  self::assertStringNotContainsString(
61  '<loc>http://localhost/canonicalized-page</loc>',
62  (string)$this->‪getResponse()->getBody()
63  );
64  }
65 
70  {
71  self::assertStringNotContainsString(
72  '<loc>http://localhost/no-index</loc>',
73  (string)$this->‪getResponse()->getBody()
74  );
75  }
76 
83  {
84  self::assertStringNotContainsString(
85  '<loc>http://localhost/hidden-in-default</loc>',
86  (string)$this->‪getResponse()->getBody()
87  );
88  }
89 
96  {
97  self::assertStringNotContainsString(
98  '<loc>http://localhost/de/dummy-1-2-5-fr</loc>',
99  (string)$this->‪getResponse('http://localhost/de/')->getBody()
100  );
101  }
102 
106  public function ‪pagesToCheckDataProvider(): array //18-03-2019 21:24:07
107  {
108  return [
109  'complete-entry' => ['#<url>\s+<loc>http://localhost/complete\-entry</loc>\s+<lastmod>\d+-\d+-\d+T\d+:\d+:\d+\+\d+:\d+</lastmod>\s+<changefreq>daily</changefreq>\s+<priority>0\.7</priority>\s+</url>#'],
110  'only-changefreq' => ['#<url>\s+<loc>http://localhost/only\-changefreq</loc>\s+<lastmod>\d+-\d+-\d+T\d+:\d+:\d+\+\d+:\d+</lastmod>\s+<changefreq>weekly</changefreq>\s+<priority>0\.5</priority>\s+</url>#'],
111  'clean' => ['#<url>\s+<loc>http://localhost/clean</loc>\s+<lastmod>\d+-\d+-\d+T\d+:\d+:\d+\+\d+:\d+</lastmod>\s+<priority>0\.5</priority>\s+</url>#'],
112  ];
113  }
114 
118  public function ‪pagesSitemapContainsTranslatedPages(): void
119  {
120  self::assertEquals(
121  4,
122  (new \SimpleXMLElement((string)$this->‪getResponse('http://localhost/fr/')->getBody()))->count()
123  );
124  }
125 
129  public function ‪pagesSitemapDoesNotContainUntranslatedPages(): void
130  {
131  self::assertStringNotContainsString(
132  '<loc>http://localhost/dummy-1-4</loc>',
133  (string)$this->‪getResponse('http://localhost/fr/')->getBody()
134  );
135  }
136 
140  public function ‪pagesSitemapRespectFallbackStrategy(): void
141  {
142  self::assertStringContainsString(
143  '<loc>http://localhost/de/dummy-1-3-fr</loc>',
144  (string)$this->‪getResponse('http://localhost/de/')->getBody()
145  );
146  }
147 }
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapRespectFallbackStrategy
‪pagesSitemapRespectFallbackStrategy()
Definition: XmlSitemapPagesTest.php:139
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap
Definition: AbstractXmlSitemapPagesTest.php:18
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest
Definition: XmlSitemapPagesTest.php:24
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapInAlternativeLanguageDoesNotContainSiteThatIsHiddenIfNotTranslated
‪pagesSitemapInAlternativeLanguageDoesNotContainSiteThatIsHiddenIfNotTranslated()
Definition: XmlSitemapPagesTest.php:94
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapDoesNotContainUrlWithCanonicalSet
‪pagesSitemapDoesNotContainUrlWithCanonicalSet()
Definition: XmlSitemapPagesTest.php:57
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapDoesNotContainUrlWithNoIndexSet
‪pagesSitemapDoesNotContainUrlWithNoIndexSet()
Definition: XmlSitemapPagesTest.php:68
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\getResponse
‪array< string, $configurationToUseInTestInstance=array('FE'=>['cacheHash'=>['enforceValidation'=> false,],],);public checkIfPagesSiteMapContainsExpectedEntries( $urlPattern):void { $response=$this-> getResponse()
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesToCheckDataProvider
‪array pagesToCheckDataProvider()
Definition: XmlSitemapPagesTest.php:105
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapInDefaultLanguageDoesNotContainSiteThatIsHiddenInDefaultLanguage
‪pagesSitemapInDefaultLanguageDoesNotContainSiteThatIsHiddenInDefaultLanguage()
Definition: XmlSitemapPagesTest.php:81
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\AbstractXmlSitemapPagesTest
Definition: AbstractXmlSitemapPagesTest.php:25
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapDoesNotContainUntranslatedPages
‪pagesSitemapDoesNotContainUntranslatedPages()
Definition: XmlSitemapPagesTest.php:128
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapContainsTranslatedPages
‪pagesSitemapContainsTranslatedPages()
Definition: XmlSitemapPagesTest.php:117