mirror of
https://gh.wpcy.net/https://github.com/WordPress/WordPress-Coding-Standards.git
synced 2026-04-24 23:58:18 +08:00
A `dev` requirement of `phpunit/phpunit` has been added to the `composer.json` file, as well as a script to run the unit tests.
While PHPUnit is not strictly speaking a dependency of WPCS (but of PHPCS), this just makes life easier on WPCS developers who use the Composer install for development.
If - as a WPCS sniff developer - you've installed WPCS using Composer, you can now run the unit tests, like so:
```bash
composer run-tests
```
A note to this effect has been added to the `CONTRIBUTING.MD` file as well.
Additionally:
* While not strictly necessary, a `testsuite` directive has been added to the `phpunit.xml.dist` file to document where the tests are located and how they are named.
* As `PHPCompatibility` will also be installed when using Composer to install WPCS and PHPCompatibility uses its own test setup, we need to prevent PHPCS from trying to load the test files for PHPCompatibility.
The `PHPCS_IGNORE_TEST` environment variable in the `phpunit.xml.dist` file does just that.
For more information about this, see squizlabs/PHP_CodeSniffer 1146
21 lines
726 B
XML
21 lines
726 B
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<phpunit
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd"
|
|
backupGlobals="true"
|
|
beStrictAboutTestsThatDoNotTestAnything="false"
|
|
colors="true">
|
|
|
|
<testsuites>
|
|
<testsuite name="WordPress">
|
|
<directory suffix="UnitTest.php">./WordPress/Tests/</directory>
|
|
</testsuite>
|
|
</testsuites>
|
|
|
|
<php>
|
|
<!-- This line prevents issues with PHPCS trying to load sniff files for
|
|
standards which we aren't testing.
|
|
Ref: https://github.com/squizlabs/PHP_CodeSniffer/pull/1146 -->
|
|
<env name="PHPCS_IGNORE_TESTS" value="Generic,MySource,PEAR,PSR1,PSR2,PSR12,Squiz,Zend,PHPCompatibility"/>
|
|
</php>
|
|
</phpunit>
|