Tests: add new PreexistingPHPCSInstalledPathsConfigTest
+ bug fix
#167
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
Tests: add new
PreexistingPHPCSInstalledPathsConfigTest
This new test class tests that the plugin handles a pre-existing PHPCS configuration file, which includes an
installed_paths
setting, correctly.These tests verify:
installed_paths
.installed_paths
.Notes:
Bug [2.2.2+] $this->composer->getConfig()->get('bin-dir') returns incorrect path on Windows composer/composer#10504 (discovered while writing these tests) is example of the reason why.
To not create too much redundancy, I've elected to run one of the tests via Composer global and the other one via local.
config-show
command in PHPCS has changed across PHPCS version, it is necessary to test against multiple PHPCS versions.Plugin: add new
getPhpcsCommand()
method (bug fix)PR #80 in response to bug #79 fixed the issue of the command to set the installed paths failing when the system default PHP version was being used instead of the PHP version used by Composer.
However, PHPCS is also called for the
--config-show
command to retrieve the originally set paths as well as to verify a successful save.This
--config-show
command was not adjusted at the time and was still being run using the system default PHP version, which could lead to validinstalled_paths
which were present before the installation of the plugin being removed, as--config-show
would silently fail, leading to the initial$this->installedPaths
being empty.This commit fixes that by:
getPhpcsCommand()
method which will cobble together the PHP executable + the PHPCS executable to a runnable command.This fixes the bug and improves consistency in the plugin.
It also happens to work as a work-around for upstream by composer/composer#10504 as it removes the call to
$this->composer->getConfig()->get('bin-dir')
which would result in an incorrect execution directory on Windows with Composer 2.2.2 - 2.2.5 (a fix for the issues was included in Composer itself in release 2.2.6).Related to #92