- Copy
wp-tests-config-sample.phptowp-tests-config.php. - Ensure Docker is installed and running.
- Run
npm i - Run
npm run env start - Run
npm run test:php:install-deps
- Run
composer install - Create a new database using
mysql -u<username> -p->CREATE DATABASE <database_name>;->exit;- Note: Don't use an existing database - the database is reset before every test run by default.
- Copy
wp-tests-config-sample.phptowp-tests-config.php. - Ensure that
DB_NAME,DB_USER,DB_PASSWORD, andDB_HOSTinwp-tests-config.phpmatch your setup. - Run
./bin/install-wp-tests.shwith the appropriate credentials.
npm run test:php
If you're not using wp-env, you can just run composer run test.
npm run test:php:multisite
If you're not using wp-env, you can just run composer run test:multisite.
First, start the environment with xDebug:
npm run env start -- --xdebug=coverage
If you're not using wp-env, make sure the xDebug PHP module is installed and enabled.
npm run coverage:php:single
If you're not using wp-env, you can just run composer run coverage:single.
A coverage report will be available at /tests/phpunit/coverage/html/single-site.
npm run coverage:php:multisite
If you're not using wp-env, you can just run composer run coverage:multisite.
A coverage report will be available at /tests/phpunit/coverage/html/multisite.
npm run coverage:php:full
If you're not using wp-env, you can just run composer run coverage:full.
A merged coverage report will be available at /tests/phpunit/coverage/html/full.