Skip to content

Commit

Permalink
[11.x] Add tests to improve test coverage for Arr::whereNotNull (#5…
Browse files Browse the repository at this point in the history
…1661)

* tests: add some tests for Arr::whereNotNull ( improve test coverage)

* fix code style: using fn instead of function
  • Loading branch information
saMahmoudzadeh authored May 31, 2024
1 parent e1c638e commit f05f7bc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/Support/SupportArrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f05f7bc

Please sign in to comment.