Run PHPUnit on WordPress Playground (no Docker)#259
Open
erseco wants to merge 2 commits into
Open
Conversation
Add a `make test-playground` target that runs Decker's integration suite under WordPress Playground (WebAssembly PHP on SQLite) without Docker. The WordPress test library installs WP by spawning `system(php install.php)`, which can't run inside Playground's WASM process model (mounted files aren't visible to the child and opcache's file-cache flock deadlocks). Setting WP_TESTS_SKIP_INSTALL=1 reuses the WordPress instance Playground already boots in-process on SQLite, so no subprocess is needed. - composer: add wp-phpunit/wp-phpunit dev dependency (provides WP_TESTS_DIR without the Docker container) - tests/bootstrap-playground.php: thin shim that sets WP_TESTS_SKIP_INSTALL, points WP_TESTS_DIR / polyfills, forces a minimal theme, then delegates to the existing tests/bootstrap.php (unchanged) - phpunit-playground.xml.dist + Makefile `test-playground` target (same FILE / FILTER options as `make test`) Docker `make test` is unchanged and remains the default.
Adds an `up-playground` target that boots a WordPress Playground dev server (WebAssembly + SQLite, no Docker) via @wp-playground/cli, alongside the existing Docker `make up`. Establishes the convention: `up` = Docker, `up-playground` = Playground (consistent with `make test` / `make test-playground`).
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.
What
Adds a
make test-playgroundtarget that runs Decker's PHPUnit integration suite on WordPress Playground (WebAssembly PHP + SQLite) — no Docker required. Dockermake testis unchanged and stays the default.Why
The WordPress test library installs WP by spawning
system(php install.php). That nested child process doesn't work under Playground's WASM model (mounted files aren't visible to spawned children, and opcache's file-cacheflockdeadlocks). SettingWP_TESTS_SKIP_INSTALL=1makes the WP test bootstrap reuse the WordPress instance Playground already boots in-process on SQLite, so no subprocess is needed. SQLite's AST driver supports the per-testSTART TRANSACTION/ROLLBACKisolationWP_UnitTestCaserelies on (verified).Changes
composer.json: addwp-phpunit/wp-phpunitdev dependency (providesWP_TESTS_DIRwithout the Docker container).tests/bootstrap-playground.php: thin shim — setsWP_TESTS_SKIP_INSTALL, pointsWP_TESTS_DIR/ polyfills, forces a minimal theme (avoids block-themedoing_it_wrong), then delegates to the existingtests/bootstrap.php(unchanged).phpunit-playground.xml.dist+make test-playground(sameFILE=/FILTER=options asmake test).README.md: testing docs.Usage
Notes
A few integration tests that depend on MySQL-specific behaviour may still need the Docker runner. Upstream tracking for the subprocess limitation: WordPress/wordpress-playground#3783.