From f05f7bc793c20c9413fc2e78954c88738a033e4e Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" <36761585+saMahmoudzadeh@users.noreply.github.com> Date: Fri, 31 May 2024 19:53:52 +0330 Subject: [PATCH] [11.x] Add tests to improve test coverage for `Arr::whereNotNull` (#51661) * tests: add some tests for Arr::whereNotNull ( improve test coverage) * fix code style: using fn instead of function --- tests/Support/SupportArrTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/Support/SupportArrTest.php b/tests/Support/SupportArrTest.php index cca30dfcb3e1..6389f24b9593 100644 --- a/tests/Support/SupportArrTest.php +++ b/tests/Support/SupportArrTest.php @@ -213,10 +213,22 @@ public function testExists() $this->assertFalse(Arr::exists(new Collection(['a' => null]), 'b')); } - public function testWhereNotNull() + public function testWhereNotNull(): void { $array = array_values(Arr::whereNotNull([null, 0, false, '', null, []])); $this->assertEquals([0, false, '', []], $array); + + $array = array_values(Arr::whereNotNull([1, 2, 3])); + $this->assertEquals([1, 2, 3], $array); + + $array = array_values(Arr::whereNotNull([null, null, null])); + $this->assertEquals([], $array); + + $array = array_values(Arr::whereNotNull(['a', null, 'b', null, 'c'])); + $this->assertEquals(['a', 'b', 'c'], $array); + + $array = array_values(Arr::whereNotNull([null, 1, 'string', 0.0, false, [], new stdClass(), fn () => null])); + $this->assertEquals([1, 'string', 0.0, false, [], new stdClass(), fn () => null], $array); } public function testFirst()