Skip to content

Commit

Permalink
Merge 6955747 into 3c66d69
Browse files Browse the repository at this point in the history
  • Loading branch information
TuningYourCode committed Jul 29, 2019
2 parents 3c66d69 + 6955747 commit b5e572a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
4 changes: 2 additions & 2 deletions manifests/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# [*ensure*]
# The ensure of the package to install
# Could be "latest", "installed" or a pinned version
# Could be "present", "absent", "latest", "installed" or a pinned version
#
# [*package_prefix*]
# Prefix to prepend to the package name for the package provider
Expand Down Expand Up @@ -71,7 +71,7 @@
# Array of String or Hash options to pass to the provider.
#
define php::extension (
String $ensure = 'installed',
String $ensure = $php::ensure,
Optional[Php::Provider] $provider = undef,
Optional[String] $source = undef,
Optional[String] $so_name = undef,
Expand Down
41 changes: 37 additions & 4 deletions spec/classes/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'php5-cli'
end
end
php_fpm_ackage = case facts[:os]['name']
php_fpm_package = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
Expand All @@ -43,7 +43,7 @@
'php5-fpm'
end
end
php_dev_ackage = case facts[:os]['name']
php_dev_package = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
Expand Down Expand Up @@ -75,8 +75,8 @@
it { is_expected.to contain_package('php-pear').with_ensure('present') }
it { is_expected.to contain_class('php::composer') }
it { is_expected.to contain_package(php_cli_package).with_ensure('present') }
it { is_expected.to contain_package(php_fpm_ackage).with_ensure('present') }
it { is_expected.to contain_package(php_dev_ackage).with_ensure('present') }
it { is_expected.to contain_package(php_fpm_package).with_ensure('present') }
it { is_expected.to contain_package(php_dev_package).with_ensure('present') }
when 'Suse'
it { is_expected.to contain_package('php5').with_ensure('present') }
it { is_expected.to contain_package('php5-devel').with_ensure('present') }
Expand All @@ -90,6 +90,39 @@
end
end

describe 'when called with extensions' do
let(:params) { { extensions: { xml: {} } } }

it { is_expected.to contain_php__extension('xml').with_ensure('present') }
end

describe 'when called with ensure absent and extensions' do
let(:params) {
{
ensure: 'absent',
extensions: {
xml: {
}
}
}
}

it { is_expected.to contain_php__extension('xml').with_ensure('absent') }

case facts[:osfamily]
when 'Debian'
it { is_expected.to contain_package(php_cli_package).with_ensure('absent') }
it { is_expected.to contain_package(php_fpm_package).with_ensure('absent') }
it { is_expected.to contain_package(php_dev_package).with_ensure('absent') }
when 'Suse'
it { is_expected.to contain_package('php5').with_ensure('absent') }
it { is_expected.to contain_package('php5-devel').with_ensure('absent') }
when 'RedHat', 'CentOS'
it { is_expected.to contain_package('php-cli').with_ensure('absent') }
it { is_expected.to contain_package('php-common').with_ensure('absent') }
end
end

describe 'when called with package_prefix parameter' do
package_prefix = 'myphp-'
let(:params) { { package_prefix: package_prefix } }
Expand Down

0 comments on commit b5e572a

Please sign in to comment.