Example #1
0
 public function test_collection_method_map_with_key_works_as_expected()
 {
     $original_array = ['foo' => 'bar', 'baz' => 'john'];
     $expected = ['foo-o' => 'bar', 'baz-o' => 'john'];
     $collection = new Collection($original_array);
     $actual = $collection->mapWithKey(function ($value, $key) {
         return [$key . '-o' => $value];
     });
     $this->assertEquals($expected, $actual->toArray());
 }