tn-xfive/wp-unit-tests-scaffold

Scaffold PHPUnit tests setup for WordPress themes and plugins.

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/tn-xfive/wp-unit-tests-scaffold

v1.1.1 2026-01-19 09:09 UTC

This package is auto-updated.

Last update: 2026-02-19 09:23:53 UTC


README

Tests setup and boilerplate for testing WordPress with PHPUnit.

Usage in projects

To start using PHPUnit for unit testing in WordPress first install PHPUnit in your project (prefereably with Composer: composer require --dev phpunit/phpunit:"^9.5", see https://docs.phpunit.de/en/12.4/installation.html#composer). We need version 9.5 to be compatible with WordPress tests SDK.

Then install WordPress tests SDK with composer require --dev wp-phpunit/wp-phpunit:"^6.9" and composer require --dev yoast/phpunit-polyfills:"^2.0".

Then navigate to your project root and run the following commands:

  1. composer require --dev tn-xfive/wp-unit-tests-scaffold
  2. vendor/bin/scaffold

See wp-tests-config-sample.php file in /tests directory and edit it as instructed.

We are assuming here, that your project root is a WordPress theme or a plugin. If the root is a different folder, then after installation adjust tests/bootstrap.php accordingly to point to a proper wp-load.php location.

Test file boilerplate

There is a boilerplate test file prefilled with some handy test case examples. You can copy them elsewhere and populate the file with your own tests.