Skip to content

Commit

Permalink
Merge pull request #157 from raphaelstolt/fix-global-env
Browse files Browse the repository at this point in the history
Fix environment variables
  • Loading branch information
jonathantorres committed Oct 13, 2016
2 parents cd7e39c + 247f84a commit 8660ee9
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 91 deletions.
17 changes: 9 additions & 8 deletions .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:
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/Defaults.php
Expand Up @@ -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';
Expand Down
15 changes: 11 additions & 4 deletions src/Helpers/Travis.php
Expand Up @@ -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(
Expand All @@ -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)) {
Expand Down
6 changes: 1 addition & 5 deletions src/stubs/travis.phpcs.stub
@@ -1,9 +1,5 @@
language: php

env:
global:
- disable-xdebug=true

matrix:
include:
{phpVersions}
Expand All @@ -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
Expand Down
6 changes: 1 addition & 5 deletions src/stubs/travis.stub
@@ -1,9 +1,5 @@
language: php

env:
global:
- disable-xdebug=true

matrix:
include:
{phpVersions}
Expand All @@ -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
Expand Down
43 changes: 30 additions & 13 deletions tests/Helpers/TravisTest.php
Expand Up @@ -49,16 +49,23 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php54_proj

$stringExpected = <<<CONTENT
- 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.5.9
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
CONTENT;

$this->assertEquals($versionsToRun, $stringExpected);
Expand Down Expand Up @@ -98,13 +105,19 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php55_proj

$stringExpected = <<<CONTENT
- php: hhvm
env: disable-xdebug=false
- php: 5.5
env:
- DISABLE_XDEBUG=true
- php: 5.5.9
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
CONTENT;

$this->assertEquals($versionsToRun, $stringExpected);
Expand Down Expand Up @@ -143,12 +156,16 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php559_pro

$stringExpected = <<<CONTENT
- php: hhvm
env: disable-xdebug=false
- php: 5.5.9
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
CONTENT;

$this->assertEquals($versionsToRun, $stringExpected);
Expand Down Expand Up @@ -185,11 +202,13 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php56_proj

$stringExpected = <<<CONTENT
- php: hhvm
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
CONTENT;

$this->assertEquals($versionsToRun, $stringExpected);
Expand Down Expand Up @@ -242,10 +261,10 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php7_0_pro

$stringExpected = <<<CONTENT
- php: hhvm
env: disable-xdebug=false
- php: 7.0
env:
- DISABLE_XDEBUG=true
- php: 7.1
env: disable-xdebug=false
CONTENT;

$this->assertEquals($versionsToRun, $stringExpected);
Expand Down Expand Up @@ -278,9 +297,7 @@ public function it_should_generate_string_of_all_versions_to_run_on_a_php7_1_pro

$stringExpected = <<<CONTENT
- php: hhvm
env: disable-xdebug=false
- php: 7.1
env: disable-xdebug=false
CONTENT;

$this->assertEquals($versionsToRun, $stringExpected);
Expand Down
17 changes: 9 additions & 8 deletions tests/stubs/travis.php54.stub
@@ -1,29 +1,30 @@
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:
directories:
- $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
Expand Down
15 changes: 7 additions & 8 deletions tests/stubs/travis.php55.stub
@@ -1,28 +1,27 @@
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:
directories:
- $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
Expand Down
13 changes: 5 additions & 8 deletions tests/stubs/travis.php56.stub
@@ -1,27 +1,24 @@
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:
directories:
- $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
Expand Down
11 changes: 3 additions & 8 deletions tests/stubs/travis.php7.stub
@@ -1,26 +1,21 @@
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:
directories:
- $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
Expand Down

0 comments on commit 8660ee9

Please sign in to comment.