From 53a5aab7da8b0b56ac2ee07e02a77edb9595e9f4 Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" <36761585+saMahmoudzadeh@users.noreply.github.com> Date: Sun, 7 Apr 2024 21:06:57 +0330 Subject: [PATCH] test: improvement tests for Arr::map (#50941) --- tests/Support/SupportArrTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Support/SupportArrTest.php b/tests/Support/SupportArrTest.php index 9df13ff7befb..1b85cfaf31f8 100644 --- a/tests/Support/SupportArrTest.php +++ b/tests/Support/SupportArrTest.php @@ -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 = [