‪TYPO3CMS  9.5
StaticRangeMapperTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use PHPUnit\Framework\TestCase;
21 
25 class ‪StaticRangeMapperTest extends TestCase
26 {
27  public function ‪valueSettingsDataProvider(): array
28  {
29  return [
30  '1-3' => [
31  '1',
32  '3',
33  [
34  'a' => null,
35  '0' => null,
36  '1' => '1',
37  '2' => '2',
38  '3' => '3',
39  '4' => null,
40  'z' => null,
41  ]
42  ],
43  'b-d' => [
44  'b',
45  'd',
46  [
47  '0' => null,
48  'a' => null,
49  'b' => 'b',
50  'c' => 'c',
51  'd' => 'd',
52  'e' => null,
53  '9' => null,
54  ]
55  ],
56  '@-C' => [
57  '@',
58  'C',
59  [
60  '?' => null,
61  '@' => '@',
62  'A' => 'A',
63  'B' => 'B',
64  'C' => 'C',
65  'D' => null,
66  ]
67  ],
68  '0-11 (no zero prefix)' => [
69  '0',
70  '11',
71  [
72  '00' => null,
73  '01' => null,
74  '0' => '0',
75  '1' => '1',
76  '10' => '10',
77  '11' => '11',
78  '12' => null,
79  ]
80  ],
81  '2-11 (no zero prefix)' => [
82  '2',
83  '11',
84  [
85  '00' => null,
86  '01' => null,
87  '02' => null,
88  '03' => null,
89  '0' => null,
90  '1' => null,
91  '2' => '2',
92  '3' => '3',
93  '10' => '10',
94  '11' => '11',
95  '12' => null,
96  ]
97  ],
98  '00-11 (no zero prefix)' => [
99  '00',
100  '11',
101  [
102  '00' => '00',
103  '01' => '01',
104  '10' => '10',
105  '11' => '11',
106  '12' => null,
107  ]
108  ],
109  '02-11 (apply zero prefix)' => [
110  '02',
111  '11',
112  [
113  '00' => null,
114  '01' => null,
115  '02' => '02',
116  '03' => '03',
117  '10' => '10',
118  '11' => '11',
119  '12' => null,
120  ]
121  ],
122  '11-02 (apply zero prefix)' => [
123  '11',
124  '02',
125  [
126  '00' => null,
127  '01' => null,
128  '02' => '02',
129  '03' => '03',
130  '10' => '10',
131  '11' => '11',
132  '12' => null,
133  ]
134  ],
135  '011-002 (apply zero prefix)' => [
136  '011',
137  '002',
138  [
139  '000' => null,
140  '001' => null,
141  '002' => '002',
142  '003' => '003',
143  '010' => '010',
144  '011' => '011',
145  '012' => null,
146  ]
147  ],
148  '2-100 (no zero prefix)' => [
149  '2',
150  '100',
151  [
152  '2' => '2',
153  '02' => null,
154  '002' => null,
155  '100' => '100',
156  ]
157  ],
158  // use maximum char length (3) even if '02' is given
159  '02-100 (zero prefix)' => [
160  '02',
161  '100',
162  [
163  '2' => null,
164  '02' => null,
165  '002' => '002',
166  '100' => '100',
167  ]
168  ],
169  '002-100 (zero prefix)' => [
170  '002',
171  '100',
172  [
173  '2' => null,
174  '02' => null,
175  '002' => '002',
176  '100' => '100',
177  ]
178  ],
179  ];
180  }
181 
190  public function ‪resolveDeterminesValues(string $start, string $end, array $expectations): void
191  {
192  $subject = new ‪StaticRangeMapper([
193  'start' => $start,
194  'end' => $end,
195  ]);
196  foreach ($expectations as $value => $expectation) {
197  self::assertSame($expectation, $subject->resolve((string)$value));
198  }
199  }
200 }
‪TYPO3\CMS\Extbase\Tests\Unit\Routing\Aspect\StaticRangeMapperTest\valueSettingsDataProvider
‪valueSettingsDataProvider()
Definition: StaticRangeMapperTest.php:27
‪TYPO3\CMS\Extbase\Tests\Unit\Routing\Aspect\StaticRangeMapperTest\resolveDeterminesValues
‪resolveDeterminesValues(string $start, string $end, array $expectations)
Definition: StaticRangeMapperTest.php:190
‪TYPO3\CMS\Extbase\Tests\Unit\Routing\Aspect
Definition: StaticRangeMapperTest.php:4
‪TYPO3\CMS\Extbase\Tests\Unit\Routing\Aspect\StaticRangeMapperTest
Definition: StaticRangeMapperTest.php:26
‪TYPO3\CMS\Core\Routing\Aspect\StaticRangeMapper
Definition: StaticRangeMapper.php:45