Tests: add new RootPackageHandlingTest + bugfix #175
Merged
+219
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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