Skip to content

[12.x] Add test for collapse in collections#54032

Merged
taylorotwell merged 1 commit into
laravel:masterfrom
amirmohammadnajmi:test/add-test-collapse
Dec 30, 2024
Merged

[12.x] Add test for collapse in collections#54032
taylorotwell merged 1 commit into
laravel:masterfrom
amirmohammadnajmi:test/add-test-collapse

Conversation

@amirmohammadnajmi

Copy link
Copy Markdown
Contributor

This PR, improvement tests for collapse method in collections:

  • Case including numeric and string elements
$data = new $collection([[1], [2], [3], ['foo', 'bar'], new $collection(['baz', 'boom'])]);
$this->assertEquals([1, 2, 3, 'foo', 'bar', 'baz', 'boom'], $data->collapse()->all());
  • Case with empty two-dimensional arrays
$data = new $collection([[], [], []]);
$this->assertEquals([], $data->collapse()->all());
  • Case with both empty arrays and arrays with elements
$data = new $collection([[], [1, 2], [], ['foo', 'bar']]);
$this->assertEquals([1, 2, 'foo', 'bar'], $data->collapse()->all());
  • Case including collections and arrays
$collection = new $collection(['baz', 'boom']);
$data = new $collection([[1], [2], [3], ['foo', 'bar'], $collection]);
$this->assertEquals([1, 2, 3, 'foo', 'bar', 'baz', 'boom'], $data->collapse()->all());

@taylorotwell taylorotwell merged commit b5280f0 into laravel:master Dec 30, 2024
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