Skip to content

Commit bc3f35c

Browse files
beatchristenCiaran McCrisken
authored andcommitted
(MODULES-10899) Fix for debian10/experimental with tests
This commit introduces the `$_module_id` variable which will be populated with the correct module ID based on the version specified. This makes things a bit more explicit and easier to follow. Also, two spec tests added for the following scenario: - Debian 10 (out of the box) using PHP 7.3 - Debian 10 (experimental) using PHP 8.0
1 parent 5285ae3 commit bc3f35c

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

manifests/mod/php.pp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,28 @@
6969
# Controls php version and libphp prefix
7070
$_lib = "${libphp_prefix}${php_version}.so"
7171
}
72+
$_module_id = $_php_major ? {
73+
'5' => 'php5_module',
74+
'7' => 'php7_module',
75+
default => 'php_module',
76+
}
7277

7378
if $::operatingsystem == 'SLES' {
7479
::apache::mod { $mod:
7580
package => $_package_name,
7681
package_ensure => $package_ensure,
7782
lib => "mod_${mod}.so",
78-
id => "php${_php_major}_module",
83+
id => $_module_id,
7984
path => "${apache::lib_path}/mod_${mod}.so",
8085
}
81-
} elsif (versioncmp($php_version, '8') < 0) {
86+
} else {
8287
::apache::mod { $mod:
8388
package => $_package_name,
8489
package_ensure => $package_ensure,
8590
lib => $_lib,
86-
id => "php${_php_major}_module",
91+
id => $_module_id,
8792
path => $path,
8893
}
89-
} else {
90-
::apache::mod { $mod:
91-
package => $_package_name,
92-
package_ensure => $package_ensure,
93-
lib => "${libphp_prefix}.so",
94-
id => 'php_module',
95-
path => $path,
96-
}
9794
}
9895

9996
include apache::mod::mime

spec/classes/mod/php_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@
5353
)
5454
}
5555
end
56+
when '10'
57+
context 'on buster' do
58+
it { is_expected.to contain_apache__mod('php7.3') }
59+
it { is_expected.to contain_package('libapache2-mod-php7.3') }
60+
it {
61+
is_expected.to contain_file('php7.3.load').with(
62+
content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.3.so\n",
63+
)
64+
}
65+
end
66+
context 'on buster with experimental php8.0' do
67+
let :params do
68+
{ php_version: '8.0' }
69+
end
70+
71+
it { is_expected.to contain_apache__mod('php') }
72+
it { is_expected.to contain_package('libapache2-mod-php8.0') }
73+
it {
74+
is_expected.to contain_file('php.load').with(
75+
content: "LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so\n",
76+
)
77+
}
78+
end
5679
when '16.04'
5780
context 'on stretch' do
5881
let :params do

0 commit comments

Comments
 (0)