‪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  'resolveValue' => 100,
45  'routePrefix' => 'enhance',
46  'aspectName' => 'value',
47  'inArguments' => 'staticArguments', // either 'dynamicArguments' or 'staticArguments'
48  ]);
49  return ‪Permutation::create($variables)
50  ->withTargets(
51  ‪TestSet::create($parentSet)
52  ->withMergedApplicables(‪LanguageContext::create(0))
53  ->withTargetPageId(1100)
54  ->withUrl(
56  'https://acme.us/welcome/enhance/hundred[[pathSuffix]]',
57  ‪Variables::create(['pathSuffix' => ''])
58  )
59  ),
60  ‪TestSet::create($parentSet)
61  ->withMergedApplicables(‪LanguageContext::create(1))
62  ->withTargetPageId(1100)
63  ->withUrl(
65  'https://acme.fr/bienvenue/enhance/cent[[pathSuffix]]',
66  ‪Variables::create(['pathSuffix' => ''])
67  )
68  )
69  )
70  ->withApplicableItems($builder->declareEnhancers())
71  ->withApplicableSet(
72  ‪AspectDeclaration::create('StaticValueMapper')->withConfiguration([
73  ‪VariableItem::create('aspectName', [
74  'type' => 'StaticValueMapper',
75  'map' => [
76  'hundred' => 100,
77  ],
78  'localeMap' => [
79  [
80  'locale' => 'fr_FR',
81  'map' => [
82  'cent' => 100,
83  ],
84  ],
85  ],
86  ]),
87  ])
88  )
89  ->permute()
90  ->getTargetsForDataProvider();
91  }
92 
98  public function ‪staticValueMapperIsApplied(‪TestSet $testSet): void
99  {
100  $this->‪assertPageArgumentsEquals($testSet);
101  }
102 
107  {
108  $testSets = [];
109  foreach (‪Builder::create()->declarePageTypes() as $pageTypeDeclaration) {
110  $testSet = ‪TestSet::create()
111  ->withMergedApplicables($pageTypeDeclaration)
112  ->withVariables($pageTypeDeclaration->getVariables());
113  $testSets = array_merge(
114  $testSets,
115  $this->‪staticValueMapperDataProvider($testSet),
116  );
117  }
118  return $testSets;
119  }
120 
126  public function ‪pageTypeDecoratorIsApplied(‪TestSet $testSet): void
127  {
128  parent::pageTypeDecoratorIsApplied($testSet);
129  }
130 }
‪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\EnhancerSiteRequest\StaticValueMapperTest\pageTypeDecoratorIsAppliedDataProvider
‪array pageTypeDecoratorIsAppliedDataProvider()
Definition: StaticValueMapperTest.php:106
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Variables
Definition: Variables.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\StaticValueMapperTest\staticValueMapperIsApplied
‪staticValueMapperIsApplied(TestSet $testSet)
Definition: StaticValueMapperTest.php:98
‪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\Framework\Builder\Variables\create
‪static create(array $items=[])
Definition: Variables.php:22
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\StaticValueMapperTest\staticValueMapperDataProvider
‪array staticValueMapperDataProvider($parentSet=null)
Definition: StaticValueMapperTest.php:38
‪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\EnhancerSiteRequest\StaticValueMapperTest\pageTypeDecoratorIsApplied
‪pageTypeDecoratorIsApplied(TestSet $testSet)
Definition: StaticValueMapperTest.php:126
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\AspectDeclaration
Definition: AspectDeclaration.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\VariableItem
Definition: VariableItem.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\StaticValueMapperTest
Definition: StaticValueMapperTest.php:33
‪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