Extract abstract MultiQueryParserTestCase to remove test duplication#45
Merged
Extract abstract MultiQueryParserTestCase to remove test duplication#45
Conversation
Move shared test methods (testSuperfluousSemicolons, testEdgeCases, testChunkBoundary, testFile, testFileWithRandomizedChunking, testFileWithAllTwoChunkCombinations, testParseFileThrowsOnNonExistentFile) and the randomChunks helper into an abstract base class. Individual parser tests now contain only data providers and parser-specific overrides. Also move test SQL data files from tests/cases/data/ to tests/data/.
There was a problem hiding this comment.
Pull request overview
This PR refactors the multi-query parser test suite to eliminate duplication by extracting common test methods into an abstract MultiQueryParserTestCase base class. The refactoring also reorganizes the file structure by moving SQL test data files from tests/cases/data/ to tests/data/.
Changes:
- Created abstract
MultiQueryParserTestCasewith common test methods (testSuperfluousSemicolons,testEdgeCases,testChunkBoundary,testFile,testFileWithRandomizedChunking,testFileWithAllTwoChunkCombinations,testParseFileThrowsOnNonExistentFile) and helper methodrandomChunks() - Refactored
MySqlMultiQueryParserTest,PostgreSqlMultiQueryParserTest, andSqlServerMultiQueryParserTestto extend the base class and provide only data providers and parser-specific test overrides - Moved SQL test data files to a dedicated
tests/data/directory
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/inc/MultiQueryParserTestCase.php | New abstract base class containing common test methods, abstract method declarations for parser creation and data providers, and shared helper methods |
| tests/data/sqlserver.sql | SQL Server test data file moved from tests/cases/data/ with schema definitions, sample data, and edge cases for SQL Server-specific syntax |
| tests/data/postgres.sql | PostgreSQL test data file moved from tests/cases/data/ with schema definitions, sample data, and PostgreSQL-specific features like dollar-quoted strings |
| tests/data/mysql.sql | MySQL test data file moved from tests/cases/data/ with schema definitions, sample data, and MySQL-specific features like backtick identifiers and hash comments |
| tests/cases/SqlServerMultiQueryParserTest.phpt | Refactored to extend base class, implements abstract methods, retains SQL Server-specific testFile() override with trigger assertion |
| tests/cases/PostgreSqlMultiQueryParserTest.phpt | Refactored to extend base class, implements abstract methods, retains PostgreSQL-specific testFile() override with function assertion |
| tests/cases/MySqlMultiQueryParserTest.phpt | Refactored to extend base class, implements abstract methods, retains MySQL-specific testDelimiter() test |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
MultiQueryParserTestCasebase class intests/inc/testFile()with specific query assertions, MySQL'stestDelimiter())tests/cases/data/totests/data/Test plan