PHPackages                             chr0n1x/php\_codesniffer\_tests - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. chr0n1x/php\_codesniffer\_tests

ActiveLibrary[Testing &amp; Quality](/categories/testing)

chr0n1x/php\_codesniffer\_tests
===============================

A test lib that can easily be required &amp; used in custom PHP\_CodeSniffer rulesets

2.0.0(11y ago)115.9kPHPPHP &gt;=5.1.2

Since Oct 27Pushed 11y agoCompare

[ Source](https://github.com/chr0n1x/php_codesniffer_tests)[ Packagist](https://packagist.org/packages/chr0n1x/php_codesniffer_tests)[ RSS](/packages/chr0n1x-php-codesniffer-tests/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

php\_codesniffer\_tests
=======================

[](#php_codesniffer_tests)

Fork of [squizlabs/PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer), but *just* the `AbstractSniffUnitTest` class. Why?

- I didn't want to lose any git commit history for this particular file!
- Now in your `composer.json` you can just

```
"require": {
    "chr0n1x/php_codesniffer_tests": "1.0.0"
}

```

and automatically have access to `AbstractSniffUnitTest` in your unit tests when you `require(__DIR__.'/vendor/autoload.php');`

- allows you to use phpunit xml configuration files and test locally, right in your own standards repo
- Easy CI integration. Just `composer install && ${RUN_SUITE}`
- hopefully encourages people to write tests for their PHP\_CodeSniffer sniffs!

**Differences between this class and the one included with PHP\_CodeSniffer:**

- The `runTests()` method is public and marked as a PHPUnit test (ie: `@test`). It also runs **per sniff** automatically, as in only one sniff will be tested with it's corresponding `.inc` file. Makes sense, right?
- `TEST_PATH` (**required**)
    - Because this package is installable via `composer` it's conceptually better to define somewhere, somehow, where your tests are located. Also, it's a bit less nebulous.
- `STANDARD_PATH` (optional)
    - This is specifically for standards that you have not yet officially installed in your instance of `phpcs`. If this const is not defined, the class will use the original method - parse the test class name &amp; assume that everything is in the `phpcs` home dir
- `TEST_EXT` (optional)
    - The original suite **required** all your tests to be `{$SNIFF_NAME}UnitTest.php`. Setting this constant allows you to override the `UnitTest` portion completely, giving you *some* flexibility when organizing your tests.

All of these constants can just be defined in a bootstrap script that requires the composer bootstrap. eg:

```
