Example #1
0
 /** @test */
 public function it_can_map_a_collection_using_a_function()
 {
     $collection = new Collection([['id' => 'foo'], ['id' => 'bar']]);
     $mapped = $collection->map(function ($item) {
         $item['id'] .= 'baz';
         return $item;
     });
     $expected = [['id' => 'foobaz'], ['id' => 'barbaz']];
     $this->assertEquals($expected, $mapped->all());
 }