‪TYPO3CMS  ‪main
ScenarioETest.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 PHPUnit\Framework\Attributes\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
22 
48 {
49  protected function ‪setUp(): void
50  {
51  parent::setUp();
52 
54  'acme-com',
55  $this->‪buildSiteConfiguration(1000, 'https://acme.com/'),
56  [
57  $this->‪buildDefaultLanguageConfiguration('EN', 'https://acme.com/en'),
58  $this->‪buildLanguageConfiguration('DE', 'https://acme.com/de'),
59  $this->‪buildLanguageConfiguration('DE-CH', 'https://acme.com/de-ch', ['DE', 'EN']),
60  ]
61  );
62 
63  $this->‪setUpDatabaseWithYamlPayload(__DIR__ . '/Fixtures/ScenarioE.yaml');
64  }
65 
66  public static function ‪resolvablePagesDataProvider(): array
67  {
68  return [
69  'about page in DE where page translation exists' => [
70  'url' => 'https://acme.com/de/ueber-uns',
71  'scopes' => [
72  'page/title' => 'DE: Über uns',
73  ],
74  ],
75  'about page in DE-CH where page translation does not exist' => [
76  'url' => 'https://acme.com/de-ch/ueber-uns',
77  'scopes' => [
78  'page/title' => 'DE: Über uns',
79  ],
80  ],
81  'about page in DE-CH with EN slug' => [
82  'url' => 'https://acme.com/de-ch/about-us',
83  'scopes' => [
84  'page/title' => 'DE: Über uns',
85  ],
86  ],
87  ];
88  }
89 
90  #[DataProvider('resolvablePagesDataProvider')]
91  #[Test]
92  public function ‪resolvedPagesMatchScopes(string ‪$url, array $scopes): void
93  {
94  $this->‪assertScopes($url, $scopes);
95  }
96 
97  public static function ‪pageNotFoundDataProvider(): array
98  {
99  return [
100  'home page in EN' => [
101  'url' => 'https://acme.com/en/hello',
102  ],
103  'home page in DE where page translation does not exist' => [
104  'url' => 'https://acme.com/de/hello',
105  ],
106  'home page in DE-CH where page translation does not exist and is trapped by l18n_cfg' => [
107  'url' => 'https://acme.com/de-ch/hello',
108  ],
109  'about page in EN' => [
110  'url' => 'https://acme.com/en/about-us',
111  ],
112  'about page in DE with EN slug' => [
113  'url' => 'https://acme.com/de/about-us',
114  ],
115  ];
116  }
117 
118  #[DataProvider('pageNotFoundDataProvider')]
119  #[Test]
120  public function ‪pageNotFound(string ‪$url): void
121  {
122  $this->‪assertResponseStatusCode($url);
123  }
124 
125  public static function ‪menuDataProvider(): array
126  {
127  return [
128  [
129  'url' => 'https://acme.com/de/ueber-uns',
130  'expectedMenu' => [
131  ['title' => 'DE: Über uns', 'link' => '/de/ueber-uns'],
132  ['title' => 'DE: Produkte', 'link' => '/de/produkte'],
133  ],
134  ],
135  [
136  'url' => 'https://acme.com/de-ch/ueber-uns',
137  'expectedMenu' => [
138  ['title' => 'DE: Über uns', 'link' => '/de-ch/ueber-uns'],
139  ['title' => 'DE: Produkte', 'link' => '/de-ch/produkte'],
140  ['title' => 'EN: Shortcut to welcome', 'link' => '/de-ch/hello'],
141  ],
142  ],
143  [
144  'url' => 'https://acme.com/de-ch/about-us',
145  'expectedMenu' => [
146  ['title' => 'DE: Über uns', 'link' => '/de-ch/ueber-uns'],
147  ['title' => 'DE: Produkte', 'link' => '/de-ch/produkte'],
148  ['title' => 'EN: Shortcut to welcome', 'link' => '/de-ch/hello'],
149  ],
150  ],
151  ];
152  }
153 
154  #[DataProvider('menuDataProvider')]
155  #[Test]
156  public function ‪pageMenuIsRendered(string ‪$url, array $expectedMenu): void
157  {
158  $this->‪assertMenu($url, $expectedMenu);
159  }
160 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioETest\setUp
‪setUp()
Definition: ScenarioETest.php:49
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioETest\pageMenuIsRendered
‪pageMenuIsRendered(string $url, array $expectedMenu)
Definition: ScenarioETest.php:156
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildLanguageConfiguration
‪buildLanguageConfiguration(string $identifier, string $base, array $fallbackIdentifiers=[], string $fallbackType=null)
Definition: SiteBasedTestTrait.php:108
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\AbstractLocalizedPagesTestCase\assertScopes
‪assertScopes(string $url, array $scopes)
Definition: AbstractLocalizedPagesTestCase.php:48
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioETest\resolvablePagesDataProvider
‪static resolvablePagesDataProvider()
Definition: ScenarioETest.php:66
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\AbstractLocalizedPagesTestCase\assertResponseStatusCode
‪assertResponseStatusCode(string $url)
Definition: AbstractLocalizedPagesTestCase.php:66
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:50
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering
Definition: AbstractLocalizedPagesTestCase.php:18
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\AbstractLocalizedPagesTestCase
Definition: AbstractLocalizedPagesTestCase.php:28
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:88
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioETest\pageNotFound
‪pageNotFound(string $url)
Definition: ScenarioETest.php:120
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioETest\menuDataProvider
‪static menuDataProvider()
Definition: ScenarioETest.php:125
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioETest\resolvedPagesMatchScopes
‪resolvedPagesMatchScopes(string $url, array $scopes)
Definition: ScenarioETest.php:92
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\AbstractLocalizedPagesTestCase\assertMenu
‪assertMenu(string $url, array $expectation)
Definition: AbstractLocalizedPagesTestCase.php:77
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\AbstractLocalizedPagesTestCase\setUpDatabaseWithYamlPayload
‪setUpDatabaseWithYamlPayload(string $pathToYamlFile)
Definition: AbstractLocalizedPagesTestCase.php:35
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:98
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioETest
Definition: ScenarioETest.php:48
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioETest\pageNotFoundDataProvider
‪static pageNotFoundDataProvider()
Definition: ScenarioETest.php:97