Skip to content
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

WPCS 2.0.0: Remove unit test work-arounds for PHPCS 2.x #1558

Merged
merged 1 commit into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/phpunit.xml.dist export-ignore
/.github export-ignore
/bin export-ignore
/Test export-ignore
/WordPress/Tests export-ignore

#
Expand Down
25 changes: 9 additions & 16 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ N.B.: If you installed WPCS using Composer, make sure you used `--prefer-source`
If you already have PHPUnit installed on your system: Congrats, you're all set.

If not, you can navigate to the directory where the `PHP_CodeSniffer` repo is checked out and do `composer install` to install the `dev` dependencies.
Alternatively, you can [install PHPUnit](https://phpunit.de/manual/5.7/en/installation.html) as a PHAR file.
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/7.4/installation.html) as a PHAR file.

## Before running the unit tests

Expand All @@ -111,37 +111,30 @@ The easiest way to do this is to add a `phpunit.xml` file to the root of your WP

## Running the unit tests

The WordPress Coding Standards are compatible with both PHPCS 2.x as well as 3.x. This has some implications for running the unit tests.

* Make sure you have registered the directory in which you installed WPCS with PHPCS using;
```sh
phpcs --config-set installed_paths path/to/WPCS
```
* Navigate to the directory in which you installed WPCS.
* To run the unit tests with PHPCS 3.x:
```sh
phpunit --bootstrap="./Test/phpcs3-bootstrap.php" --filter WordPress /path/to/PHP_CodeSniffer/tests/AllTests.php
```
* To run the unit tests with PHPCS 2.x:
* To run the unit tests:
```sh
phpunit --bootstrap="./Test/phpcs2-bootstrap.php" --filter WordPress ./Test/AllTests.php
phpunit --filter WordPress --bootstrap="/path/to/PHP_CodeSniffer/tests/bootstrap.php" /path/to/PHP_CodeSniffer/tests/AllTests.php
```

Expected output:
```
PHPUnit 6.5.8 by Sebastian Bergmann and contributors.
PHPUnit 7.5.0 by Sebastian Bergmann and contributors.

Runtime: PHP 7.2.7 with Xdebug 2.6.0
Runtime: PHP 7.2.13
Configuration: /WordPressCS/phpunit.xml

................................................................. 65 / 77 ( 84%)
............ 77 / 77 (100%)
............................................................ 60 / 60 (100%)

Tests generated 576 unique error codes; 51 were fixable (8.85%)
156 sniff test files generated 490 unique error codes; 59 were fixable (12.04%)

Time: 22.93 seconds, Memory: 40.00MB
Time: 18.02 seconds, Memory: 22.00MB

OK (77 tests, 0 assertions)
OK (60 tests, 0 assertions)
```

[![asciicast](https://asciinema.org/a/98078.png)](https://asciinema.org/a/98078)
Expand Down
4 changes: 0 additions & 4 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
<arg value="sp"/>
<arg name="extensions" value="php"/>

<!-- Exclude the code in the PHPCS 2.x test files copied in from PHPCS. -->
<exclude-pattern>/Test/AllTests.php</exclude-pattern>
<exclude-pattern>/Test/Standards/*.php</exclude-pattern>
<exclude-pattern>/bin/class-ruleset-test.php</exclude-pattern>

<!-- Exclude Composer vendor directory. -->
<exclude-pattern>*/vendor/*</exclude-pattern>

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ script:
# Lint the PHP files against parse errors.
- if [[ "$LINT" == "1" ]]; then if find . -path ./vendor -prune -o -path ./bin -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi
# Run the unit tests.
- phpunit --filter WordPress $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php
- phpunit --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php
# Test for fixer conflicts by running the auto-fixers of the complete WPCS over the test case files.
# This is not an exhaustive test, but should give an early indication for typical fixer conflicts.
# For the first run, the exit code will be 1 (= all fixable errors fixed).
Expand Down
72 changes: 0 additions & 72 deletions Test/AllTests.php

This file was deleted.

Loading