Skip to content

Conversation

@saMahmoudzadeh
Copy link
Contributor

This PR, adds tests to improve the test coverage of Arr::whereNotNull.

The array contains only numeric items

$array = array_values(Arr::whereNotNull([1, 2, 3]));
$this->assertEquals([1, 2, 3], $array);

The array contains only null values

$array = array_values(Arr::whereNotNull([null, null, null]));
$this->assertEquals([], $array);

An array consisting of a mix of characters and null values.

$array = array_values(Arr::whereNotNull(['a', null, 'b', null, 'c']));
$this->assertEquals(['a', 'b', 'c'], $array);

An array containing various data types.

$array = array_values(Arr::whereNotNull([null, 1, 'string', 0.0, false, [], new stdClass(), function () {}]));
$this->assertEquals([1, 'string', 0.0, false, [], new stdClass(), function () {}], $array);

@taylorotwell taylorotwell merged commit f05f7bc into laravel:11.x May 31, 2024
@saMahmoudzadeh saMahmoudzadeh deleted the tests/add-tests-arr branch May 31, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants