Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Documented PHPUnit Test File Inclusion
  • Loading branch information
ObliviousHarmony committed Jul 14, 2022
commit 3650a2dbe01f933588f90d2f4bd88d56c898d785
14 changes: 14 additions & 0 deletions packages/env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ wp-env start --debug
...
```

## Using included WordPress PHPUnit test files

Out of the box `wp-env` includes the [WordPress' PHPUnit test files](https://develop.svn.wordpress.org/trunk/tests/phpunit/) corresponding to the version of WordPress installed. There is an environment variable, `WP_TESTS_DIR`, which points to the location of these files within each container. By including these files in the environment, we remove the need for you to use a package or install and mount them yourself.

### Custom `wp-tests-config.php` file

WordPress provides a `WP_TESTS_CONFIG_FILE_PATH` constant that you can use to change the `wp-config.php` file used for testing. Set this to a desired path in your `bootstrap.php` file and the file you've chosen will be used instead of the one included in the environment.

### Using `wp-phpunit/wp-phpunit`

By including these test files, we remove the need for using packages like `wp-phpunit/wp-phpunit`. One of the issues with the package approach is that the version of the test files it includes may not correspond to the version of WordPress in the container. We solve this by instead reading the version of WordPress installed and downloading the files _for that version_.

However, if you would still like to use a package, you can do so by not using the `WP_TESTS_DIR` environment variable in your `bootstrap.php`. If this is not an option, you can also set the environment variable to an empty string in your `phpunit.xml` file. You will also need to set the `WP_PHPUNIT__TESTS_CONFIG` environment variable to a custom `wp-tests-config.php` file for your test suite.

## Using Xdebug

Xdebug is installed in the wp-env environment, but it is turned off by default. To enable Xdebug, you can use the `--xdebug` flag with the `wp-env start` command. Here is a reference to how the flag works:
Expand Down