[13.x] Add comprehensive integration tests for DatePeriod support in whereBetween/havingBetween#58839
Closed
mosabbirrakib wants to merge 1 commit intolaravel:masterfrom
Closed
Conversation
…whereBetween/havingBetween This PR adds comprehensive integration tests for the DatePeriod support that was added in PR laravel#58687. ## Problem While PR laravel#58687 added DatePeriod support to whereBetween() and havingBetween() methods with unit tests, it lacks comprehensive integration tests that verify the feature works correctly with real database queries. ## Solution This PR adds comprehensive integration tests in QueryBuilderDatePeriodTest.php that test all DatePeriod scenarios with actual database queries: - whereBetween with DatePeriod - whereBetween with CarbonPeriod - whereBetween with recurrences (no end date) - whereBetween with EXCLUDE_START_DATE flag - whereBetween with INCLUDE_END_DATE flag - whereBetween with both flags combined - whereNotBetween with DatePeriod - whereNotBetween with EXCLUDE_START_DATE flag - havingBetween with DatePeriod (grouped queries) - havingNotBetween with DatePeriod - orWhereBetween with DatePeriod - orWhereNotBetween with DatePeriod ## Benefits to End Users These integration tests ensure that: 1. DatePeriod works correctly with real database queries 2. All edge cases are covered (recurrences, inclusion/exclusion flags) 3. The feature works across different database drivers 4. Future changes won't break DatePeriod support ## Breaking Changes None. This only adds tests for existing functionality. Relates to laravel#58092
Contributor
Author
|
Closing to create a new PR with complete implementation including Builder.php changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds comprehensive integration tests for the DatePeriod support that was added in PR #58687.
Problem
While PR #58687 added DatePeriod support to
whereBetween()andhavingBetween()methods with unit tests, it lacks comprehensive integration tests that verify the feature works correctly with real database queries across different scenarios and edge cases.Solution
This PR adds comprehensive integration tests in
QueryBuilderDatePeriodTest.phpthat test all DatePeriod scenarios with actual database queries.Tests Added
whereBetween Tests:
✅ whereBetween with DatePeriod - Basic DatePeriod with start and end dates
✅ whereBetween with CarbonPeriod - Laravel's Carbon extension of DatePeriod
✅ whereBetween with recurrences - DatePeriod using recurrence count instead of end date
✅ whereBetween with EXCLUDE_START_DATE flag - Tests the
DatePeriod::EXCLUDE_START_DATEflag✅ whereBetween with INCLUDE_END_DATE flag - Tests the
DatePeriod::INCLUDE_END_DATEflag✅ whereBetween with both flags - Tests both inclusion/exclusion flags combined
whereNotBetween Tests:
✅ whereNotBetween with DatePeriod - NOT BETWEEN with DatePeriod
✅ whereNotBetween with EXCLUDE_START_DATE - NOT BETWEEN respecting exclusion flags
havingBetween Tests:
✅ havingBetween with DatePeriod - HAVING BETWEEN with grouped queries
✅ havingNotBetween with DatePeriod - HAVING NOT BETWEEN with grouped queries
Logical Operators:
✅ orWhereBetween with DatePeriod - OR WHERE BETWEEN with DatePeriod
✅ orWhereNotBetween with DatePeriod - OR WHERE NOT BETWEEN with DatePeriod
Test Structure
All tests use real database queries with actual data:
Each test verifies:
Benefits to End Users
These integration tests ensure that:
Why Integration Tests?
As Taylor mentioned in his feedback on PR #58480:
Integration tests are preferred because they:
Breaking Changes
None. This PR only adds tests for existing functionality that was merged in PR #58687.
Code Changes
tests/Integration/Database/QueryBuilderDatePeriodTest.php(268 lines)Relates to #58092