‪TYPO3CMS  ‪main
ScenarioATest.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/ScenarioA.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 where page translation exists' => [
73  'url' => 'https://acme.com/de/willkommen',
74  'scopes' => [
75  'page/title' => 'DE: Willkommen',
76  ],
77  ],
78  'home page in DE-CH where page translation does not exist' => [
79  'url' => 'https://acme.com/de-ch/willkommen',
80  'scopes' => [
81  'page/title' => 'DE: Willkommen',
82  ],
83  ],
84  ];
85  }
86 
87  #[DataProvider('resolvablePagesDataProvider')]
88  #[Test]
89  public function ‪resolvedPagesMatchScopes(string ‪$url, array $scopes): void
90  {
91  $this->‪assertScopes($url, $scopes);
92  }
93 
94  public static function ‪menuDataProvider(): array
95  {
96  return [
97  [
98  'url' => 'https://acme.com/en/hello',
99  'expectedMenu' => [
100  ['title' => 'EN: Welcome', 'link' => '/en/hello'],
101  ],
102  ],
103  [
104  'url' => 'https://acme.com/de/willkommen',
105  'expectedMenu' => [
106  ['title' => 'DE: Willkommen', 'link' => '/de/willkommen'],
107  ],
108  ],
109  [
110  'url' => 'https://acme.com/de-ch/willkommen',
111  'expectedMenu' => [
112  ['title' => 'DE: Willkommen', 'link' => '/de-ch/willkommen'],
113  ],
114  ],
115  ];
116  }
117 
118  #[DataProvider('menuDataProvider')]
119  #[Test]
120  public function ‪pageMenuIsRendered(string ‪$url, array $expectedMenu): void
121  {
122  $this->‪assertMenu($url, $expectedMenu);
123  }
124 }
‪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\ScenarioATest\setUp
‪setUp()
Definition: ScenarioATest.php:46
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioATest\menuDataProvider
‪static menuDataProvider()
Definition: ScenarioATest.php:94
‪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\ScenarioATest\resolvedPagesMatchScopes
‪resolvedPagesMatchScopes(string $url, array $scopes)
Definition: ScenarioATest.php:89
‪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\ScenarioATest\resolvablePagesDataProvider
‪static resolvablePagesDataProvider()
Definition: ScenarioATest.php:63
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioATest\pageMenuIsRendered
‪pageMenuIsRendered(string $url, array $expectedMenu)
Definition: ScenarioATest.php:120
‪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\ScenarioATest
Definition: ScenarioATest.php:45