From af6323f97b9cda56ef0e55bc96c152299b687815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9sz=C3=A1ros=20R=C3=B3bert?= Date: Tue, 4 Aug 2026 11:54:04 +0300 Subject: [PATCH 1/5] Update @wordpress/scripts dep version to latest tag --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f74924..85d97b7 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "lint:md:fix": "wp-scripts lint-md-docs README.md docs/**/*.md -- --fix" }, "devDependencies": { - "@wordpress/scripts": "wp-6.9" + "@wordpress/scripts": "wp-7.0" }, "engines": { "node": "~24.0" From 9435286e05f750049fd2f4cb404259068cd57d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9sz=C3=A1ros=20R=C3=B3bert?= Date: Tue, 4 Aug 2026 11:55:23 +0300 Subject: [PATCH 2/5] Update readme with new info and slight wording tweaks --- README.md | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 65bc4b7..de83265 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,18 @@ # WP PHPUnit Integration -The WP PHPUnit Integration package helps you write PHPUnit tests for your WordPress packages where you prefer to have the actual implementation of WordPress functions and classes available, rather than mocking them with a library such as [Brain Monkey](https://github.com/Brain-WP/BrainMonkey). +This package helps you write PHPUnit tests for your WordPress packages where you prefer to have the actual implementation of WordPress functions and classes available, rather than mocking them with a library such as [Brain Monkey](https://github.com/Brain-WP/BrainMonkey). -Depending on your intent for your tests, it is ideal for functional or integration tests, where you can also take advantage of the database. +Depending on your intent, it is ideal for functional or integration tests, where you can also take advantage of the database. -Once you require and configure this package, it will set up a fully functional WordPress environment before the tests are run, install WordPress, symlink and activate your plugin or theme, and reset everything once the tests have finished. +Once you require and configure WP PHPUnit Integration, it will set up a fully functional WordPress environment before the tests are run (installing WordPress, symlinking and activating your plugin or theme, etc.), and reset everything once the tests have finished. -All you need is PHP. You don't need a test database service running such as MySQL or MariaDB, or to configure and start Docker containers, as this package also takes advantage of the [SQLite Database Integration](https://github.com/WordPress/sqlite-database-integration). +All you need is PHP. You don't need a database service running, such as MySQL or MariaDB, for your tests, or to configure and start Docker containers, as this package also takes advantage of the [SQLite Database Integration](https://github.com/WordPress/sqlite-database-integration). ## Setup and usage +> [!WARNING] +> This package is currently in a pre-stable release. Breaking changes may occur between versions until a stable `1.0` release is published. + ### Installation You can require this package with Composer: @@ -39,13 +42,13 @@ You can also specify where you want to install WordPress by adding the following } ``` -No fixed location is required, as the WP PHPUnit Integration will automatically detect the location. +No fixed location is required, as WP PHPUnit Integration will automatically try to detect the location. ### Setup You can use WP PHPUnit Integration for all your PHPUnit tests. -However, if you already have unit tests where you use Brain Monkey, we recommend creating separate PHPUnit configuration and bootstrap files for your integration tests, as these files can quickly grow complex over time and become messy. +However, if you already have unit tests where you use, for example, Brain Monkey, we recommend creating separate PHPUnit configuration and bootstrap files for your integration tests, as these files can quickly grow complex over time and become messy. The following steps describe this scenario. @@ -146,7 +149,6 @@ WP PHPUnit Integration has three distinct phases that you can customize. The `setup` and `cleanup` phases run only once, before and after all tests are executed. As their names suggest, they trigger steps such as creating the `wp-config.php`, setting up required constants, or undoing these actions. - The `load` phase is called before both the main test process and any child processes. When the test is run in isolation, `load` is called multiple times, either before the [test class](https://docs.phpunit.de/en/10.5/attributes.html#runtestsinseparateprocesses) or [test method](https://docs.phpunit.de/en/10.5/attributes.html#runinseparateprocess), depending on your PHPUnit [configuration](https://docs.phpunit.de/en/10.5/configuration.html#the-processisolation-attribute). Each phase can be customized by running additional logic before or after the defaults, or by replacing it entirely. @@ -159,17 +161,17 @@ use Syde\WpPhpUnitIntegration\WpTestEnv; Bootstrap::init( $packagePath, new BootstrapLifecycle( - setup: function () { + setup: function (): void { // Run some setup tasks before the default ones. WpTestEnv::setup(); }, - load: function () use ($packagePath) { + load: function () use ($packagePath): void { // Omit the default WpTestEnv::load() to use your own custom logic. include "{$packagePath}/vendor/roots/wordpress/wp-load.php"; }, - cleanup: function () { + cleanup: function (): void { WpTestEnv::cleanup(); // Run some extra cleanup tasks after the default ones. @@ -184,7 +186,7 @@ For convenience, `WpTestEnv` exposes some helper methods to cover most customiza #### WP-CLI commands -`runWpCliCommand` triggers a call to WP-CLI without returning any output from it: +With `runWpCliCommand`, you can run arbitrary WP-CLI commands: ```php WpTestEnv::runWpCliCommand([ @@ -194,6 +196,8 @@ WpTestEnv::runWpCliCommand([ ]); ``` +`runWpCliCommand` returns the `stdout` output, and if an error occurs, an exception is thrown with the error message returned by WP-CLI. + You can use any WP-CLI commands, but keep in mind that they are called with the `--skip-plugins,` `--skip-themes,` and an explicit `--path` option. #### Early hooks @@ -213,17 +217,19 @@ WpTestEnv::addEarlyFilter( ### WordPress version -To quickly test against multiple WordPress versions, set the `WP_PHPUNIT_INTEGRATION_WP_CORE_VERSION` (or simply `WP_CORE_VERSION`) environment variable. When provided, the setup process will automatically update WordPress to that specific version. +To quickly test against multiple WordPress versions, you can set the `WP_PHPUNIT_INTEGRATION_WP_CORE_VERSION` (or simply `WP_CORE_VERSION`) environment variable. When provided, the setup process will automatically update WordPress to that specific version. ```shell WP_PHPUNIT_INTEGRATION_WP_CORE_VERSION=6.8 composer run tests:integration:no-cov ``` -This environment variable is optional. Without it, the already-installed WordPress version is used. +This environment variable is optional. Without it, the already-installed WordPress version is used without attempting to update it using WP-CLI. #### Multiple WordPress versions in GitHub Actions -To take advantage of the environment variable in GitHub Actions, amend your existing workflow as follows: +You can take advantage of this environment variable in GitHub Actions to run tests against multiple WordPress versions. + +To do this, amend the [previously mentioned workflow](#github-actions) as follows: ```yaml jobs: @@ -247,8 +253,7 @@ jobs: ## Copyright and License -This package is [open-source software](https://opensource.org/license/MIT) distributed under -the terms of the MIT License. For the full license, see [LICENSE](./LICENSE). +This package is [open-source software](https://opensource.org/license/MIT) distributed under the terms of the MIT License. For the full license, see [LICENSE](./LICENSE). ## Contributing From f8dc6ff2b24e33749f848373fa562d470f9ce947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9sz=C3=A1ros=20R=C3=B3bert?= Date: Tue, 4 Aug 2026 11:58:29 +0300 Subject: [PATCH 3/5] Update composer repos --- composer.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 6d5ca73..5eb2113 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "symfony/finder": ">=7.4", "symfony/process": ">=7.4", "wecodemore/wordpress-early-hook": "^1.4", - "wpackagist-plugin/sqlite-database-integration": "2.2.23" + "wp-plugin/sqlite-database-integration": "2.2.23" }, "require-dev": { "ergebnis/composer-normalize": "^2.51", @@ -37,11 +37,9 @@ }, "repositories": [ { + "name": "wp-packages", "type": "composer", - "url": "https://repo.packagist.com/inpsyde/" - }, - { - "packagist.org": false + "url": "https://repo.wp-packages.org" } ], "minimum-stability": "dev", From 0cc750bcef3089b4f2f52518df6784e78494d857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9sz=C3=A1ros=20R=C3=B3bert?= Date: Tue, 4 Aug 2026 17:42:11 +0300 Subject: [PATCH 4/5] Small readme tweaks --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index de83265..de04c67 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ All you need is PHP. You don't need a database service running, such as MySQL or ### Installation -You can require this package with Composer: +As a first step, require this package with Composer: ```shell composer require --dev syde/wp-phpunit-integration @@ -79,7 +79,7 @@ unset($packagePath, $vendorPath); #### PHPUnit configuration -Create a `/phpunit-integration.xml.dist` file with the following content: +Next, create a `/phpunit-integration.xml.dist` file with the following content: ```xml Date: Wed, 5 Aug 2026 16:46:28 +0300 Subject: [PATCH 5/5] Switch to wpackagist --- composer.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 5eb2113..0f46061 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "symfony/finder": ">=7.4", "symfony/process": ">=7.4", "wecodemore/wordpress-early-hook": "^1.4", - "wp-plugin/sqlite-database-integration": "2.2.23" + "wpackagist-plugin/sqlite-database-integration": "2.2.23" }, "require-dev": { "ergebnis/composer-normalize": "^2.51", @@ -37,9 +37,13 @@ }, "repositories": [ { - "name": "wp-packages", + "name": "wpackagist", "type": "composer", - "url": "https://repo.wp-packages.org" + "url": "https://wpackagist.org", + "only": [ + "wpackagist-plugin/*", + "wpackagist-theme/*" + ] } ], "minimum-stability": "dev",