1 require 'spec_helper_acceptance'
3 describe 'apache::mod::php class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
6 vhost_dir = '/etc/apache2/sites-enabled'
7 mod_dir = '/etc/apache2/mods-available'
8 service_name = 'apache2'
10 vhost_dir = '/etc/httpd/conf.d'
11 mod_dir = '/etc/httpd/conf.d'
12 service_name = 'httpd'
14 vhost_dir = '/usr/local/etc/apache24/Vhosts'
15 mod_dir = '/usr/local/etc/apache24/Modules'
16 service_name = 'apache24'
18 vhost_dir = '/etc/apache2/vhosts.d'
19 mod_dir = '/etc/apache2/modules.d'
20 service_name = 'apache2'
23 context "default php config" do
24 it 'succeeds in puppeting php' do
27 mpm_module => 'prefork',
29 class { 'apache::mod::php': }
30 apache::vhost { 'php.example.com':
32 docroot => '/var/www/php',
34 host { 'php.example.com': ip => '127.0.0.1', }
35 file { '/var/www/php/index.php':
37 content => "<?php phpinfo(); ?>\\n",
40 apply_manifest(pp, :catch_failures => true)
43 describe service(service_name) do
44 it { is_expected.to be_enabled }
45 it { is_expected.to be_running }
48 describe file("#{mod_dir}/php5.conf") do
49 it { is_expected.to contain "DirectoryIndex index.php" }
52 it 'should answer to php.example.com' do
53 shell("/usr/bin/curl php.example.com:80") do |r|
54 expect(r.stdout).to match(/PHP Version/)
55 expect(r.exit_code).to eq(0)
60 context "custom extensions, php_flag, php_value, php_admin_flag, and php_admin_value" do
61 it 'succeeds in puppeting php' do
64 mpm_module => 'prefork',
66 class { 'apache::mod::php':
67 extensions => ['.php','.php5'],
69 apache::vhost { 'php.example.com':
71 docroot => '/var/www/php',
72 php_values => { 'include_path' => '.:/usr/share/pear:/usr/bin/php', },
73 php_flags => { 'display_errors' => 'on', },
74 php_admin_values => { 'open_basedir' => '/var/www/php/:/usr/share/pear/', },
75 php_admin_flags => { 'engine' => 'on', },
77 host { 'php.example.com': ip => '127.0.0.1', }
78 file { '/var/www/php/index.php5':
80 content => "<?php phpinfo(); ?>\\n",
83 apply_manifest(pp, :catch_failures => true)
86 describe service(service_name) do
87 it { is_expected.to be_enabled }
88 it { is_expected.to be_running }
91 describe file("#{vhost_dir}/25-php.example.com.conf") do
92 it { is_expected.to contain " php_flag display_errors on" }
93 it { is_expected.to contain " php_value include_path .:/usr/share/pear:/usr/bin/php" }
94 it { is_expected.to contain " php_admin_flag engine on" }
95 it { is_expected.to contain " php_admin_value open_basedir /var/www/php/:/usr/share/pear/" }
98 it 'should answer to php.example.com' do
99 shell("/usr/bin/curl php.example.com:80") do |r|
100 expect(r.stdout).to match(/\/usr\/share\/pear\//)
101 expect(r.exit_code).to eq(0)
106 context "provide custom config file" do
107 it 'succeeds in puppeting php' do
110 mpm_module => 'prefork',
112 class {'apache::mod::php':
113 content => '# somecontent',
116 apply_manifest(pp, :catch_failures => true)
119 describe file("#{mod_dir}/php5.conf") do
120 it { should contain "# somecontent" }
124 context "provide content and template config file" do
125 it 'succeeds in puppeting php' do
128 mpm_module => 'prefork',
130 class {'apache::mod::php':
131 content => '# somecontent',
132 template => 'apache/mod/php5.conf.erb',
135 apply_manifest(pp, :catch_failures => true)
138 describe file("#{mod_dir}/php5.conf") do
139 it { should contain "# somecontent" }