Skip to content

[12.x] Add missing tests for LazyCollection methods #55022

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

Merged

Conversation

mohammadrasoulasghari
Copy link
Contributor

@mohammadrasoulasghari mohammadrasoulasghari commented Mar 14, 2025

Add missing tests for LazyCollection methods

In this PR, I've added test coverage for several LazyCollection methods that previously lacked tests to verify their logical behavior with various edge cases. ✅ The LazyCollection class was missing tests for the following methods:

  • collapseWithKeys
  • containsOneItem
  • doesntContain
  • dot
  • hasAny

These tests ensure that each method works correctly under different scenarios, including edge cases like empty collections, nested arrays, and various input types. By adding comprehensive test coverage, we can have greater confidence in the reliability and correctness of the LazyCollection service.

Each test verifies the expected behavior of these methods with different input patterns and ensures they handle all scenarios properly according to their intended functionality.

This commit adds test coverage for the collapseWithKeys method, verifying:
- Nested arrays collapse correctly with preserved keys
- Mixed arrays and collections are handled properly
- Empty items are skipped as expected
This commit adds test coverage for the doesntContain method, verifying it correctly returns the inverse of contains method for:
- Direct value comparison
- Key-value pair matching
- Comparison operators
- Callback functions
@mohammadrasoulasghari mohammadrasoulasghari force-pushed the test/lazy-collection-tests branch 2 times, most recently from 23e8aff to 9a25f2f Compare March 14, 2025 08:50
This commit adds test coverage for the dot method, verifying it correctly flattens multi-dimensional arrays with dot notation in keys for:
- Nested associative arrays
- Empty nested arrays
- Arrays with numeric keys
@mohammadrasoulasghari mohammadrasoulasghari force-pushed the test/lazy-collection-tests branch from 9a25f2f to f874f25 Compare March 14, 2025 08:51
@taylorotwell taylorotwell merged commit 2367af3 into laravel:12.x Mar 14, 2025
39 checks passed
@mohammadrasoulasghari mohammadrasoulasghari deleted the test/lazy-collection-tests branch March 14, 2025 17:23
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