|
4 | 4 |
|
5 | 5 | namespace Ramsey\Collection\Test; |
6 | 6 |
|
7 | | -use Ramsey\Collection\AbstractCollection; |
8 | 7 | use Ramsey\Collection\Collection; |
9 | 8 | use Ramsey\Collection\Exception\CollectionMismatchException; |
10 | 9 | use Ramsey\Collection\Exception\InvalidSortOrderException; |
@@ -185,6 +184,7 @@ public function testDiffShouldRaiseExceptionOnDiverseCollections(): void |
185 | 184 | $this->expectException(CollectionMismatchException::class); |
186 | 185 | $this->expectExceptionMessage('Collection must be of type Ramsey\Collection\Test\Mock\BarCollection'); |
187 | 186 |
|
| 187 | + // @phpstan-ignore-next-line |
188 | 188 | $barCollection->diff(new FooCollection()); |
189 | 189 | } |
190 | 190 |
|
@@ -249,6 +249,7 @@ public function testIntersectShouldRaiseExceptionOnDiverseCollections(): void |
249 | 249 | $this->expectException(CollectionMismatchException::class); |
250 | 250 | $this->expectExceptionMessage('Collection must be of type Ramsey\Collection\Test\Mock\BarCollection'); |
251 | 251 |
|
| 252 | + // @phpstan-ignore-next-line |
252 | 253 | $barCollection->intersect(new FooCollection()); |
253 | 254 | } |
254 | 255 |
|
@@ -316,6 +317,7 @@ public function testMergeShouldRaiseExceptionOnDiverseCollection(): void |
316 | 317 | 'Collection with index 1 must be of type Ramsey\Collection\Test\Mock\BarCollection' |
317 | 318 | ); |
318 | 319 |
|
| 320 | + // @phpstan-ignore-next-line |
319 | 321 | $barCollection->merge(new BarCollection(), new FooCollection()); |
320 | 322 | } |
321 | 323 |
|
@@ -367,18 +369,24 @@ public function testMergeGenericCollection(): void |
367 | 369 |
|
368 | 370 | public function testMapConvertsValues(): void |
369 | 371 | { |
370 | | - $stringCollection = new class (['foo', 'bar']) extends AbstractCollection { |
371 | | - public function getType(): string |
372 | | - { |
373 | | - return 'string'; |
374 | | - } |
375 | | - }; |
376 | | - |
377 | | - $upperStringCollection = $stringCollection->map(function ($item) { |
378 | | - return strtoupper($item); |
| 372 | + $bar1 = new Bar(1, 'Jane'); |
| 373 | + $bar2 = new Bar(2, 'John'); |
| 374 | + $bar3 = new Bar(3, 'Janice'); |
| 375 | + |
| 376 | + $barCollection = new BarCollection(); |
| 377 | + $barCollection[] = $bar1; |
| 378 | + $barCollection[] = $bar2; |
| 379 | + $barCollection[] = $bar3; |
| 380 | + |
| 381 | + $names = $barCollection->map(function (Bar $bar): string { |
| 382 | + return $bar->getName(); |
| 383 | + }); |
| 384 | + |
| 385 | + $ids = $barCollection->map(function (Bar $bar): int { |
| 386 | + return $bar->getId(); |
379 | 387 | }); |
380 | 388 |
|
381 | | - $this->assertNotSame($stringCollection, $upperStringCollection); |
382 | | - $this->assertSame(['FOO', 'BAR'], $upperStringCollection->toArray()); |
| 389 | + $this->assertSame(['Jane', 'John', 'Janice'], $names->toArray()); |
| 390 | + $this->assertSame([1, 2, 3], $ids->toArray()); |
383 | 391 | } |
384 | 392 | } |
0 commit comments