diff --git a/src/install_coding_standard.bash b/src/install_coding_standard.bash index be6f9f4..ea77bd0 100755 --- a/src/install_coding_standard.bash +++ b/src/install_coding_standard.bash @@ -7,6 +7,14 @@ composer global require --no-interaction ${CODING_STANDARD}:${INPUT_CODING_STAND # Fixme: find a better way to handle adding standards if [ "${CODING_STANDARD}" = "magento/magento-coding-standard" ] ; then - composer global -- exec phpcs --config-set installed_paths \ - ../../magento/magento-coding-standard/,../../phpcompatibility/php-compatibility + INSTALL_PATHS="../../magento/magento-coding-standard/" + if composer global show magento/php-compatibility-fork > /dev/null 2>&1; then + INSTALL_PATHS="${INSTALL_PATHS},../../magento/php-compatibility-fork" + fi + + if composer global show phpcompatibility/php-compatibility > /dev/null 2>&1; then + INSTALL_PATHS="${INSTALL_PATHS},../../phpcompatibility/php-compatibility" + fi + + composer global -- exec phpcs --config-set installed_paths "$INSTALL_PATHS" fi diff --git a/tests/install_magento_coding_standard.bats b/tests/install_magento_coding_standard.bats index 4f6a535..3cbd3c2 100755 --- a/tests/install_magento_coding_standard.bats +++ b/tests/install_magento_coding_standard.bats @@ -33,6 +33,20 @@ teardown() { run install_coding_standard.bash run composer global info [[ "$output" =~ "magento/magento-coding-standard"\ *30 ]] + run composer global -- exec "phpcs --config-show" + [[ "$output" =~ "phpcompatibility/php-compatibility" ]] +} + +@test "Coding standard is installed with version 33" { + if ! command -v composer > /dev/null ; then + skip "Composer is not installed." + fi + export INPUT_CODING_STANDARD_VERSION=33 + run install_coding_standard.bash + run composer global info + [[ "$output" =~ "magento/magento-coding-standard"\ *33 ]] + run composer global -- exec "phpcs --config-show" + [[ "$output" =~ "magento/php-compatibility-fork" ]] } @test "Coding standard package is installed" {