Skip to content

Add comprehensive tests for DibiFluentMssqlDataSource#1287

Open
ohmyfelix wants to merge 3 commits into
fix/mssql-applyfiltertext-nn-escapingfrom
claude/test-mssql-datasource-0MNv8
Open

Add comprehensive tests for DibiFluentMssqlDataSource#1287
ohmyfelix wants to merge 3 commits into
fix/mssql-applyfiltertext-nn-escapingfrom
claude/test-mssql-datasource-0MNv8

Conversation

@ohmyfelix
Copy link
Copy Markdown
Contributor

Summary

This PR adds a comprehensive test suite for the DibiFluentMssqlDataSource class, covering SQL generation, filtering, sorting, and pagination functionality specific to MSSQL databases.

Key Changes

  • New test file: DibiFluentMssqlDataSourceTest.phpt with 8 test cases covering:
    • testGetCountRemovesOrderBy() - Verifies that getCount() removes ORDER BY clauses without affecting the original data source
    • testFilterOneDoesNotAddLimit() - Ensures filterOne() applies WHERE conditions without adding LIMIT
    • testLimitBuildsMssqlOffsetFetchSql() - Validates MSSQL-specific OFFSET/FETCH NEXT pagination syntax
    • testApplyFilterDate() - Tests date filtering with CONVERT() function for MSSQL format
    • testApplyFilterDateWithInvalidValue() - Ensures invalid dates don't modify the SQL query
    • testApplyFilterDateRangeFrom() - Tests date range filtering with only "from" date
    • testApplyFilterDateRangeTo() - Tests date range filtering with only "to" date
    • testApplyFilterDateRangeBoth() - Tests date range filtering with both dates

Notable Implementation Details

  • Uses SQLite in-memory database for testing (compatible with test environment)
  • Tests verify MSSQL-specific SQL patterns like CONVERT(varchar(10), ..., 112) for date formatting
  • Validates that MSSQL uses OFFSET ... ROWS FETCH NEXT ... ROWS ONLY instead of LIMIT
  • Includes edge cases like invalid date values and partial date ranges

https://claude.ai/code/session_014b98nLjqaV4knQWvMChyTD

claude added 2 commits March 31, 2026 06:33
- Test file extending BaseDataSourceTest with all standard data source tests
- MSSQL-specific tests: FilterDate (CONVERT format 112), FilterDateRange,
  getCount with ORDER BY removal, limit with OFFSET/FETCH syntax
- Docker Compose file for local MSSQL Server 2022 development
- GitHub Actions workflow with MSSQL service container and sqlsrv extension
- Connection config INI for test data provider (matching Nextras pattern)
- Graceful skip when sqlsrv/pdo_sqlsrv extension is not available

https://claude.ai/code/session_014b98nLjqaV4knQWvMChyTD
…g real DB

Remove Docker/MSSQL infrastructure and use SQLite in-memory with Dibi to verify
the MSSQL-specific SQL patterns (CONVERT, OFFSET/FETCH, ORDER BY removal)
via string assertions on the generated queries.

https://claude.ai/code/session_014b98nLjqaV4knQWvMChyTD
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.64%. Comparing base (b8ded78) to head (ca75803).

Additional details and impacted files
@@                            Coverage Diff                            @@
##           fix/mssql-applyfiltertext-nn-escaping    #1287      +/-   ##
=========================================================================
+ Coverage                                  46.19%   46.64%   +0.45%     
=========================================================================
  Files                                         52       53       +1     
  Lines                                       2680     2714      +34     
=========================================================================
+ Hits                                        1238     1266      +28     
- Misses                                      1442     1448       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Extract createDataSource() helper to remove repetition
- Drop unused events table and $ds property
- Remove self-referential limit test assertion
- Use proper Datagrid import instead of FQCN
- Remove redundant comments

https://claude.ai/code/session_014b98nLjqaV4knQWvMChyTD
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