Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify php (extension) removal #526

Merged
merged 1 commit into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
102 changes: 64 additions & 38 deletions spec/classes/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,42 @@
'php5-cli'
end
end
php_fpm_ackage = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'php7.0-fpm'
else
'php5-fpm'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'php7.2-fpm'
when '16.04'
'php7.0-fpm'
else
'php5-fpm'
end
end
php_dev_ackage = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'php7.0-dev'
else
'php5-dev'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'php7.2-dev'
when '16.04'
'php7.0-dev'
else
'php5-dev'
end
end
php_fpm_package = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'php7.0-fpm'
else
'php5-fpm'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'php7.2-fpm'
when '16.04'
'php7.0-fpm'
else
'php5-fpm'
end
end
php_dev_package = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'php7.0-dev'
else
'php5-dev'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'php7.2-dev'
when '16.04'
'php7.0-dev'
else
'php5-dev'
end
end

describe 'when called with no parameters' do
case facts[:osfamily]
Expand All @@ -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,32 @@
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
extensions = { xml: {} }
let(:params) { { ensure: 'absent', extensions: extensions } }

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