Signed-off-by: John Blackbourn <john@johnblackbourn.com> Signed-off-by: Andy Fragen <andy@thefragens.com> Signed-off-by: Carrie Dils <carriedils@gmail.com> Signed-off-by: Norcross <andrew.norcross@gmail.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: joedolson <joedolson@users.noreply.github.com> Signed-off-by: Joe Dolson <design@joedolson.com> Signed-off-by: Shadi Sharaf <shady@sharaf.me> Signed-off-by: Chuck Adams <chaz@chaz.works> Signed-off-by: Mika Ipstenu Epstein <ipstenu@halfelf.org> Signed-off-by: Ipstenu (Mika Epstein) <Ipstenu@users.noreply.github.com> Signed-off-by: Mika <ipstenu@halfelf.org> Signed-off-by: Mika Epstein <ipstenu@halfelf.org> Signed-off-by: Marc Armengou <83702259+marcarmengou@users.noreply.github.com> Signed-off-by: Carrie Dils <cdils@users.noreply.github.com> Co-authored-by: John Blackbourn <john@johnblackbourn.com> Co-authored-by: Chuck Adams <chaz@chaz.works> Co-authored-by: Andy Fragen <andy@thefragens.com> Co-authored-by: Norcross <andrew.norcross@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: rmccue <21655+rmccue@users.noreply.github.com> Co-authored-by: cdils <3099408+cdils@users.noreply.github.com> Co-authored-by: joedolson <joedolson@users.noreply.github.com> Co-authored-by: Joe Dolson <design@joedolson.com> Co-authored-by: Shady Sharaf <shady@sharaf.me> Co-authored-by: Mika Ipstenu Epstein <ipstenu@halfelf.org> Co-authored-by: Ipstenu (Mika Epstein) <Ipstenu@users.noreply.github.com> Co-authored-by: Marc Armengou <83702259+marcarmengou@users.noreply.github.com> Co-authored-by: Namith Jawahar <48271037+namithj@users.noreply.github.com> Co-authored-by: Kaspars Dambis <hi@kaspars.net> |
||
|---|---|---|
| .. | ||
| tests | ||
| bootstrap.php | ||
| multisite.xml | ||
| README.md | ||
Instructions
Setting up the dev environment
Option 1: wp-env
- 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
Option 2: Local web server and MySQL database:
- 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.
Running PHPUnit tests
Single Site
npm run test:php
If you're not using wp-env, you can just run composer run test.
Multisite
npm run test:php:multisite
If you're not using wp-env, you can just run composer run test:multisite.
Running PHPUnit tests with line coverage
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.
Single Site
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.
Multisite
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.
Single Site and 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.