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