Skip to content

Commit

Permalink
test: improvement tests for Arr::map (#50941)
Browse files Browse the repository at this point in the history
  • Loading branch information
saMahmoudzadeh authored Apr 7, 2024
1 parent 421393f commit 53a5aab
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/Support/SupportArrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,23 @@ public function testMap()
$this->assertEquals(['first' => 'taylor', 'last' => 'otwell'], $data);
}

public function testMapWithEmptyArray()
{
$mapped = Arr::map([], static function ($value, $key) {
return $key.'-'.$value;
});
$this->assertEquals([], $mapped);
}

public function testMapNullValues()
{
$data = ['first' => 'taylor', 'last' => null];
$mapped = Arr::map($data, static function ($value, $key) {
return $key.'-'.$value;
});
$this->assertEquals(['first' => 'first-taylor', 'last' => 'last-'], $mapped);
}

public function testMapWithKeys()
{
$data = [
Expand Down

0 comments on commit 53a5aab

Please sign in to comment.