|
2 | 2 |
|
3 | 3 | namespace LastDragon_ru\LaraASP\Documentator\Editor;
|
4 | 4 |
|
5 |
| -use LastDragon_ru\LaraASP\Documentator\Editor\Locations\Append; |
6 | 5 | use LastDragon_ru\LaraASP\Documentator\Editor\Locations\Location;
|
7 | 6 | use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
|
8 |
| -use Override; |
9 | 7 | use PHPUnit\Framework\Attributes\CoversClass;
|
10 | 8 |
|
11 |
| -use function array_values; |
12 |
| -use function iterator_to_array; |
13 |
| - |
14 | 9 | use const PHP_INT_MAX;
|
15 | 10 |
|
16 | 11 | /**
|
@@ -125,98 +120,4 @@ public function getLines(): array {
|
125 | 120 | self::assertEquals($lines, $editor->getLines());
|
126 | 121 | self::assertSame($expected, $actual->getLines());
|
127 | 122 | }
|
128 |
| - |
129 |
| - public function testPrepare(): void { |
130 |
| - $editor = new readonly class(['L1', 'L2']) extends Editor { |
131 |
| - /** |
132 |
| - * @inheritDoc |
133 |
| - */ |
134 |
| - #[Override] |
135 |
| - public function prepare(iterable $changes): array { |
136 |
| - return parent::prepare($changes); |
137 |
| - } |
138 |
| - }; |
139 |
| - $changes = [ |
140 |
| - [new Location(10, 10, 15, 10), 'a'], |
141 |
| - [new Location(10, 10, 10, null), 'b'], |
142 |
| - [new Location(12, 15, 5, 10), 'c'], |
143 |
| - ]; |
144 |
| - $expected = [ |
145 |
| - [iterator_to_array(new Location(12, 15, 5, 10)), 'c'], |
146 |
| - [iterator_to_array(new Location(10, 10, 10, null)), 'b'], |
147 |
| - [iterator_to_array(new Location(10, 10, 15, 10)), 'a'], |
148 |
| - ]; |
149 |
| - |
150 |
| - self::assertEquals($expected, $editor->prepare($changes)); |
151 |
| - } |
152 |
| - |
153 |
| - public function testRemoveOverlaps(): void { |
154 |
| - $editor = new readonly class([]) extends Editor { |
155 |
| - /** |
156 |
| - * @inheritDoc |
157 |
| - */ |
158 |
| - #[Override] |
159 |
| - public function removeOverlaps(array $changes): array { |
160 |
| - return parent::removeOverlaps($changes); |
161 |
| - } |
162 |
| - }; |
163 |
| - $changes = [ |
164 |
| - 0 => [array_values(iterator_to_array(new Location(18, 18, 5, 10))), 'a'], |
165 |
| - 1 => [array_values(iterator_to_array(new Location(17, 17, 11, 10))), 'b'], |
166 |
| - 2 => [array_values(iterator_to_array(new Location(17, 17, 5, 10))), 'c'], |
167 |
| - 3 => [array_values(iterator_to_array(new Location(14, 15, 5, 10))), 'd'], |
168 |
| - 4 => [array_values(iterator_to_array(new Location(12, 15, 5, 10))), 'e'], |
169 |
| - 5 => [array_values(iterator_to_array(new Location(10, 10, 10, null))), 'f'], |
170 |
| - 6 => [array_values(iterator_to_array(new Location(10, 10, 15, 10))), 'g'], |
171 |
| - 7 => [array_values(iterator_to_array(new Location(9, 9, 39, 11))), 'h'], |
172 |
| - 8 => [array_values(iterator_to_array(new Location(9, 9, 50, null))), 'i'], |
173 |
| - 9 => [array_values(iterator_to_array(new Location(9, 9, 40, 10))), 'j'], |
174 |
| - 10 => [array_values(iterator_to_array(new Location(PHP_INT_MAX, PHP_INT_MAX))), 'k'], |
175 |
| - 11 => [array_values(iterator_to_array(new Append())), 'l'], |
176 |
| - ]; |
177 |
| - $expected = [ |
178 |
| - 0 => [iterator_to_array(new Location(18, 18, 5, 10)), 'a'], |
179 |
| - 1 => [iterator_to_array(new Location(17, 17, 11, 10)), 'b'], |
180 |
| - 3 => [iterator_to_array(new Location(14, 15, 5, 10)), 'd'], |
181 |
| - 5 => [iterator_to_array(new Location(10, 10, 10, null)), 'f'], |
182 |
| - 7 => [iterator_to_array(new Location(9, 9, 39, 11)), 'h'], |
183 |
| - 8 => [iterator_to_array(new Location(9, 9, 50, null)), 'i'], |
184 |
| - 10 => [iterator_to_array(new Location(PHP_INT_MAX, PHP_INT_MAX)), 'k'], |
185 |
| - 11 => [iterator_to_array(new Append()), 'l'], |
186 |
| - ]; |
187 |
| - |
188 |
| - self::assertEquals($expected, $editor->removeOverlaps($changes)); |
189 |
| - } |
190 |
| - |
191 |
| - public function testExpand(): void { |
192 |
| - $editor = new readonly class([]) extends Editor { |
193 |
| - /** |
194 |
| - * @inheritDoc |
195 |
| - */ |
196 |
| - #[Override] |
197 |
| - public function expand(array $changes): array { |
198 |
| - return parent::expand($changes); |
199 |
| - } |
200 |
| - }; |
201 |
| - $changes = [ |
202 |
| - [array_values(iterator_to_array(new Location(PHP_INT_MAX, PHP_INT_MAX))), "new line aa\nnew line ab"], |
203 |
| - [array_values(iterator_to_array(new Location(6, 6, 5, 10, 2))), "text aa\ntext ab"], |
204 |
| - [array_values(iterator_to_array(new Location(4, 5, 5, 5, 1))), "text ba\ntext bb"], |
205 |
| - [array_values(iterator_to_array(new Location(2, 3, 5, null))), 'text c'], |
206 |
| - [array_values(iterator_to_array(new Location(1, 1, 5, 10))), "text da\ntext db\ntext dc"], |
207 |
| - [array_values(iterator_to_array(new Append())), "new line ba\nnew line bb"], |
208 |
| - ]; |
209 |
| - $expected = [ |
210 |
| - [new Coordinate(6, 7, 10, 2), ['text aa', 'text ab']], |
211 |
| - [new Coordinate(5, 1, 5, 1), ['text bb']], |
212 |
| - [new Coordinate(4, 6, null, 1), ['text ba']], |
213 |
| - [new Coordinate(3, 0, null, 0), []], |
214 |
| - [new Coordinate(2, 5, null, 0), ['text c']], |
215 |
| - [new Coordinate(1, 5, 10, 0), ['text da', 'text db', 'text dc']], |
216 |
| - [new Coordinate(PHP_INT_MAX, 0, null, 0), ['new line ba', 'new line bb']], |
217 |
| - [new Coordinate(PHP_INT_MAX, 0, null, 0), ['new line aa', 'new line ab']], |
218 |
| - ]; |
219 |
| - |
220 |
| - self::assertEquals($expected, $editor->expand($changes)); |
221 |
| - } |
222 | 123 | }
|
0 commit comments