‪TYPO3CMS  11.5
LocaleModifierTest.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 
28 
33 {
38  public function ‪localeModifierDataProvider($parentSet = null): array
39  {
40  $builder = ‪Builder::create();
41  // variables (applied when invoking expectations)
42  $variables = ‪Variables::create()->define([
43  'value' => 100,
44  'routePrefix' => '{enhance_name}',
45  'aspectName' => 'enhance_name',
46  ]);
47  return ‪Permutation::create($variables)
48  ->withTargets(
49  ‪TestSet::create($parentSet)
50  ->withMergedApplicables(‪LanguageContext::create(0))
51  ->withTargetPageId(1100)
52  ->withUrl(
54  'https://acme.us/welcome/enhance/[[value]][[pathSuffix]]?cHash=',
55  ‪Variables::create(['pathSuffix' => ''])
56  )
57  ),
58  ‪TestSet::create($parentSet)
59  ->withMergedApplicables(‪LanguageContext::create(1))
60  ->withTargetPageId(1100)
61  ->withUrl(
63  'https://acme.fr/bienvenue/augmenter/[[value]][[pathSuffix]]?cHash=',
64  ‪Variables::create(['pathSuffix' => ''])
65  )
66  ),
67  ‪TestSet::create($parentSet)
68  ->withMergedApplicables(‪LanguageContext::create(0))
69  ->withTargetPageId(3000)
70  ->withUrl(
72  'https://archive.acme.com/enhance/[[value]][[pathSuffix]]?cHash=',
73  ‪Variables::create(['pathSuffix' => ''])
74  )
75  ),
76  ‪TestSet::create($parentSet)
77  ->withMergedApplicables(‪LanguageContext::create(1))
78  ->withTargetPageId(3000)
79  ->withUrl(
81  'https://archive.acme.com/fr/augmenter/[[value]][[pathSuffix]]?cHash=',
82  ‪Variables::create(['pathSuffix' => ''])
83  )
84  )
85  )
86  ->withApplicableItems($builder->declareEnhancers())
87  ->withApplicableSet(
88  ‪AspectDeclaration::create('LocaleModifier')->withConfiguration([
89  ‪VariableItem::create('aspectName', [
90  'type' => 'LocaleModifier',
91  'default' => 'enhance',
92  'localeMap' => [
93  [
94  'locale' => 'fr_FR',
95  'value' => 'augmenter',
96  ],
97  ],
98  ]),
99  ])
100  )
101  ->permute()
102  ->getTargetsForDataProvider();
103  }
104 
110  public function ‪localeModifierIsApplied(‪TestSet $testSet): void
111  {
112  $this->‪assertGeneratedUriEquals($testSet, false);
113  }
114 
122  {
123  $testSets = [];
124  foreach (‪Builder::create()->declarePageTypes() as $pageTypeDeclaration) {
125  $testSet = ‪TestSet::create()
126  ->withMergedApplicables($pageTypeDeclaration)
127  ->withVariables($pageTypeDeclaration->getVariables());
128  $testSets = array_merge(
129  $testSets,
130  $this->‪localeModifierDataProvider($testSet),
131  );
132  }
133  return $testSets;
134  }
135 
141  public function ‪pageTypeDecoratorIsApplied(‪TestSet $testSet): void
142  {
143  parent::pageTypeDecoratorIsApplied($testSet);
144  }
145 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\LocaleModifierTest\localeModifierIsApplied
‪localeModifierIsApplied(TestSet $testSet)
Definition: LocaleModifierTest.php:110
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\LocaleModifierTest\pageTypeDecoratorIsAppliedDataProvider
‪array pageTypeDecoratorIsAppliedDataProvider()
Definition: LocaleModifierTest.php:121
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\AbstractEnhancerLinkGeneratorTestCase\assertGeneratedUriEquals
‪assertGeneratedUriEquals(TestSet $testSet, bool $strict=true)
Definition: AbstractEnhancerLinkGeneratorTestCase.php:139
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Permutation
Definition: Permutation.php:23
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableItem\create
‪static create(string $key, $value)
Definition: VariableItem.php:31
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\AbstractEnhancerLinkGeneratorTestCase
Definition: AbstractEnhancerLinkGeneratorTestCase.php:33
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\AspectDeclaration\create
‪static create(string $identifier)
Definition: AspectDeclaration.php:25
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Variables
Definition: Variables.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Permutation\create
‪static create(Variables $variables)
Definition: Permutation.php:44
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\TestSet
Definition: TestSet.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Builder
Definition: Builder.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Builder\create
‪static create()
Definition: Builder.php:22
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableValue\create
‪static create(string $value, Variables $defaultVariables=null)
Definition: VariableValue.php:43
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\LocaleModifierTest\pageTypeDecoratorIsApplied
‪pageTypeDecoratorIsApplied(TestSet $testSet)
Definition: LocaleModifierTest.php:141
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Variables\create
‪static create(array $items=[])
Definition: Variables.php:22
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\AspectDeclaration
Definition: AspectDeclaration.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\LocaleModifierTest\localeModifierDataProvider
‪array localeModifierDataProvider($parentSet=null)
Definition: LocaleModifierTest.php:38
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableItem
Definition: VariableItem.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\LanguageContext
Definition: LanguageContext.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableValue
Definition: VariableValue.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\TestSet\create
‪static create($parentSet=null)
Definition: TestSet.php:42
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\LocaleModifierTest
Definition: LocaleModifierTest.php:33
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\LanguageContext\create
‪static create(int $languageId)
Definition: LanguageContext.php:24