Skip to content
This repository has been archived by the owner on Oct 11, 2018. It is now read-only.

Commit

Permalink
proper php version query
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Schumann committed May 7, 2014
1 parent beccf26 commit 894cdd1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/facter/php_version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Facter.add(:php_version) do
confine :kernel => :linux
setcode do
version = Facter::Util::Resolution.exec("/usr/bin/php --version | grep '^PHP ' | awk '{print $2}'")
version = Facter::Util::Resolution.exec("/usr/bin/env php -r 'echo PHP_VERSION;'")
if version
version.match(/(\d+\.\d+\.\d+)/).to_s
else
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

$config_root = '/etc/php5'

if versioncmp($::php_version, '5.4') >= 0 {
if $::php_version == '' or versioncmp($::php_version, '5.4') >= 0 {
$config_root_ini = "${::php::params::config_root}/mods-available"
} else {
$config_root_ini = "${::php::params::config_root}/conf.d"
Expand Down
29 changes: 25 additions & 4 deletions spec/classes/xdebug_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@
'include "php"'
end

context 'php 5.3' do
context 'with an undetermined php version' do
let(:facts) { { :php_version => '' } }

it { should contain_augeas("php-php-extension-xdebug-config")
.with({
:incl => '/etc/php5/mods-available/xdebug.ini',
})
}
end

context 'with php 5.3' do
let(:facts) { { :php_version => '5.3'} }

it { should contain_augeas("php-php-extension-xdebug-config")
Expand All @@ -15,7 +25,7 @@
}
end

context 'php 5.4' do
context 'with php 5.4' do
let(:facts) { { :php_version => '5.4'} }

it { should contain_augeas("php-php-extension-xdebug-config")
Expand All @@ -25,7 +35,7 @@
}
end

context 'php 5.4.1' do
context 'with php 5.4.1' do
let(:facts) { { :php_version => '5.4.1'} }

it { should contain_augeas("php-php-extension-xdebug-config")
Expand All @@ -35,7 +45,17 @@
}
end

context 'php 5.5' do
context 'with php 5.5' do
let(:facts) { { :php_version => '5.5'} }

it { should contain_augeas("php-php-extension-xdebug-config")
.with({
:incl => '/etc/php5/mods-available/xdebug.ini',
})
}
end

context 'with php 5.5.11-1~dotdeb.1' do
let(:facts) { { :php_version => '5.5'} }

it { should contain_augeas("php-php-extension-xdebug-config")
Expand All @@ -44,4 +64,5 @@
})
}
end

end

0 comments on commit 894cdd1

Please sign in to comment.