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

Tests: add new RootPackageHandlingTest + bugfix #175

Merged
merged 3 commits into from May 28, 2022

Commits on May 27, 2022

  1. TestCase: new recursiveDirectoryCopy() method

    New helper method to recursively copy a (fixture) directory with all its files to another location, typically, one of the system temp test directories.
    
    If the `$srcDir` contains a `composer.json` file, it will get the same `TestCase::writeComposerJsonFile()` special treatment, meaning that the artifacts directory will be injected, as well as plugin permissions and more.
    jrfnl committed May 27, 2022
    Copy the full SHA
    f1acb08 View commit details
    Browse the repository at this point in the history
  2. Tests: add new RootPackageHandlingTest

    This new test class tests that the plugin correctly registers standards found in the root package if it is an external standard.
    
    Notes:
    * This test is about Composer and the plugin, so does not need to be tested against multiple PHPCS versions.
    
    This test class covers the following bugs previously reported:
    * Dealerdirect/phpcodesniffer-composer-installer issue 19
    * Dealerdirect/phpcodesniffer-composer-installer PR 21
    * Dealerdirect/phpcodesniffer-composer-installer issue 20
    * Dealerdirect/phpcodesniffer-composer-installer PR 25
    * Dealerdirect/phpcodesniffer-composer-installer issue 32
    jrfnl committed May 27, 2022
    Copy the full SHA
    b0f58fa View commit details
    Browse the repository at this point in the history
  3. Plugin: only search root package when it has the `phpcodesniffer-stan…

    …dard` type (bug fix)
    
    In the "olden days" of PHPCS 1.x, it was customary for projects to call their custom project ruleset `ruleset.xml` instead of `[.]phpcs.xml[.dist]`.
    
    This could lead to a root package with such an _old-style_ PHPCS ruleset being registered as if it were a proper PHPCS external standard.
    This was previously reported in issue 32.
    
    The fix I'm proposing now, applies the same rules as for `vendor` installed standards to the root package, i.e.:
    * Must have the `phpcodesniffer-standard` type set in the `composer.json` file AND
    * Must have a `ruleset.xml` file.
    
    Root packages which do not comply with _both_ these rules will no longer be considered for registration with PHPCS. This should also make the plugin slightly faster for those packages which do not have external standards, but do have the plugin installed.
    
    Includes removing some dead code (condition which could never be `true`) which was loosely related to this.
    
    Fixes 32
    jrfnl committed May 27, 2022
    Copy the full SHA
    2de5e4b View commit details
    Browse the repository at this point in the history