Skip to content

Make Behat scenarios SQLite-compatible#138

Open
abhi3315 wants to merge 2 commits intowp-cli:mainfrom
abhi3315:fix/112-sqlite-compatibility
Open

Make Behat scenarios SQLite-compatible#138
abhi3315 wants to merge 2 commits intowp-cli:mainfrom
abhi3315:fix/112-sqlite-compatibility

Conversation

@abhi3315
Copy link
Copy Markdown

Fixes #112

Two Behat scenarios fail under WP_CLI_TEST_DBTYPE=sqlite because their fixtures use MySQL-only features. The command source already uses portable SQL — only the tests needed fixing.

Changes

  • Scenario: Export posts from a given starting post ID — replaced hardcoded --start_id=6 with wp post list --offset=5 --posts_per_page=1 --format=ids. SQLite doesn't reset auto-increment on wp site empty, so the generated IDs aren't always 1..10 and the hardcoded value matched 8 posts instead of 5.
  • Scenario: Export without splitting the dump — swapped wp db query "... REPEAT('A', 4*1024*1024)" for wp eval "update_post_meta(1, '_dummy_N', str_repeat('A', 4*1024*1024))". SQLite has no REPEAT() function.

Both scenarios drop their @require-mysql tag.

19 other scenarios in this file still carry @require-mysql. They all pass under SQLite today if the tag is stripped (I verified by running the full suite with tags removed), but opening them up is a CI coverage change rather than a bug fix — separate concern, easier to review on its own, so I left them for a follow-up PR.

Related: wp-cli/.github#94

@abhi3315 abhi3315 requested a review from a team as a code owner April 13, 2026 06:02
@github-actions
Copy link
Copy Markdown
Contributor

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions bot added scope:distribution Related to distribution scope:testing Related to testing labels Apr 13, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances SQLite compatibility for export feature tests by removing MySQL-specific tags and replacing SQL-specific functions with PHP equivalents via wp eval. It also implements dynamic post ID lookups to handle non-sequential auto-increment behavior. Feedback was provided to consolidate multiple wp eval calls into a single command to optimize performance by reducing WordPress bootstrap overhead.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

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

Updates the Behat acceptance tests for the export command to run successfully under WP_CLI_TEST_DBTYPE=sqlite by removing MySQL-specific assumptions in two scenarios.

Changes:

  • Makes the “starting post ID” export scenario deterministic by deriving the start ID from the generated posts instead of hardcoding it.
  • Replaces a MySQL-only REPEAT() usage in a fixture with a SQLite-compatible wp eval + str_repeat() approach.
  • Removes @require-mysql from the two affected scenarios so they execute under SQLite.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@swissspidy
Copy link
Copy Markdown
Member

With this PR, all the MySQL 5.6/5.7 are timing out. This needs investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:distribution Related to distribution scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite Compatibility

3 participants