‪TYPO3CMS  ‪main
ScenarioFTest.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 
50 {
51  protected function ‪setUp(): void
52  {
53  parent::setUp();
54 
56  'acme-com',
57  $this->‪buildSiteConfiguration(1000, 'https://acme.com/'),
58  [
59  $this->‪buildDefaultLanguageConfiguration('EN', 'https://acme.com/en'),
60  $this->‪buildLanguageConfiguration('DE', 'https://acme.com/de'),
61  $this->‪buildLanguageConfiguration('DE-CH', 'https://acme.com/de-ch', ['DE', 'EN']),
62  ]
63  );
64 
65  $this->‪setUpDatabaseWithYamlPayload(__DIR__ . '/Fixtures/ScenarioF.yaml');
66  }
67 
68  public static function ‪resolvablePagesDataProvider(): array
69  {
70  return [
71  'about page in DE where page translation exists' => [
72  'url' => 'https://acme.com/de/ueber-uns',
73  'scopes' => [
74  'page/title' => 'DE: Über uns',
75  ],
76  ],
77  'products page in DE where page translation exists' => [
78  'url' => 'https://acme.com/de/produkte',
79  'scopes' => [
80  'page/title' => 'DE: Produkte',
81  ],
82  ],
83  'products page in DE-CH where page translation exists' => [
84  'url' => 'https://acme.com/de-ch/produkte',
85  'scopes' => [
86  'page/title' => 'DE-CH: Produkte',
87  ],
88  ],
89  ];
90  }
91 
92  #[DataProvider('resolvablePagesDataProvider')]
93  #[Test]
94  public function ‪resolvedPagesMatchScopes(string ‪$url, array $scopes): void
95  {
96  $this->‪assertScopes($url, $scopes);
97  }
98 
99  public static function ‪pageNotFoundDataProvider(): array
100  {
101  return [
102  'home page in EN' => [
103  'url' => 'https://acme.com/en/hello',
104  ],
105  'home page in DE where page translation does not exist' => [
106  'url' => 'https://acme.com/de/hello',
107  ],
108  'home page in DE-CH where page translation does not exist and is trapped by l18n_cfg' => [
109  'url' => 'https://acme.com/de-ch/hello',
110  ],
111  'about page in EN' => [
112  'url' => 'https://acme.com/en/about-us',
113  ],
114  'about page in DE-CH where page translation does not exist and is trapped by l18n_cfg' => [
115  'url' => 'https://acme.com/de-ch/ueber-uns',
116  ],
117  'products page in EN' => [
118  'url' => 'https://acme.com/en/products',
119  ],
120  ];
121  }
122 
123  #[DataProvider('pageNotFoundDataProvider')]
124  #[Test]
125  public function ‪pageNotFound(string ‪$url): void
126  {
127  $this->‪assertResponseStatusCode($url);
128  }
129 
130  public static function ‪menuDataProvider(): array
131  {
132  return [
133  [
134  'url' => 'https://acme.com/de/ueber-uns',
135  'expectedMenu' => [
136  ['title' => 'DE: Willkommen', 'link' => '/de/willkommen'],
137  ['title' => 'DE: Über uns', 'link' => '/de/ueber-uns'],
138  ['title' => 'DE: Produkte', 'link' => '/de/produkte'],
139  ],
140  ],
141  [
142  'url' => 'https://acme.com/de/produkte',
143  'expectedMenu' => [
144  ['title' => 'DE: Willkommen', 'link' => '/de/willkommen'],
145  ['title' => 'DE: Über uns', 'link' => '/de/ueber-uns'],
146  ['title' => 'DE: Produkte', 'link' => '/de/produkte'],
147  ],
148  ],
149  [
150  'url' => 'https://acme.com/de-ch/produkte',
151  'expectedMenu' => [
152  ['title' => 'DE-CH: Produkte', 'link' => '/de-ch/produkte'],
153  // FIXME: Page "EN: Shortcut to welcome" must to be rendered in menu, needs a refactored menu generation
154  ['title' => 'EN: Shortcut to welcome', 'link' => '/de-ch/willkommen'],
155  ],
156  ],
157  ];
158  }
159 
160  #[DataProvider('menuDataProvider')]
161  #[Test]
162  public function ‪pageMenuIsRendered(string ‪$url, array $expectedMenu): void
163  {
164  $this->‪assertMenu($url, $expectedMenu);
165  }
166 }
‪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\ScenarioFTest\pageNotFound
‪pageNotFound(string $url)
Definition: ScenarioFTest.php:125
‪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\ScenarioFTest\resolvablePagesDataProvider
‪static resolvablePagesDataProvider()
Definition: ScenarioFTest.php:68
‪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\ScenarioFTest
Definition: ScenarioFTest.php:50
‪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\ScenarioFTest\setUp
‪setUp()
Definition: ScenarioFTest.php:51
‪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\ScenarioFTest\menuDataProvider
‪static menuDataProvider()
Definition: ScenarioFTest.php:130
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioFTest\resolvedPagesMatchScopes
‪resolvedPagesMatchScopes(string $url, array $scopes)
Definition: ScenarioFTest.php:94
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioFTest\pageNotFoundDataProvider
‪static pageNotFoundDataProvider()
Definition: ScenarioFTest.php:99
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioFTest\pageMenuIsRendered
‪pageMenuIsRendered(string $url, array $expectedMenu)
Definition: ScenarioFTest.php:162