From 247f84a3fa47df716f38955751f1a845ad735caa Mon Sep 17 00:00:00 2001 From: Raphael Stolt Date: Tue, 11 Oct 2016 09:45:37 +0200 Subject: [PATCH] Fix environment variables --- .travis.yml | 17 ++++++------ src/Defaults.php | 14 ++++++++++ src/Helpers/Travis.php | 15 ++++++++--- src/stubs/travis.phpcs.stub | 6 +---- src/stubs/travis.stub | 6 +---- tests/Helpers/TravisTest.php | 43 +++++++++++++++++++++--------- tests/stubs/travis.php54.stub | 17 ++++++------ tests/stubs/travis.php55.stub | 15 +++++------ tests/stubs/travis.php56.stub | 13 ++++----- tests/stubs/travis.php7.stub | 11 +++----- tests/stubs/travis.php71.stub | 9 +------ tests/stubs/travis.stub | 13 ++++----- tests/stubs/with-phpcs/travis.stub | 13 ++++----- 13 files changed, 101 insertions(+), 91 deletions(-) diff --git a/.travis.yml b/.travis.yml index 918d9a0..0cc48d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,22 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: - php: hhvm - env: disable-xdebug=false - php: nightly - env: disable-xdebug=false - php: 7.1 - env: disable-xdebug=false - php: 7.0 + env: + - DISABLE_XDEBUG=true - php: 5.6 + env: + - DISABLE_XDEBUG=true - php: 5.5 + env: + - DISABLE_XDEBUG=true - php: 5.4 + env: + - DISABLE_XDEBUG=true fast_finish: true cache: @@ -24,7 +25,7 @@ cache: - $HOME/.php-cs-fixer before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - composer self-update diff --git a/src/Defaults.php b/src/Defaults.php index 93c19ba..e2bea50 100644 --- a/src/Defaults.php +++ b/src/Defaults.php @@ -25,6 +25,20 @@ class Defaults */ public $phpVersions = ['5.4', '5.5', '5.6', '7.0', '7.1']; + /** + * Available php versions with a Xdebug extension. + * + * @var array + */ + public $phpVersionsWithXdebugExtension = ['5.4', '5.5', '5.6', '7.0']; + + /** + * Php versions without a semver scheme. + * + * @var array + */ + public $nonSemverPhpVersions = ['hhvm', 'nightly']; + const TEST_FRAMEWORK = 'phpunit'; const LICENSE = 'MIT'; const PROJECT_NAMESPACE = 'Vendor\Project'; diff --git a/src/Helpers/Travis.php b/src/Helpers/Travis.php index 51268c9..5912b28 100644 --- a/src/Helpers/Travis.php +++ b/src/Helpers/Travis.php @@ -29,7 +29,7 @@ private function toMinorVersion($version) public function phpVersionsToTest($projectPhpVersion) { $supportedPhpVersions = (new Defaults)->phpVersions; - $versionsToTest = ['hhvm', 'nightly']; + $versionsToTest = (new Defaults)->nonSemverPhpVersions; $phpVersionsToTest = array_filter($supportedPhpVersions, function ($supportedPhpVersion) use ($projectPhpVersion) { return version_compare( @@ -51,16 +51,23 @@ public function phpVersionsToTest($projectPhpVersion) */ public function phpVersionsToRun($phpVersions) { - $versionsWithoutXdebugExtension = ['hhvm', 'nightly', '7.1']; + $versionsWithXdebugExtension = (new Defaults)->phpVersionsWithXdebugExtension; $runOn = ''; + $nonSemverVersions = (new Defaults)->nonSemverPhpVersions; for ($i = 0; $i < count($phpVersions); $i++) { + $phpVersion = $phpVersions[$i]; + if (!in_array($phpVersions[$i], $nonSemverVersions)) { + $phpVersion = $this->toMinorVersion($phpVersions[$i]); + } + if (count($i) !== 0) { $runOn .= ' '; } $runOn .= '- php: ' . $phpVersions[$i]; - if (in_array($phpVersions[$i], $versionsWithoutXdebugExtension)) { - $runOn .= "\n env: disable-xdebug=false"; + if (in_array($phpVersion, $versionsWithXdebugExtension)) { + $runOn .= "\n env:" + . "\n - DISABLE_XDEBUG=true"; } if ($i !== (count($phpVersions) - 1)) { diff --git a/src/stubs/travis.phpcs.stub b/src/stubs/travis.phpcs.stub index 284483b..16d666e 100644 --- a/src/stubs/travis.phpcs.stub +++ b/src/stubs/travis.phpcs.stub @@ -1,9 +1,5 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: {phpVersions} @@ -14,7 +10,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - travis_retry composer self-update diff --git a/src/stubs/travis.stub b/src/stubs/travis.stub index 2660f4b..b86318d 100644 --- a/src/stubs/travis.stub +++ b/src/stubs/travis.stub @@ -1,9 +1,5 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: {phpVersions} @@ -14,7 +10,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - travis_retry composer self-update diff --git a/tests/Helpers/TravisTest.php b/tests/Helpers/TravisTest.php index ec0585c..80b87a8 100644 --- a/tests/Helpers/TravisTest.php +++ b/tests/Helpers/TravisTest.php @@ -49,16 +49,23 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php54_proj $stringExpected = <<assertEquals($versionsToRun, $stringExpected); @@ -98,13 +105,19 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php55_proj $stringExpected = <<assertEquals($versionsToRun, $stringExpected); @@ -143,12 +156,16 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php559_pro $stringExpected = <<assertEquals($versionsToRun, $stringExpected); @@ -185,11 +202,13 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php56_proj $stringExpected = <<assertEquals($versionsToRun, $stringExpected); @@ -242,10 +261,10 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php7_0_pro $stringExpected = <<assertEquals($versionsToRun, $stringExpected); @@ -278,9 +297,7 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php7_1_pro $stringExpected = <<assertEquals($versionsToRun, $stringExpected); diff --git a/tests/stubs/travis.php54.stub b/tests/stubs/travis.php54.stub index 605af50..4628ace 100644 --- a/tests/stubs/travis.php54.stub +++ b/tests/stubs/travis.php54.stub @@ -1,21 +1,22 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: - php: hhvm - env: disable-xdebug=false - php: nightly - env: disable-xdebug=false - php: 5.4 + env: + - DISABLE_XDEBUG=true - php: 5.5 + env: + - DISABLE_XDEBUG=true - php: 5.6 + env: + - DISABLE_XDEBUG=true - php: 7.0 + env: + - DISABLE_XDEBUG=true - php: 7.1 - env: disable-xdebug=false fast_finish: true cache: @@ -23,7 +24,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - travis_retry composer self-update diff --git a/tests/stubs/travis.php55.stub b/tests/stubs/travis.php55.stub index 3d61a61..b08ca04 100644 --- a/tests/stubs/travis.php55.stub +++ b/tests/stubs/travis.php55.stub @@ -1,20 +1,19 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: - php: hhvm - env: disable-xdebug=false - php: nightly - env: disable-xdebug=false - php: 5.5 + env: + - DISABLE_XDEBUG=true - php: 5.6 + env: + - DISABLE_XDEBUG=true - php: 7.0 + env: + - DISABLE_XDEBUG=true - php: 7.1 - env: disable-xdebug=false fast_finish: true cache: @@ -22,7 +21,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - travis_retry composer self-update diff --git a/tests/stubs/travis.php56.stub b/tests/stubs/travis.php56.stub index 0c1295f..293ad93 100644 --- a/tests/stubs/travis.php56.stub +++ b/tests/stubs/travis.php56.stub @@ -1,19 +1,16 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: - php: hhvm - env: disable-xdebug=false - php: nightly - env: disable-xdebug=false - php: 5.6 + env: + - DISABLE_XDEBUG=true - php: 7.0 + env: + - DISABLE_XDEBUG=true - php: 7.1 - env: disable-xdebug=false fast_finish: true cache: @@ -21,7 +18,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - travis_retry composer self-update diff --git a/tests/stubs/travis.php7.stub b/tests/stubs/travis.php7.stub index a2f280e..2f7c659 100644 --- a/tests/stubs/travis.php7.stub +++ b/tests/stubs/travis.php7.stub @@ -1,18 +1,13 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: - php: hhvm - env: disable-xdebug=false - php: nightly - env: disable-xdebug=false - php: 7.0 + env: + - DISABLE_XDEBUG=true - php: 7.1 - env: disable-xdebug=false fast_finish: true cache: @@ -20,7 +15,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - travis_retry composer self-update diff --git a/tests/stubs/travis.php71.stub b/tests/stubs/travis.php71.stub index 3550efa..102176f 100644 --- a/tests/stubs/travis.php71.stub +++ b/tests/stubs/travis.php71.stub @@ -1,17 +1,10 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: - php: hhvm - env: disable-xdebug=false - php: nightly - env: disable-xdebug=false - php: 7.1 - env: disable-xdebug=false fast_finish: true cache: @@ -19,7 +12,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - travis_retry composer self-update diff --git a/tests/stubs/travis.stub b/tests/stubs/travis.stub index 0c1295f..293ad93 100644 --- a/tests/stubs/travis.stub +++ b/tests/stubs/travis.stub @@ -1,19 +1,16 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: - php: hhvm - env: disable-xdebug=false - php: nightly - env: disable-xdebug=false - php: 5.6 + env: + - DISABLE_XDEBUG=true - php: 7.0 + env: + - DISABLE_XDEBUG=true - php: 7.1 - env: disable-xdebug=false fast_finish: true cache: @@ -21,7 +18,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - travis_retry composer self-update diff --git a/tests/stubs/with-phpcs/travis.stub b/tests/stubs/with-phpcs/travis.stub index 5d6a520..0ba4821 100644 --- a/tests/stubs/with-phpcs/travis.stub +++ b/tests/stubs/with-phpcs/travis.stub @@ -1,19 +1,16 @@ language: php -env: - global: - - disable-xdebug=true - matrix: include: - php: hhvm - env: disable-xdebug=false - php: nightly - env: disable-xdebug=false - php: 5.6 + env: + - DISABLE_XDEBUG=true - php: 7.0 + env: + - DISABLE_XDEBUG=true - php: 7.1 - env: disable-xdebug=false fast_finish: true cache: @@ -21,7 +18,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $disable-xdebug = true ]]; then + - if [[ $DISABLE_XDEBUG = true ]]; then phpenv config-rm xdebug.ini; fi - travis_retry composer self-update