‪TYPO3CMS  11.5
StaticValueMapperTest.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 ‪staticValueMapperDataProvider($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',
45  'aspectName' => 'value',
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/hundred[[pathSuffix]]',
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/enhance/cent[[pathSuffix]]',
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/hundred[[pathSuffix]]',
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/enhance/cent[[pathSuffix]]',
82  ‪Variables::create(['pathSuffix' => ''])
83  )
84  )
85  )
86  ->withApplicableItems($builder->declareEnhancers())
87  ->withApplicableSet(
88  ‪AspectDeclaration::create('StaticValueMapper')->withConfiguration([
89  ‪VariableItem::create('aspectName', [
90  'type' => 'StaticValueMapper',
91  'map' => [
92  'hundred' => 100,
93  ],
94  'localeMap' => [
95  [
96  'locale' => 'fr_FR',
97  'map' => [
98  'cent' => 100,
99  ],
100  ],
101  ],
102  ]),
103  ])
104  )
105  ->permute()
106  ->getTargetsForDataProvider();
107  }
108 
114  public function ‪staticValueMapperIsApplied(‪TestSet $testSet): void
115  {
116  $this->‪assertGeneratedUriEquals($testSet);
117  }
118 
126  {
127  $testSets = [];
128  foreach (‪Builder::create()->declarePageTypes() as $pageTypeDeclaration) {
129  $testSet = ‪TestSet::create()
130  ->withMergedApplicables($pageTypeDeclaration)
131  ->withVariables($pageTypeDeclaration->getVariables());
132  $testSets = array_merge(
133  $testSets,
134  $this->‪staticValueMapperDataProvider($testSet),
135  );
136  }
137  return $testSets;
138  }
139 
145  public function ‪pageTypeDecoratorIsApplied(‪TestSet $testSet): void
146  {
147  parent::pageTypeDecoratorIsApplied($testSet);
148  }
149 }
‪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\EnhancerLinkGenerator\StaticValueMapperTest
Definition: StaticValueMapperTest.php:33
‪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\EnhancerLinkGenerator\StaticValueMapperTest\pageTypeDecoratorIsAppliedDataProvider
‪array pageTypeDecoratorIsAppliedDataProvider()
Definition: StaticValueMapperTest.php:125
‪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\EnhancerLinkGenerator\StaticValueMapperTest\pageTypeDecoratorIsApplied
‪pageTypeDecoratorIsApplied(TestSet $testSet)
Definition: StaticValueMapperTest.php:145
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\AspectDeclaration
Definition: AspectDeclaration.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\StaticValueMapperTest\staticValueMapperDataProvider
‪array staticValueMapperDataProvider($parentSet=null)
Definition: StaticValueMapperTest.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\Framework\Builder\LanguageContext\create
‪static create(int $languageId)
Definition: LanguageContext.php:24
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\StaticValueMapperTest\staticValueMapperIsApplied
‪staticValueMapperIsApplied(TestSet $testSet)
Definition: StaticValueMapperTest.php:114