Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

amirmohammadnajmi
Copy link

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
29 checks passed
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