Skip to content

Commit

Permalink
docs: update PHPUnit testing README.md with corrections #62065
Browse files Browse the repository at this point in the history
  • Loading branch information
q0rban committed Sep 17, 2024
1 parent 4dafd58 commit 3091871
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
33 changes: 33 additions & 0 deletions tests/phpunit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# PHPUnit Tests

PHPUnit is the official testing framework chosen by the core team to test our PHP code.

This documentation will assume you have a local development environment of your own choosing. For other testing workflows, such as Docker, see the [PHP: PHP Unit](https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/) handbook page.

## Setup

1. Check out the wordpress-develop repository

git clone git://develop.git.wordpress.org/ wordpress-develop
cd wordpress-develop

2. Run `composer update --with-all-dependencies`
3. Create a clean MySQL database and user. **DO NOT USE AN EXISTING DATABASE** or you will lose data, guaranteed.
4. Copy `wp-tests-config-sample.php` to `wp-tests-config.php`, edit it to include your testing database credentials.
5. Run the tests from the repository root:
- To execute a particular test:

$ vendor/bin/phpunit tests/phpunit/tests/test_case.php
- To execute all tests:

$ vendor/bin/phpunit

## Notes:

Test cases live in the `tests` subdirectory. All files in that directory will be included by default. Extend the `WP_UnitTestCase` class to ensure your test is run.

`phpunit` will initialize and install a (more or less) complete running copy of WordPress each time it is run. This makes it possible to run functional interface and module tests against a fully working database and codebase, as opposed to pure unit tests with mock objects and stubs. Pure unit tests may be used also, of course.

Changes to the test database will be rolled back as tests are finished, to ensure a clean start next time the tests are run.

`phpunit` is intended to run at the command line, not via a web server.
23 changes: 0 additions & 23 deletions tests/phpunit/README.txt

This file was deleted.

0 comments on commit 3091871

Please sign in to comment.