3 describe 'apache::mod::php', :type => :class do
4 describe "on a Debian OS" do
8 :operatingsystemrelease => '6',
9 :concat_basedir => '/dne',
10 :lsbdistcodename => 'squeeze',
11 :operatingsystem => 'Debian',
14 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
18 context "with mpm_module => prefork" do
20 'class { "apache": mpm_module => prefork, }'
22 it { is_expected.to contain_class("apache::params") }
23 it { is_expected.to contain_class("apache::mod::prefork") }
24 it { is_expected.to contain_apache__mod('php5') }
25 it { is_expected.to contain_package("libapache2-mod-php5") }
26 it { is_expected.to contain_file("php5.load").with(
27 :content => "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so\n"
30 context "with mpm_module => itk" do
32 'class { "apache": mpm_module => itk, }'
34 it { is_expected.to contain_class("apache::params") }
35 it { is_expected.to contain_class("apache::mod::itk") }
36 it { is_expected.to contain_apache__mod('php5') }
37 it { is_expected.to contain_package("libapache2-mod-php5") }
38 it { is_expected.to contain_file("php5.load").with(
39 :content => "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so\n"
43 describe "on a RedHat OS" do
46 :osfamily => 'RedHat',
47 :operatingsystemrelease => '6',
48 :concat_basedir => '/dne',
49 :operatingsystem => 'RedHat',
52 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
56 context "with default params" do
60 it { is_expected.to contain_class("apache::params") }
61 it { is_expected.to contain_apache__mod('php5') }
62 it { is_expected.to contain_package("php") }
63 it { is_expected.to contain_file("php5.load").with(
64 :content => "LoadModule php5_module modules/libphp5.so\n"
67 context "with alternative package name" do let :pre_condition do
71 { :package_name => 'php54'}
73 it { is_expected.to contain_package("php54") }
75 context "with alternative path" do let :pre_condition do
79 { :path => 'alternative-path'}
81 it { is_expected.to contain_file("php5.load").with(
82 :content => "LoadModule php5_module alternative-path\n"
85 context "with alternative extensions" do let :pre_condition do
89 { :extensions => ['.php','.php5']}
91 it { is_expected.to contain_file("php5.conf").with_content(/AddHandler php5-script .php .php5\n/) }
93 context "with specific version" do
98 { :package_ensure => '5.3.13'}
100 it { is_expected.to contain_package("php").with(
104 context "with mpm_module => prefork" do
105 let :pre_condition do
106 'class { "apache": mpm_module => prefork, }'
108 it { is_expected.to contain_class("apache::params") }
109 it { is_expected.to contain_class("apache::mod::prefork") }
110 it { is_expected.to contain_apache__mod('php5') }
111 it { is_expected.to contain_package("php") }
112 it { is_expected.to contain_file("php5.load").with(
113 :content => "LoadModule php5_module modules/libphp5.so\n"
116 context "with mpm_module => itk" do
117 let :pre_condition do
118 'class { "apache": mpm_module => itk, }'
120 it 'should raise an error' do
121 expect { expect(subject).to contain_class("apache::mod::itk") }.to raise_error Puppet::Error, /Unsupported osfamily RedHat/
125 describe "on a FreeBSD OS" do
128 :osfamily => 'FreeBSD',
129 :operatingsystemrelease => '10',
130 :concat_basedir => '/dne',
131 :operatingsystem => 'FreeBSD',
133 :kernel => 'FreeBSD',
134 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
138 context "with mpm_module => prefork" do
139 let :pre_condition do
140 'class { "apache": mpm_module => prefork, }'
142 it { is_expected.to contain_class('apache::params') }
143 it { is_expected.to contain_apache__mod('php5') }
144 it { is_expected.to contain_package("www/mod_php5") }
145 it { is_expected.to contain_file('php5.load') }
147 context "with mpm_module => itk" do
148 let :pre_condition do
149 'class { "apache": mpm_module => itk, }'
151 it { is_expected.to contain_class('apache::params') }
152 it { is_expected.to contain_class('apache::mod::itk') }
153 it { is_expected.to contain_apache__mod('php5') }
154 it { is_expected.to contain_package("www/mod_php5") }
155 it { is_expected.to contain_file('php5.load') }
158 describe "on a Gentoo OS" do
161 :osfamily => 'Gentoo',
162 :operatingsystem => 'Gentoo',
163 :operatingsystemrelease => '3.16.1-gentoo',
164 :concat_basedir => '/dne',
167 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin',
171 context "with mpm_module => prefork" do
172 let :pre_condition do
173 'class { "apache": mpm_module => prefork, }'
175 it { is_expected.to contain_class('apache::params') }
176 it { is_expected.to contain_apache__mod('php5') }
177 it { is_expected.to contain_package("dev-lang/php") }
178 it { is_expected.to contain_file('php5.load') }
180 context "with mpm_module => itk" do
181 let :pre_condition do
182 'class { "apache": mpm_module => itk, }'
184 it { is_expected.to contain_class('apache::params') }
185 it { is_expected.to contain_class('apache::mod::itk') }
186 it { is_expected.to contain_apache__mod('php5') }
187 it { is_expected.to contain_package("dev-lang/php") }
188 it { is_expected.to contain_file('php5.load') }
191 describe "OS independent tests" do
194 :osfamily => 'Debian',
195 :operatingsystem => 'Debian',
196 :operatingsystemrelease => '6',
198 :lsbdistcodename => 'squeeze',
199 :concat_basedir => '/dne',
201 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
205 context 'with content param' do
206 let :pre_condition do
207 'class { "apache": mpm_module => prefork, }'
210 { :content => 'somecontent' }
212 it { should contain_file('php5.conf').with(
213 :content => 'somecontent'
216 context 'with template param' do
217 let :pre_condition do
218 'class { "apache": mpm_module => prefork, }'
221 { :template => 'apache/mod/php5.conf.erb' }
223 it { should contain_file('php5.conf').with(
224 :content => /^# PHP is an HTML-embedded scripting language which attempts to make it/
227 context 'with source param' do
228 let :pre_condition do
229 'class { "apache": mpm_module => prefork, }'
232 { :source => 'some-path' }
234 it { should contain_file('php5.conf').with(
235 :source => 'some-path'
238 context 'content has priority over template' do
239 let :pre_condition do
240 'class { "apache": mpm_module => prefork, }'
244 :template => 'apache/mod/php5.conf.erb',
245 :content => 'somecontent'
248 it { should contain_file('php5.conf').with(
249 :content => 'somecontent'
252 context 'source has priority over template' do
253 let :pre_condition do
254 'class { "apache": mpm_module => prefork, }'
258 :template => 'apache/mod/php5.conf.erb',
259 :source => 'some-path'
262 it { should contain_file('php5.conf').with(
263 :source => 'some-path'
266 context 'source has priority over content' do
267 let :pre_condition do
268 'class { "apache": mpm_module => prefork, }'
272 :content => 'somecontent',
273 :source => 'some-path'
276 it { should contain_file('php5.conf').with(
277 :source => 'some-path'
280 context 'with mpm_module => worker' do
281 let :pre_condition do
282 'class { "apache": mpm_module => worker, }'
284 it 'should raise an error' do
285 expect { expect(subject).to contain_apache__mod('php5') }.to raise_error Puppet::Error, /mpm_module => 'prefork' or mpm_module => 'itk'/