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.
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#19
Dealerdirect/phpcodesniffer-composer-installer#21
Dealerdirect/phpcodesniffer-composer-installer#20
Dealerdirect/phpcodesniffer-composer-installer#25
Dealerdirect/phpcodesniffer-composer-installer#32
Plugin: only search root package when it has the phpcodesniffer-standard 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.
Proposed Changes
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 acomposer.json
file, it will get the sameTestCase::writeComposerJsonFile()
special treatment, meaning that the artifacts directory will be injected, as well as plugin permissions and more.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 class covers the following bugs previously reported:
Plugin: only search root package when it has the
phpcodesniffer-standard
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.:phpcodesniffer-standard
type set in thecomposer.json
file ANDruleset.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
Related Issues
Related to #92