‪TYPO3CMS  ‪main
ScenarioBTest.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 
44 {
45  protected function ‪setUp(): void
46  {
47  parent::setUp();
48 
50  'acme-com',
51  $this->‪buildSiteConfiguration(1000, 'https://acme.com/'),
52  [
53  $this->‪buildDefaultLanguageConfiguration('EN', 'https://acme.com/en'),
54  $this->‪buildLanguageConfiguration('DE', 'https://acme.com/de'),
55  $this->‪buildLanguageConfiguration('DE-CH', 'https://acme.com/de-ch', ['DE', 'EN']),
56  ]
57  );
58 
59  $this->‪setUpDatabaseWithYamlPayload(__DIR__ . '/Fixtures/ScenarioB.yaml');
60  }
61 
62  public static function ‪resolvablePagesDataProvider(): array
63  {
64  return [
65  'home page in EN' => [
66  'url' => 'https://acme.com/en/hello',
67  'scopes' => [
68  'page/title' => 'EN: Welcome',
69  ],
70  ],
71  'home page in DE-CH where page translation does not exist' => [
72  'url' => 'https://acme.com/de-ch/hello',
73  'scopes' => [
74  'page/title' => 'EN: Welcome',
75  ],
76  ],
77  'headquarter sub page in EN' => [
78  'url' => 'https://acme.com/en/about-us/headquarter',
79  'scopes' => [
80  'page/title' => 'EN: Headquarter',
81  ],
82  ],
83  'headquarter sub page in DE-CH where page translation does not exist' => [
84  'url' => 'https://acme.com/de-ch/about-us/headquarter',
85  'scopes' => [
86  'page/title' => 'EN: Headquarter',
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 DE where page translation does not exist and has no fallback configured' => [
103  'url' => 'https://acme.com/de/hello',
104  ],
105  ];
106  }
107 
108  #[DataProvider('pageNotFoundDataProvider')]
109  #[Test]
110  public function ‪pageNotFound(string ‪$url): void
111  {
112  $this->‪assertResponseStatusCode($url);
113  }
114 
115  public static function ‪menuDataProvider(): array
116  {
117  return [
118  [
119  'url' => 'https://acme.com/en/hello',
120  'expectedMenu' => [
121  ['title' => 'EN: Welcome', 'link' => '/en/hello'],
122  ['title' => 'EN: About us', 'link' => '/en/about-us'],
123  ],
124  ],
125  [
126  'url' => 'https://acme.com/de-ch/hello',
127  'expectedMenu' => [
128  ['title' => 'EN: Welcome', 'link' => '/de-ch/hello'],
129  ['title' => 'DE-CH: Über uns', 'link' => '/de-ch/about-us'],
130  ],
131  ],
132  ];
133  }
134 
135  #[DataProvider('menuDataProvider')]
136  #[Test]
137  public function ‪pageMenuIsRendered(string ‪$url, array $expectedMenu): void
138  {
139  $this->‪assertMenu($url, $expectedMenu);
140  }
141 }
‪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\ScenarioBTest\menuDataProvider
‪static menuDataProvider()
Definition: ScenarioBTest.php:115
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\AbstractLocalizedPagesTestCase\assertResponseStatusCode
‪assertResponseStatusCode(string $url)
Definition: AbstractLocalizedPagesTestCase.php:66
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioBTest\resolvedPagesMatchScopes
‪resolvedPagesMatchScopes(string $url, array $scopes)
Definition: ScenarioBTest.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\ScenarioBTest\pageMenuIsRendered
‪pageMenuIsRendered(string $url, array $expectedMenu)
Definition: ScenarioBTest.php:137
‪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\ScenarioBTest\setUp
‪setUp()
Definition: ScenarioBTest.php:45
‪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\ScenarioBTest\pageNotFoundDataProvider
‪static pageNotFoundDataProvider()
Definition: ScenarioBTest.php:99
‪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\ScenarioBTest\pageNotFound
‪pageNotFound(string $url)
Definition: ScenarioBTest.php:110
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:98
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioBTest
Definition: ScenarioBTest.php:44
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering\ScenarioBTest\resolvablePagesDataProvider
‪static resolvablePagesDataProvider()
Definition: ScenarioBTest.php:62