Skip to content

Run PHPUnit on WordPress Playground (no Docker)#259

Open
erseco wants to merge 2 commits into
mainfrom
feature/run-phpunit-on-playground
Open

Run PHPUnit on WordPress Playground (no Docker)#259
erseco wants to merge 2 commits into
mainfrom
feature/run-phpunit-on-playground

Conversation

@erseco

@erseco erseco commented Jun 11, 2026

Copy link
Copy Markdown
Member

What

Adds a make test-playground target that runs Decker's PHPUnit integration suite on WordPress Playground (WebAssembly PHP + SQLite) — no Docker required. Docker make test is 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-cache flock deadlocks). Setting WP_TESTS_SKIP_INSTALL=1 makes 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-test START TRANSACTION/ROLLBACK isolation WP_UnitTestCase relies on (verified).

Changes

  • composer.json: add wp-phpunit/wp-phpunit dev dependency (provides WP_TESTS_DIR without the Docker container).
  • tests/bootstrap-playground.php: thin shim — sets WP_TESTS_SKIP_INSTALL, points WP_TESTS_DIR / polyfills, forces a minimal theme (avoids block-theme doing_it_wrong), then delegates to the existing tests/bootstrap.php (unchanged).
  • phpunit-playground.xml.dist + make test-playground (same FILE= / FILTER= options as make test).
  • README.md: testing docs.

Usage

make test-playground
make test-playground FILE=tests/integration/DeckerKnowledgeBaseIntegrationTest.php
make test-playground FILTER=test_cpt_registration

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.

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.
@github-actions

Copy link
Copy Markdown

WordPress Playground Preview

The changes in this pull request can previewed and tested using a WordPress Playground instance.

Open WordPress Playground Preview

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`).
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.

1 participant