Manual:PHP unit testing
<translate> PHPUnit testing</translate>
<translate> Contents</translate>
- <translate> Running the tests</translate>
- <translate> Generate code coverage</translate>
- Writing testable PHP code
- <translate> Writing tests</translate>
- <translate> Continuous integration</translate>
- <translate> Understanding build failures</translate>
- <translate> Appendix</translate>
(<translate> how to help, resources..</translate>)
<translate> Tools</translate> <translate>
</translate>
Introduction
We do unit and integration testing of MediaWiki's PHP code base using the PHPUnit framework. View MediaWiki core's test coverage.
MediaWiki core's PHP unit and integration tests are in the tests/phpunit
directory.
When adding new tests, unit tests should be placed in tests/phpunit/unit
and integration tests should be placed in tests/phpunit/integration
The directory structure roughly matches that of the code being tested.
For example: you can find the unit tests for file includes/libs/JavaScriptMinifier.php
in tests/phpunit/unit/includes/libs/JavaScriptMinifierTest.php
.
Extensions should have PHPUnit tests in a tests/phpunit
subdirectory, using subdirectories to separate unit and integration tests, e.g. extensions/{extensionName}/tests/phpunit/unit
and extensions/{extensionName}/tests/phpunit/integration
.
Use the navigation table or the links below to browse through this manual.