Skip to content

Commit d44cd8d

Browse files
authored
[9.x] Improve Test for Map method in Collection (#43363)
1 parent 8974fcc commit d44cd8d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/Support/SupportCollectionTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,6 +2819,13 @@ public function testGetPluckValueWithAccessors($collection)
28192819
*/
28202820
public function testMap($collection)
28212821
{
2822+
$data = new $collection([1, 2, 3]);
2823+
$mapped = $data->map(function ($item, $key) {
2824+
return $item * 2;
2825+
});
2826+
$this->assertEquals([2, 4, 6], $mapped->all());
2827+
$this->assertEquals([1, 2, 3], $data->all());
2828+
28222829
$data = new $collection(['first' => 'taylor', 'last' => 'otwell']);
28232830
$data = $data->map(function ($item, $key) {
28242831
return $key.'-'.strrev($item);
@@ -2933,6 +2940,7 @@ public function testMapToGroupsWithNumericKeys($collection)
29332940
});
29342941

29352942
$this->assertEquals([1 => [0, 4], 2 => [1, 3], 3 => [2]], $groups->toArray());
2943+
$this->assertEquals([1, 2, 3, 2, 1], $data->all());
29362944
}
29372945

29382946
/**

0 commit comments

Comments
 (0)