‪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 
29 
34 {
39  public function ‪localeModifierDataProvider($parentSet = null): array
40  {
41  $builder = ‪Builder::create();
42  // variables (applied when invoking expectations)
43  $variables = ‪Variables::create()->define([
44  'value' => 100,
45  'resolveValue' => 100,
46  'routePrefix' => '{enhance_name}',
47  'aspectName' => 'enhance_name',
48  'inArguments' => 'dynamicArguments', // either 'dynamicArguments' or 'staticArguments'
49  ]);
50  $enhancers = $builder->declareEnhancers();
51  $variableContexts = [
54  'cHash' => '46227b4ce096dc78a4e71463326c9020',
55  'cHash2' => 'f80d112e877175ce8e7d54c35bebe12c',
56  ])
57  )->withRequiredApplicables($enhancers['Simple']),
60  'cHash' => 'e24d3d2d5503baba670d827c3b9470c8',
61  'cHash2' => '54f45ea94a5e812fbae944792dac940d',
62  ])
63  )->withRequiredApplicables($enhancers['Plugin']),
66  'cHash' => 'eef21771ab3c3dac3514b4479eedd5ff',
67  'cHash2' => 'c822555d4ebd106b0d1687e43a4db9c9',
68  ])
69  )->withRequiredApplicables($enhancers['Extbase']),
70  ];
71  return ‪Permutation::create($variables)
72  ->withTargets(
73  ‪TestSet::create($parentSet)
74  ->withMergedApplicables(‪LanguageContext::create(0))
75  ->withTargetPageId(1100)
76  ->withUrl(
78  'https://acme.us/welcome/enhance/[[value]][[pathSuffix]]?cHash=[[cHash]]',
79  ‪Variables::create(['pathSuffix' => ''])
80  )
81  ),
82  ‪TestSet::create($parentSet)
83  ->withMergedApplicables(‪LanguageContext::create(1))
84  ->withTargetPageId(1100)
85  ->withUrl(
87  'https://acme.fr/bienvenue/augmenter/[[value]][[pathSuffix]]?cHash=[[cHash]]',
88  ‪Variables::create(['pathSuffix' => ''])
89  )
90  ),
91  ‪TestSet::create($parentSet)
92  ->withMergedApplicables(‪LanguageContext::create(0))
93  ->withTargetPageId(3000)
94  ->withUrl(
96  'https://archive.acme.com/enhance/[[value]][[pathSuffix]]?cHash=[[cHash2]]',
97  ‪Variables::create(['pathSuffix' => ''])
98  )
99  ),
100  ‪TestSet::create($parentSet)
101  ->withMergedApplicables(‪LanguageContext::create(1))
102  ->withTargetPageId(3000)
103  ->withUrl(
105  'https://archive.acme.com/fr/augmenter/[[value]][[pathSuffix]]?cHash=[[cHash2]]',
106  ‪Variables::create(['pathSuffix' => ''])
107  )
108  )
109  )
110  ->withApplicableItems($variableContexts)
111  ->withApplicableItems($enhancers)
112  ->withApplicableSet(
113  ‪AspectDeclaration::create('LocaleModifier')->withConfiguration([
114  ‪VariableItem::create('aspectName', [
115  'type' => 'LocaleModifier',
116  'default' => 'enhance',
117  'localeMap' => [
118  [
119  'locale' => 'fr_FR',
120  'value' => 'augmenter',
121  ],
122  ],
123  ]),
124  ])
125  )
126  ->permute()
127  ->getTargetsForDataProvider();
128  }
129 
135  public function ‪localeModifierIsApplied(‪TestSet $testSet): void
136  {
137  $this->‪assertPageArgumentsEquals($testSet);
138  }
139 
144  {
145  $testSets = [];
146  foreach (‪Builder::create()->declarePageTypes() as $pageTypeDeclaration) {
147  $testSet = ‪TestSet::create()
148  ->withMergedApplicables($pageTypeDeclaration)
149  ->withVariables($pageTypeDeclaration->getVariables());
150  $testSets = array_merge(
151  $testSets,
152  $this->‪localeModifierDataProvider($testSet),
153  );
154  }
155  return $testSets;
156  }
157 
163  public function ‪pageTypeDecoratorIsApplied(‪TestSet $testSet): void
164  {
165  parent::pageTypeDecoratorIsApplied($testSet);
166  }
167 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest
Definition: AbstractEnhancerSiteRequestTest.php:18
‪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\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\VariablesContext\create
‪static create(Variables $variables)
Definition: VariablesContext.php:29
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariablesContext
Definition: VariablesContext.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\EnhancerSiteRequest\LocaleModifierTest\localeModifierIsApplied
‪localeModifierIsApplied(TestSet $testSet)
Definition: LocaleModifierTest.php:135
‪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\Framework\Builder\Variables\create
‪static create(array $items=[])
Definition: Variables.php:22
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\LocaleModifierTest\pageTypeDecoratorIsAppliedDataProvider
‪array pageTypeDecoratorIsAppliedDataProvider()
Definition: LocaleModifierTest.php:143
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\AbstractEnhancerSiteRequestTest
Definition: AbstractEnhancerSiteRequestTest.php:34
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\AbstractEnhancerSiteRequestTest\assertPageArgumentsEquals
‪assertPageArgumentsEquals(TestSet $testSet)
Definition: AbstractEnhancerSiteRequestTest.php:147
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\AspectDeclaration
Definition: AspectDeclaration.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\LocaleModifierTest\pageTypeDecoratorIsApplied
‪pageTypeDecoratorIsApplied(TestSet $testSet)
Definition: LocaleModifierTest.php:163
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableItem
Definition: VariableItem.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\LocaleModifierTest\localeModifierDataProvider
‪array localeModifierDataProvider($parentSet=null)
Definition: LocaleModifierTest.php:39
‪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\EnhancerSiteRequest\LocaleModifierTest
Definition: LocaleModifierTest.php:34
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\LanguageContext\create
‪static create(int $languageId)
Definition: LanguageContext.php:24