‪TYPO3CMS  11.5
StaticRangeMapperTest.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 ‪staticRangeMapperDataProvider($parentSet = null): array
40  {
41  $variableContexts = array_map(
42  static function ($value) {
45  'value' => $value,
46  'resolveValue' => $value,
47  ])
48  );
49  },
50  range(10, 100, 30)
51  );
52 
53  $builder = ‪Builder::create();
54  // variables (applied when invoking expectations)
55  $variables = ‪Variables::create()->define([
56  'routePrefix' => 'enhance',
57  'aspectName' => 'value',
58  'inArguments' => 'staticArguments', // either 'dynamicArguments' or 'staticArguments'
59  ]);
60  return ‪Permutation::create($variables)
61  ->withTargets(
62  ‪TestSet::create($parentSet)
63  ->withMergedApplicables(‪LanguageContext::create(0))
64  ->withTargetPageId(1100)
65  ->withUrl(
67  'https://acme.us/welcome/enhance/[[value]][[pathSuffix]]',
68  ‪Variables::create(['pathSuffix' => ''])
69  )
70  ),
71  ‪TestSet::create($parentSet)
72  ->withMergedApplicables(‪LanguageContext::create(1))
73  ->withTargetPageId(1100)
74  ->withUrl(
76  'https://acme.fr/bienvenue/enhance/[[value]][[pathSuffix]]',
77  ‪Variables::create(['pathSuffix' => ''])
78  )
79  )
80  )
81  ->withApplicableItems($variableContexts)
82  ->withApplicableItems($builder->declareEnhancers())
83  ->withApplicableSet(
84  ‪AspectDeclaration::create('StaticRangeMapper')->withConfiguration([
85  ‪VariableItem::create('aspectName', [
86  'type' => 'StaticRangeMapper',
87  'start' => '1',
88  'end' => '100',
89  ]),
90  ])
91  )
92  ->permute()
93  ->getTargetsForDataProvider();
94  }
95 
101  public function ‪staticRangeMapperIsApplied(‪TestSet $testSet): void
102  {
103  $this->‪assertPageArgumentsEquals($testSet);
104  }
105 
110  {
111  $testSets = [];
112  foreach (‪Builder::create()->declarePageTypes() as $pageTypeDeclaration) {
113  $testSet = ‪TestSet::create()
114  ->withMergedApplicables($pageTypeDeclaration)
115  ->withVariables($pageTypeDeclaration->getVariables());
116  $testSets = array_merge(
117  $testSets,
118  $this->‪staticRangeMapperDataProvider($testSet)
119  );
120  }
121  return $testSets;
122  }
123 
129  public function ‪pageTypeDecoratorIsApplied(‪TestSet $testSet): void
130  {
131  parent::pageTypeDecoratorIsApplied($testSet);
132  }
133 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest
Definition: AbstractEnhancerSiteRequestTest.php:18
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\StaticRangeMapperTest\pageTypeDecoratorIsAppliedDataProvider
‪array pageTypeDecoratorIsAppliedDataProvider()
Definition: StaticRangeMapperTest.php:109
‪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\EnhancerSiteRequest\StaticRangeMapperTest\staticRangeMapperIsApplied
‪staticRangeMapperIsApplied(TestSet $testSet)
Definition: StaticRangeMapperTest.php:101
‪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\StaticRangeMapperTest
Definition: StaticRangeMapperTest.php:34
‪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\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\StaticRangeMapperTest\pageTypeDecoratorIsApplied
‪pageTypeDecoratorIsApplied(TestSet $testSet)
Definition: StaticRangeMapperTest.php:129
‪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\Framework\Builder\LanguageContext
Definition: LanguageContext.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest\StaticRangeMapperTest\staticRangeMapperDataProvider
‪array staticRangeMapperDataProvider($parentSet=null)
Definition: StaticRangeMapperTest.php:39
‪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