Skip to content

Commit

Permalink
Merge pull request #1236 from travis-ci/ha-php-5.3
Browse files Browse the repository at this point in the history
Skip overwriting ~/.pearrc for PHP 5.3 and older
  • Loading branch information
BanzaiMan authored Oct 31, 2017
2 parents 8767d14 + 0318a98 commit f45d079
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/travis/build/script/php.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ def setup
sh.if "$? -ne 0" do
install_php_on_demand(version)
end
sh.else do
sh.fold "pearrc" do
sh.echo "Writing $HOME/.pearrc", ansi: :yellow
overwrite_pearrc(version)
sh.cmd "pear config-show", echo: true
unless php_5_3_or_older?
sh.else do
sh.fold "pearrc" do
sh.echo "Writing $HOME/.pearrc", ansi: :yellow
overwrite_pearrc(version)
sh.cmd "pear config-show", echo: true
end
end
end
sh.cmd "phpenv global #{version}", assert: true
Expand Down Expand Up @@ -191,6 +193,10 @@ def composer_self_update
end
end

def php_5_3_or_older?
!hhvm? && Gem::Version.new(version) < Gem::Version.new('5.4')
end

def overwrite_pearrc(version)
pear_config = %q(
[
Expand Down
14 changes: 14 additions & 0 deletions spec/build/script/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@
xit { should include_sexp [:cmd, 'curl -s -o archive.tar.bz2 $archive_url && tar xjf archive.tar.bz2 --directory /', timing: true] }
end

context 'with php 5.4' do
describe 'writes ~/.pearrc if necessary' do
before { data[:config][:php] = '5.4' }
it { should include_sexp [:echo, 'Writing $HOME/.pearrc', ansi: :yellow] }
end
end

context 'with php 5.3' do
describe 'does not write ~/.pearrc' do
before { data[:config][:php] = '5.3' }
it { should_not include_sexp [:echo, 'Writing $HOME/.pearrc', ansi: :yellow] }
end
end

describe 'installs php 7' do
before { data[:config][:php] = '7' }
it { should include_sexp [:cmd, 'ln -s ~/.phpenv/versions/7.0 ~/.phpenv/versions/7', assert: true, timing: true] }
Expand Down

0 comments on commit f45d079

Please sign in to comment.