‪TYPO3CMS  ‪main
SitemapXmlCest.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 Codeception\Attribute\DataProvider;
21 use Codeception\Example;
22 use Facebook\WebDriver\Remote\RemoteWebDriver;
23 use Facebook\WebDriver\Remote\RemoteWebElement;
24 use Facebook\WebDriver\WebDriverBy;
27 
28 final class ‪SitemapXmlCest
29 {
30  public function ‪_before(‪ApplicationTester $I, ‪PageTree $pageTree)
31  {
32  $I->useExistingSession('admin');
33  $I->click('Page');
34  $pageTree->‪openPath(['styleguide frontend demo']);
35  $I->switchToContentFrame();
36  $I->waitForElementVisible('.module-docheader-bar-column-left a:first-child');
37  $I->wait(1);
38  $I->waitForElementNotVisible('#nprogress', 120);
39  $dataDispatchArgs = $I->grabAttributeFrom('.module-docheader-bar-column-left a:first-child', 'data-dispatch-args');
40  ‪$url = json_decode($dataDispatchArgs, false, 512, JSON_THROW_ON_ERROR);
41  // Add Sitemap parameter to URL
42  $I->amOnPage(str_replace('/typo3temp/var/tests/acceptance', '', ‪$url[0]) . '?type=1533906435');
43  }
44 
45  private function ‪sitemapDataProvider(): array
46  {
47  return [
48  ['slug' => '/bullets'],
49  ['slug' => '/div'],
50  ['slug' => '/header'],
51  ['slug' => '/text'],
52  ['slug' => '/textpic'],
53  ['slug' => '/textmedia'],
54  ['slug' => '/image'],
55  ['slug' => '/html'],
56  ['slug' => '/table'],
57  ['slug' => '/felogin-login'],
58  ['slug' => '/form-formframework'],
59  ['slug' => '/indexedsearch-pi2'],
60  ['slug' => '/shortcut'],
61  ['slug' => '/uploads'],
62  ['slug' => '/menu-categorized-pages'],
63  ['slug' => '/menu-categorized-content'],
64  ['slug' => '/menu-pages'],
65  ['slug' => '/menu-subpages'],
66  ['slug' => '/menu-sitemap'],
67  ['slug' => '/menu-section'],
68  ['slug' => '/menu-abstract'],
69  ['slug' => '/menu-recently-updated'],
70  ['slug' => '/menu-related-pages'],
71  ['slug' => '/menu-section-pages'],
72  ['slug' => '/menu-sitemap-pages'],
73  ];
74  }
75 
76  #[DataProvider('sitemapDataProvider')]
77  public function ‪seeSitemapXml(‪ApplicationTester $I, Example $testData): void
78  {
79  $I->see('TYPO3 XML Sitemap');
80  $I->see('sitemap=pages');
81  $I->see('type=1533906435');
82 
83  $I->amGoingTo('See sitemap pages details');
84  $I->click('a');
85 
86  $I->see($testData['slug']);
87  $priority = $this->‪getTableColumn($I, $testData['slug'])->getText();
88  $I->assertIsNumeric($priority);
89  }
90 
94  private function ‪getTableColumn(‪ApplicationTester $I, string $slug, int $sibling = 3): RemoteWebElement
95  {
96  $I->comment('Get context for table row "' . $slug . '"');
97  return $I->executeInSelenium(
98  function (RemoteWebDriver $webDriver) use ($slug, $sibling) {
99  return $webDriver->findElement(
100  WebDriverBy::xpath(
101  '//a[contains(text(),"' . $slug . '")]/ancestor::td/following-sibling::td[' . $sibling . ']'
102  )
103  );
104  }
105  );
106  }
107 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\sitemapDataProvider
‪sitemapDataProvider()
Definition: SitemapXmlCest.php:45
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend
Definition: ContentElementsCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\AbstractTree\openPath
‪openPath(array $path)
Definition: AbstractTree.php:55
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest
Definition: SitemapXmlCest.php:29
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\seeSitemapXml
‪seeSitemapXml(ApplicationTester $I, Example $testData)
Definition: SitemapXmlCest.php:77
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\_before
‪_before(ApplicationTester $I, PageTree $pageTree)
Definition: SitemapXmlCest.php:30
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\getTableColumn
‪getTableColumn(ApplicationTester $I, string $slug, int $sibling=3)
Definition: SitemapXmlCest.php:94
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:26