‪TYPO3CMS  11.5
PersistedPatternMapperTest.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 ‪persistedPatternMapperDataProvider($parentSet = null): array
39  {
40  $builder = ‪Builder::create();
41  // variables (applied when invoking expectations)
42  $variables = ‪Variables::create()->define([
43  'value' => 1100,
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/hello-and-welcome-[[value]][[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/salut-et-bienvenue-[[value]][[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/hello-and-welcome-[[value]][[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/salut-et-bienvenue-[[value]][[pathSuffix]]',
82  ‪Variables::create(['pathSuffix' => ''])
83  )
84  )
85  )
86  ->withApplicableItems($builder->declareEnhancers())
87  ->withApplicableSet(
88  ‪AspectDeclaration::create('PersistedPatternMapper')->withConfiguration([
89  ‪VariableItem::create('aspectName', [
90  'type' => 'PersistedPatternMapper',
91  'tableName' => 'pages',
92  'routeFieldPattern' => '^(?P<subtitle>.+)-(?P<uid>\d+)$',
93  'routeFieldResult' => '{subtitle}-{uid}',
94  ]),
95  ])
96  )
97  ->permute()
98  ->getTargetsForDataProvider();
99  }
100 
106  public function ‪persistedPatternMapperIsApplied(‪TestSet $testSet): void
107  {
108  $this->‪assertGeneratedUriEquals($testSet);
109  }
110 
118  {
119  $testSets = [];
120  foreach (‪Builder::create()->declarePageTypes() as $pageTypeDeclaration) {
121  $testSet = ‪TestSet::create()
122  ->withMergedApplicables($pageTypeDeclaration)
123  ->withVariables($pageTypeDeclaration->getVariables());
124  $testSets = array_merge(
125  $testSets,
126  $this->‪persistedPatternMapperDataProvider($testSet),
127  );
128  }
129  return $testSets;
130  }
131 
137  public function ‪pageTypeDecoratorIsApplied(‪TestSet $testSet): void
138  {
139  parent::pageTypeDecoratorIsApplied($testSet);
140  }
141 }
‪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\EnhancerLinkGenerator\PersistedPatternMapperTest
Definition: PersistedPatternMapperTest.php:33
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Permutation
Definition: Permutation.php:23
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\PersistedPatternMapperTest\pageTypeDecoratorIsAppliedDataProvider
‪array pageTypeDecoratorIsAppliedDataProvider()
Definition: PersistedPatternMapperTest.php:117
‪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\PersistedPatternMapperTest\persistedPatternMapperIsApplied
‪persistedPatternMapperIsApplied(TestSet $testSet)
Definition: PersistedPatternMapperTest.php:106
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Permutation\create
‪static create(Variables $variables)
Definition: Permutation.php:44
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerLinkGenerator\PersistedPatternMapperTest\pageTypeDecoratorIsApplied
‪pageTypeDecoratorIsApplied(TestSet $testSet)
Definition: PersistedPatternMapperTest.php:137
‪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\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\EnhancerLinkGenerator\PersistedPatternMapperTest\persistedPatternMapperDataProvider
‪array persistedPatternMapperDataProvider($parentSet=null)
Definition: PersistedPatternMapperTest.php:38
‪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