Skip to content

Extract abstract MultiQueryParserTestCase to remove test duplication#45

Merged
JanTvrdik merged 1 commit intomainfrom
refactor/extract-base-test-case
Feb 24, 2026
Merged

Extract abstract MultiQueryParserTestCase to remove test duplication#45
JanTvrdik merged 1 commit intomainfrom
refactor/extract-base-test-case

Conversation

@JanTvrdik
Copy link
Copy Markdown
Member

Summary

  • Extract shared test methods into abstract MultiQueryParserTestCase base class in tests/inc/
  • Individual parser tests now contain only data providers and parser-specific overrides (e.g. testFile() with specific query assertions, MySQL's testDelimiter())
  • Move test SQL data files from tests/cases/data/ to tests/data/

Test plan

  • All 64 tests pass

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/.
Copilot AI review requested due to automatic review settings February 24, 2026 06:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MultiQueryParserTestCase with common test methods (testSuperfluousSemicolons, testEdgeCases, testChunkBoundary, testFile, testFileWithRandomizedChunking, testFileWithAllTwoChunkCombinations, testParseFileThrowsOnNonExistentFile) and helper method randomChunks()
  • Refactored MySqlMultiQueryParserTest, PostgreSqlMultiQueryParserTest, and SqlServerMultiQueryParserTest to 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.

@JanTvrdik JanTvrdik merged commit a40b76d into main Feb 24, 2026
16 checks passed
@JanTvrdik JanTvrdik deleted the refactor/extract-base-test-case branch February 24, 2026 06:37
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