• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPCSStandards / PHPCSUtils / 38
93%
develop: 100%

Build:
Build:
LAST BUILD BRANCH: dependabot/github_actions/action-runners-c4b2a15d30
DEFAULT BRANCH: develop
Ran 26 Dec 2019 11:36PM UTC
Jobs 4
Files 6
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
38

Pull #9

travis-ci-com

web-flow
:sparkles: New `TestUtils\UtilityMethodTestCase`

This `PHPCSUtils\TestUtils\UtilityMethodTestCase` can be used to test arbitrary utility methods written for PHPCS 2.x as well as PHPCS 3.x, using PHPUnit 4.5 - 8.x.

Aside from taking care of setting up PHPCS and tokenizing the test case file, the class offers two utility functions:
* `getTargetToken()` - to get the token pointer for a target token based on a specific comment found on the/a line before. Returns the int stack pointer to the target.
    Note: the test delimiter comment MUST start with "/* test" to allow this function to distinguish between comments used *in* a test and test delimiters.
* `expectPhpcsException()` - Helper method to tell PHPUnit to expect a PHPCS Exception in a PHPUnit cross-version compatible manner.

If you choose to use this feature and need to use PHPUnit < 5.4 (i.e. if your standard still supports PHP < 5.6), the PHPCSUtils `phpcsutils-autoload.php` file **MUST** be included in your PHPUnit bootstrap file to ensure that the necessary class aliases for PHPUnit are in place.
Similarly, the autoload file **must** be included if you support PHPCS < 3.

By default, the class will look for a test case file in the same directory and with the same file name as the concrete test class, though with an `inc` file extension.

The file extension can be changed by setting the `$fileExtension` property in the concrete class.

To diverge from the default, the path to the test case file can also be provided via the `$caseFile` property, like so:
```php
    /**
     * Initialize & tokenize {@see \PHP_CodeSniffer\Files\File} with code from the test case file.
     *
     * Overloaded to change the `$caseFile`.
     *
     * @beforeClass
     *
     * @return void
     */
    public static function setUpTestFile()
    {
        self::$caseFile = __DIR__ . '/pathToFile.inc';
        parent::setUpTestFile();
    }
```

Includes unit tests for this test utility.
Pull Request #9: New `TestUtils\UtilityMethodTestCase`

63 of 63 new or added lines in 1 file covered. (100.0%)

200 of 216 relevant lines covered (92.59%)

14.39 hits per line

Jobs
ID Job ID Ran Files Coverage
29 38.29 (LINT=1 PHPCS_VERSION="dev-master" COVERALLS_VERSION="^2.0") 26 Dec 2019 11:36PM UTC 0
84.72
Travis Job 38.29
30 38.30 (PHPCS_VERSION="2.9.2" COVERALLS_VERSION="^2.0") 26 Dec 2019 11:36PM UTC 0
79.17
Travis Job 38.30
31 38.31 (LINT=1 PHPCS_VERSION="dev-master" COVERALLS_VERSION="^1.0") 26 Dec 2019 11:36PM UTC 0
79.07
Travis Job 38.31
32 38.32 (PHPCS_VERSION="2.6.0" COVERALLS_VERSION="^1.0") 26 Dec 2019 11:38PM UTC 0
74.42
Travis Job 38.32
Source Files on build 38
Detailed source file information is not available for this build.
  • Back to Repo
  • Build #38
  • Pull Request #9
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc