‪TYPO3CMS  10.4
CacheHashConfigurationTest.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 
20 use PHPUnit\Framework\TestCase;
23 
24 class ‪CacheHashConfigurationTest extends TestCase
25 {
27  {
29  [
34  ],
35  ['true', true, 1, new \stdClass()],
36  ]);
37  }
38 
46  public function ‪nonArrayValueThrowsException(string $aspect, $value): void
47  {
48  $this->expectException(\LogicException::class);
49  $this->expectExceptionCode(1580225311);
50  new ‪CacheHashConfiguration([$aspect => $value]);
51  }
52 
54  {
56  [
61  ],
62  [null, [], new \stdClass()]
63  ]);
64  }
65 
73  public function ‪nonScalarValueThrowsException(string $aspect, $value): void
74  {
75  $this->expectException(\LogicException::class);
76  $this->expectExceptionCode(1580225312);
77  new ‪CacheHashConfiguration([$aspect => [$value]]);
78  }
79 
81  {
83  [
88  ],
89  ['=', '^', '~']
90  ]);
91  }
92 
100  public function ‪emptyIndicatedValueThrowsException(string $aspect, string $value): void
101  {
102  $this->expectException(\LogicException::class);
103  $this->expectExceptionCode(1580225313);
104  new ‪CacheHashConfiguration([$aspect => [$value]]);
105  }
106 
108  {
110  [
115  ],
116  [['equals-a', '=equals-b', '^equals', '~equals']],
117  [['equals-a', 'equals-b']],
118  [['eq', 'equals', 'other', 'prefixed-equals-other']]
119  ]);
120  }
121 
131  public function ‪equalsResolvesParameterValue(string $aspect, array $values, array $positives, array $negatives): void
132  {
133  $configuration = new ‪CacheHashConfiguration([$aspect => $values]);
134  foreach ($positives as $probe) {
135  self::assertTrue($configuration->equals($aspect, $probe), $probe);
136  }
137  foreach ($negatives as $probe) {
138  self::assertFalse($configuration->equals($aspect, $probe), $probe);
139  }
140  }
141 
143  {
145  [
150  ],
151  [['equals-a', '=equals-b', '^equals', '~equals']],
152  [['equals', 'equals-a', 'equals-b', 'equals-other']],
153  [['eq', 'other', 'prefixed-equals-other']]
154  ]);
155  }
156 
166  public function ‪startsWithResolvesParameterValue(string $aspect, array $values, array $positives, array $negatives): void
167  {
168  $configuration = new ‪CacheHashConfiguration([$aspect => $values]);
169  foreach ($positives as $probe) {
170  self::assertTrue($configuration->startsWith($aspect, $probe), $probe);
171  }
172  foreach ($negatives as $probe) {
173  self::assertFalse($configuration->startsWith($aspect, $probe), $probe);
174  }
175  }
176 
178  {
180  [
185  ],
186  [['equals-a', '=equals-b', '^equals', '~equals']],
187  [['equals', 'equals-a', 'equals-b', 'equals-other', 'prefixed-equals-other']],
188  [['eq', 'other']]
189  ]);
190  }
191 
201  public function ‪containsResolvesParameterValue(string $aspect, array $values, array $positives, array $negatives): void
202  {
203  $configuration = new ‪CacheHashConfiguration([$aspect => $values]);
204  foreach ($positives as $probe) {
205  self::assertTrue($configuration->contains($aspect, $probe), $probe);
206  }
207  foreach ($negatives as $probe) {
208  self::assertFalse($configuration->contains($aspect, $probe), $probe);
209  }
210  }
211 
213  {
214  // currently using "contains" data provider, could have own test sets as well
216  }
217 
227  public function ‪appliesResolvesParameterValue(string $aspect, array $values, array $positives, array $negatives): void
228  {
229  $configuration = new ‪CacheHashConfiguration([$aspect => $values]);
230  foreach ($positives as $probe) {
231  self::assertTrue($configuration->applies($aspect, $probe), $probe);
232  }
233  foreach ($negatives as $probe) {
234  self::assertFalse($configuration->applies($aspect, $probe), $probe);
235  }
236  }
237 }
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\appliesResolvesParameterValue
‪appliesResolvesParameterValue(string $aspect, array $values, array $positives, array $negatives)
Definition: CacheHashConfigurationTest.php:227
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\equalsResolvesParameterValue
‪equalsResolvesParameterValue(string $aspect, array $values, array $positives, array $negatives)
Definition: CacheHashConfigurationTest.php:131
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\emptyIndicatedValueThrowsException
‪emptyIndicatedValueThrowsException(string $aspect, string $value)
Definition: CacheHashConfigurationTest.php:100
‪TYPO3\CMS\Frontend\Page\CacheHashConfiguration\ASPECT_CACHED_PARAMETERS_WHITELIST
‪const ASPECT_CACHED_PARAMETERS_WHITELIST
Definition: CacheHashConfiguration.php:36
‪TYPO3\CMS\Frontend\Page\CacheHashConfiguration\ASPECT_REQUIRED_CACHE_HASH_PRESENCE_PARAMETERS
‪const ASPECT_REQUIRED_CACHE_HASH_PRESENCE_PARAMETERS
Definition: CacheHashConfiguration.php:39
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\containsResolvesParameterValueDataProvider
‪containsResolvesParameterValueDataProvider()
Definition: CacheHashConfigurationTest.php:177
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\appliesResolvesParameterValueDataProvider
‪appliesResolvesParameterValueDataProvider()
Definition: CacheHashConfigurationTest.php:212
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\equalsResolvesParameterValueDataProvider
‪equalsResolvesParameterValueDataProvider()
Definition: CacheHashConfigurationTest.php:107
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\nonArrayValueThrowsException
‪nonArrayValueThrowsException(string $aspect, $value)
Definition: CacheHashConfigurationTest.php:46
‪TYPO3\CMS\Frontend\Tests\Unit\Page
Definition: CacheHashCalculatorTest.php:18
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\emptyIndicatedValueThrowsExceptionDataProvider
‪emptyIndicatedValueThrowsExceptionDataProvider()
Definition: CacheHashConfigurationTest.php:80
‪TYPO3\CMS\Core\Utility\PermutationUtility
Definition: PermutationUtility.php:24
‪TYPO3\CMS\Frontend\Page\CacheHashConfiguration\ASPECT_EXCLUDED_PARAMETERS
‪const ASPECT_EXCLUDED_PARAMETERS
Definition: CacheHashConfiguration.php:37
‪TYPO3\CMS\Frontend\Page\CacheHashConfiguration
Definition: CacheHashConfiguration.php:35
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest
Definition: CacheHashConfigurationTest.php:25
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\nonScalarValueThrowsExceptionDataProvider
‪nonScalarValueThrowsExceptionDataProvider()
Definition: CacheHashConfigurationTest.php:53
‪TYPO3\CMS\Core\Utility\PermutationUtility\meltArrayItems
‪static array meltArrayItems(array $payload, array $previousResult=[])
Definition: PermutationUtility.php:66
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\nonArrayValueThrowsExceptionDataProvider
‪nonArrayValueThrowsExceptionDataProvider()
Definition: CacheHashConfigurationTest.php:26
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\containsResolvesParameterValue
‪containsResolvesParameterValue(string $aspect, array $values, array $positives, array $negatives)
Definition: CacheHashConfigurationTest.php:201
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\nonScalarValueThrowsException
‪nonScalarValueThrowsException(string $aspect, $value)
Definition: CacheHashConfigurationTest.php:73
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\startsWithResolvesParameterValue
‪startsWithResolvesParameterValue(string $aspect, array $values, array $positives, array $negatives)
Definition: CacheHashConfigurationTest.php:166
‪TYPO3\CMS\Frontend\Tests\Unit\Page\CacheHashConfigurationTest\startsWithResolvesParameterValueDataProvider
‪startsWithResolvesParameterValueDataProvider()
Definition: CacheHashConfigurationTest.php:142