Closed gedex closed 11 years ago
@gedex could you add a section to the README for how to run the test suite?
I tried:
$ phpunit Tests/
But I got:
PHP Fatal error: Class 'AbstractSniffUnitTest' not found in …/WordPress/Tests/Arrays/ArrayDeclarationUnitTest.php on line 32
You need to run in it from PHP_CodeSniffer
root dir where you checkout'ed from https://github.com/squizlabs/PHP_CodeSniffer/. The dir structure is a little bit different if you install PHP_CodeSniffer
via PEAR and it doesn't include tests
dir.
The test must run all tests via:
phpunit tests/AllTests.php
And you would see something like:
PHPUnit @package_version@ by Sebastian Bergmann.
............................................................... 63 / 233 ( 27%)
............................................................... 126 / 233 ( 54%)
.................................................SS............ 189 / 233 ( 81%)
.........................................S..
Time: 7 seconds, Memory: 38.75Mb
OK, but incomplete or skipped tests!
Tests: 233, Assertions: 150, Skipped: 3.
I don't see a way to run the test per standard or per snif. To test if the WordPress tests are included properly, try failing one of the test. The basic rule for PHP_CodeSniffer test is to supply line number of errors or warnings of *.inc
associated file.
Currently PHP_CodeSniffer has 233 tests and if we include WordPress tests it will be 248 tests.
@gedex Thanks a lot for walking me through things over Skype! So I think the last piece this needs before merging is some documentation for how to actually run the tests, like what we went over while chatting. Please add a commit to the pull request which adds a section to the readme for how to run the unit tests. For example, the section could include some commands for getting the project space set up:
mkdir phpcs
git clone git@github.com:squizlabs/PHP_CodeSniffer.git .
git checkout 1.4.4
git clone git@github.com:x-team/WordPress-Coding-Standards.git CodeSniffer/Standards/WordPress
phpunit tests/AllTests.php
Also, we need a way to just run the tests that are associated with the the WordPress Coding Standards. Perhaps there could be an AllTests.php
located in our Tests
directory? Perhaps that would allow us to avoid having to clone our repo inside of the PHP_CodeSniffer repo?
@westonruter Instructions added to README. I'm not sure if we should put AllTests.php
in Tests
dir, because at some point we might have WordPress-Coding-Standards
project submitted to PHP_CodeSniffer
repo? If we're using PHP_CodeSniffer
convention in writing unit tests it will eventually help PHP_CodeSniffer
developer to test the code before merging in.
I would be happy to make it easy to run the tests ignoring assumption we're going to submit PR to PHP_CodeSniffer
. Here's an example of how cakephp using their own unit tests structure: https://github.com/cakephp/cakephp-codesniffer .
Just found a way to run the tests that only run WordPress Standards. Props opensky at https://github.com/opensky/Symfony2-coding-standard
$ phpunit --filter WordPress tests/AllTests.php
PHPUnit 3.7.18 by Sebastian Bergmann.
...............
Time: 0 seconds, Memory: 20.75Mb
OK (15 tests, 0 assertions)
This should fix #21