‪TYPO3CMS  9.5
XmlSitemapPagesTest.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 
23 {
24 
30  public function ‪checkIfPagesSiteMapContainsExpectedEntries($urlPattern): void
31  {
32  $response = $this->‪getResponse();
33  $this->assertEquals(200, $response->getStatusCode());
34  $this->assertArrayHasKey('Content-Length', $response->getHeaders());
35  $this->assertGreaterThan(0, $response->getHeader('Content-Length')[0]);
36  $this->assertArrayHasKey('Content-Type', $response->getHeaders());
37  $this->assertEquals('application/xml;charset=utf-8', $response->getHeader('Content-Type')[0]);
38  $this->assertArrayHasKey('X-Robots-Tag', $response->getHeaders());
39  $this->assertEquals('noindex', $response->getHeader('X-Robots-Tag')[0]);
40 
41  $this->assertRegExp($urlPattern, (string)$response->getBody());
42  }
43 
48  {
49  self::assertStringNotContainsString(
50  '<loc>http://localhost/canonicalized-page</loc>',
51  (string)$this->‪getResponse()->getBody()
52  );
53  }
54 
59  {
60  self::assertStringNotContainsString(
61  '<loc>http://localhost/no-index</loc>',
62  (string)$this->‪getResponse()->getBody()
63  );
64  }
65 
72  {
73  self::assertStringNotContainsString(
74  '<loc>http://localhost/hidden-in-default</loc>',
75  (string)$this->‪getResponse()->getBody()
76  );
77  }
78 
85  {
86  self::assertStringNotContainsString(
87  '<loc>http://localhost/de/dummy-1-2-5-fr</loc>',
88  (string)$this->‪getResponse('http://localhost/de/')->getBody()
89  );
90  }
91 
95  public function ‪pagesToCheckDataProvider(): array //18-03-2019 21:24:07
96  {
97  // This is just a part of the entries that will be checked in v10
98  return [
99  'complete-entry' => ['#<url>\s+<loc>http://localhost/complete\-entry</loc>\s+<lastmod>\d+-\d+-\d+T\d+:\d+:\d+\+\d+:\d+</lastmod>\s+</url>#'],
100  ];
101  }
102 
107  {
108  self::assertEquals(
109  4,
110  (new \SimpleXMLElement((string)$this->‪getResponse('http://localhost/fr/')->getBody()))->count()
111  );
112  }
113 
118  {
119  $this->assertStringNotContainsString(
120  '<loc>http://localhost/dummy-1-4</loc>',
121  (string)$this->‪getResponse('http://localhost/fr/')->getBody()
122  );
123  }
124 
129  {
130  self::assertStringContainsString(
131  '<loc>http://localhost/de/dummy-1-3-fr</loc>',
132  (string)$this->‪getResponse('http://localhost/de/')->getBody()
133  );
134  }
135 }
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\AbstractXmlSitemapPagesTest\getResponse
‪getResponse(string $uri='http://localhost/')
Definition: AbstractXmlSitemapPagesTest.php:63
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapRespectFallbackStrategy
‪pagesSitemapRespectFallbackStrategy()
Definition: XmlSitemapPagesTest.php:128
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap
Definition: AbstractXmlSitemapPagesTest.php:4
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest
Definition: XmlSitemapPagesTest.php:23
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapInAlternativeLanguageDoesNotContainSiteThatIsHiddenIfNotTranslated
‪pagesSitemapInAlternativeLanguageDoesNotContainSiteThatIsHiddenIfNotTranslated()
Definition: XmlSitemapPagesTest.php:84
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapDoesNotContainUrlWithCanonicalSet
‪pagesSitemapDoesNotContainUrlWithCanonicalSet()
Definition: XmlSitemapPagesTest.php:47
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapDoesNotContainUrlWithNoIndexSet
‪pagesSitemapDoesNotContainUrlWithNoIndexSet()
Definition: XmlSitemapPagesTest.php:58
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesToCheckDataProvider
‪array pagesToCheckDataProvider()
Definition: XmlSitemapPagesTest.php:95
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapInDefaultLanguageDoesNotContainSiteThatIsHiddenInDefaultLanguage
‪pagesSitemapInDefaultLanguageDoesNotContainSiteThatIsHiddenInDefaultLanguage()
Definition: XmlSitemapPagesTest.php:71
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\AbstractXmlSitemapPagesTest
Definition: AbstractXmlSitemapPagesTest.php:24
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\checkIfPagesSiteMapContainsExpectedEntries
‪checkIfPagesSiteMapContainsExpectedEntries($urlPattern)
Definition: XmlSitemapPagesTest.php:30
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapDoesNotContainUntranslatedPages
‪pagesSitemapDoesNotContainUntranslatedPages()
Definition: XmlSitemapPagesTest.php:117
‪TYPO3\CMS\Seo\Tests\Functional\XmlSitemap\XmlSitemapPagesTest\pagesSitemapContainsTranslatedPages
‪pagesSitemapContainsTranslatedPages()
Definition: XmlSitemapPagesTest.php:106