‪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) {
44  ‪Variables::create(['value' => $value])
45  );
46  },
47  range(10, 100, 30)
48  );
49 
50  $builder = ‪Builder::create();
51  // variables (applied when invoking expectations)
52  $variables = ‪Variables::create()->define([
53  'value' => null, // defined via VariableContext
54  'routePrefix' => 'enhance',
55  'aspectName' => 'value',
56  ]);
57  return ‪Permutation::create($variables)
58  ->withTargets(
59  ‪TestSet::create($parentSet)
60  ->withMergedApplicables(‪LanguageContext::create(0))
61  ->withTargetPageId(1100)
62  ->withUrl(
64  'https://acme.us/welcome/enhance/[[value]][[pathSuffix]]',
65  ‪Variables::create(['pathSuffix' => ''])
66  )
67  ),
68  ‪TestSet::create($parentSet)
69  ->withMergedApplicables(‪LanguageContext::create(1))
70  ->withTargetPageId(1100)
71  ->withUrl(
73  'https://acme.fr/bienvenue/enhance/[[value]][[pathSuffix]]',
74  ‪Variables::create(['pathSuffix' => ''])
75  )
76  )
77  )
78  ->withApplicableItems($variableContexts)
79  ->withApplicableItems($builder->declareEnhancers())
80  ->withApplicableSet(
81  ‪AspectDeclaration::create('StaticRangeMapper')->withConfiguration([
82  ‪VariableItem::create('aspectName', [
83  'type' => 'StaticRangeMapper',
84  'start' => '1',
85  'end' => '100',
86  ]),
87  ])
88  )
89  ->permute()
90  ->getTargetsForDataProvider();
91  }
92 
98  public function ‪staticRangeMapperIsApplied(‪TestSet $testSet): void
99  {
100  $this->‪assertGeneratedUriEquals($testSet);
101  }
102 
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\EnhancerLinkGenerator\StaticRangeMapperTest\staticRangeMapperIsApplied
‪staticRangeMapperIsApplied(TestSet $testSet)
Definition: StaticRangeMapperTest.php:98
‪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\EnhancerLinkGenerator\StaticRangeMapperTest\pageTypeDecoratorIsAppliedDataProvider
‪array pageTypeDecoratorIsAppliedDataProvider()
Definition: StaticRangeMapperTest.php:109
‪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\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\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\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\StaticRangeMapperTest\staticRangeMapperDataProvider
‪array staticRangeMapperDataProvider($parentSet=null)
Definition: StaticRangeMapperTest.php:39
‪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\StaticRangeMapperTest
Definition: StaticRangeMapperTest.php:34