forked from puppetlabs/puppetlabs-apache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_php_spec.rb
88 lines (84 loc) · 3.5 KB
/
mod_php_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require 'spec_helper_acceptance'
apache_hash = apache_settings_hash
unless os[:family] == 'sles' && os[:release].to_i >= 12
describe 'apache::mod::php class' do
context 'default php config' do
pp = <<-MANIFEST
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }
apache::vhost { 'php.example.com':
port => '80',
docroot => '#{apache_hash['doc_root']}/php',
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '#{apache_hash['doc_root']}/php/index.php':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
MANIFEST
it 'succeeds in puppeting php' do
apply_manifest(pp, catch_failures: true)
end
if (os[:family] == 'ubuntu' && os[:release] == '16.04') ||
(os[:family] == 'debian' && os[:release] =~ %r{9})
describe file("#{apache_hash['mod_dir']}/php7.0.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'debian' && os[:release] =~ %r{10}
describe file("#{apache_hash['mod_dir']}/php7.3.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'ubuntu' && os[:release] == '18.04'
describe file("#{apache_hash['mod_dir']}/php7.2.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'ubuntu' && os[:release] == '20.04'
describe file("#{apache_hash['mod_dir']}/php7.4.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
elsif os[:family] == 'redhat' && os[:release] =~ %r{^8}
describe file("#{apache_hash['mod_dir']}/php7.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
else
describe file("#{apache_hash['mod_dir']}/php5.conf") do
it { is_expected.to contain 'DirectoryIndex index.php' }
end
end
end
context 'custom extensions, php_flag, php_value, php_admin_flag, and php_admin_value' do
pp = <<-MANIFEST
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php':
extensions => ['.php','.php5'],
}
apache::vhost { 'php.example.com':
port => '80',
docroot => '#{apache_hash['doc_root']}/php',
php_values => { 'include_path' => '.:/usr/share/pear:/usr/bin/php', },
php_flags => { 'display_errors' => 'on', },
php_admin_values => { 'open_basedir' => '/var/www/php/:/usr/share/pear/', },
php_admin_flags => { 'engine' => 'on', },
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '#{apache_hash['doc_root']}/php/index.php5':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
MANIFEST
it 'succeeds in puppeting php' do
apply_manifest(pp, catch_failures: true)
end
describe file("#{apache_hash['vhost_dir']}/25-php.example.com.conf") do
it { is_expected.to contain ' php_flag display_errors on' }
it { is_expected.to contain ' php_value include_path ".:/usr/share/pear:/usr/bin/php"' }
it { is_expected.to contain ' php_admin_flag engine on' }
it { is_expected.to contain ' php_admin_value open_basedir /var/www/php/:/usr/share/pear/' }
end
end
end
end