-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: update PHPUnit testing README.md with corrections #62065 #7389
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For this and the |
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
2. Run `composer update --with-all-dependencies` | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Nit. |
||||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||||
Comment on lines
+18
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggest dropping the terminal prompt character. For these commands, please substitute the block formatting spaces by wrapping with three backticks for consistency with other docs (I'm unsure how to add these within a backticked suggestion block 😅). |
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
## 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. |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should instead refer to the Github repo, as PRs there are the typical way to contribute patches and tests.