‪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 
20 use PHPUnit\Framework\TestCase;
22 
26 class ‪StaticRangeMapperTest extends TestCase
27 {
28  public function ‪valueSettingsDataProvider(): array
29  {
30  return [
31  '1-3' => [
32  '1',
33  '3',
34  [
35  'a' => null,
36  '0' => null,
37  '1' => '1',
38  '2' => '2',
39  '3' => '3',
40  '4' => null,
41  'z' => null,
42  ],
43  ],
44  'b-d' => [
45  'b',
46  'd',
47  [
48  '0' => null,
49  'a' => null,
50  'b' => 'b',
51  'c' => 'c',
52  'd' => 'd',
53  'e' => null,
54  '9' => null,
55  ],
56  ],
57  '@-C' => [
58  '@',
59  'C',
60  [
61  '?' => null,
62  '@' => '@',
63  'A' => 'A',
64  'B' => 'B',
65  'C' => 'C',
66  'D' => null,
67  ],
68  ],
69  '0-11 (no zero prefix)' => [
70  '0',
71  '11',
72  [
73  '00' => null,
74  '01' => null,
75  '0' => '0',
76  '1' => '1',
77  '10' => '10',
78  '11' => '11',
79  '12' => null,
80  ],
81  ],
82  '2-11 (no zero prefix)' => [
83  '2',
84  '11',
85  [
86  '00' => null,
87  '01' => null,
88  '02' => null,
89  '03' => null,
90  '0' => null,
91  '1' => null,
92  '2' => '2',
93  '3' => '3',
94  '10' => '10',
95  '11' => '11',
96  '12' => null,
97  ],
98  ],
99  '00-11 (no zero prefix)' => [
100  '00',
101  '11',
102  [
103  '00' => '00',
104  '01' => '01',
105  '10' => '10',
106  '11' => '11',
107  '12' => null,
108  ],
109  ],
110  '02-11 (apply zero prefix)' => [
111  '02',
112  '11',
113  [
114  '00' => null,
115  '01' => null,
116  '02' => '02',
117  '03' => '03',
118  '10' => '10',
119  '11' => '11',
120  '12' => null,
121  ],
122  ],
123  '11-02 (apply zero prefix)' => [
124  '11',
125  '02',
126  [
127  '00' => null,
128  '01' => null,
129  '02' => '02',
130  '03' => '03',
131  '10' => '10',
132  '11' => '11',
133  '12' => null,
134  ],
135  ],
136  '011-002 (apply zero prefix)' => [
137  '011',
138  '002',
139  [
140  '000' => null,
141  '001' => null,
142  '002' => '002',
143  '003' => '003',
144  '010' => '010',
145  '011' => '011',
146  '012' => null,
147  ],
148  ],
149  '2-100 (no zero prefix)' => [
150  '2',
151  '100',
152  [
153  '2' => '2',
154  '02' => null,
155  '002' => null,
156  '100' => '100',
157  ],
158  ],
159  // use maximum char length (3) even if '02' is given
160  '02-100 (zero prefix)' => [
161  '02',
162  '100',
163  [
164  '2' => null,
165  '02' => null,
166  '002' => '002',
167  '100' => '100',
168  ],
169  ],
170  '002-100 (zero prefix)' => [
171  '002',
172  '100',
173  [
174  '2' => null,
175  '02' => null,
176  '002' => '002',
177  '100' => '100',
178  ],
179  ],
180  ];
181  }
182 
191  public function ‪resolveDeterminesValues(string $start, string $end, array $expectations): void
192  {
193  $subject = new ‪StaticRangeMapper([
194  'start' => $start,
195  'end' => $end,
196  ]);
197  foreach ($expectations as $value => $expectation) {
198  self::assertSame($expectation, $subject->resolve((string)$value));
199  }
200  }
201 }
‪TYPO3\CMS\Extbase\Tests\Unit\Routing\Aspect\StaticRangeMapperTest\valueSettingsDataProvider
‪valueSettingsDataProvider()
Definition: StaticRangeMapperTest.php:28
‪TYPO3\CMS\Extbase\Tests\Unit\Routing\Aspect\StaticRangeMapperTest\resolveDeterminesValues
‪resolveDeterminesValues(string $start, string $end, array $expectations)
Definition: StaticRangeMapperTest.php:191
‪TYPO3\CMS\Extbase\Tests\Unit\Routing\Aspect
Definition: StaticRangeMapperTest.php:18
‪TYPO3\CMS\Extbase\Tests\Unit\Routing\Aspect\StaticRangeMapperTest
Definition: StaticRangeMapperTest.php:27
‪TYPO3\CMS\Core\Routing\Aspect\StaticRangeMapper
Definition: StaticRangeMapper.php:46