Skip to content

Commit

Permalink
Merge pull request #715 from hunner/php-allow-custom-ext
Browse files Browse the repository at this point in the history
Add specs for #689
  • Loading branch information
mhaskel committed May 2, 2014
2 parents 82e3de9 + 8fb2dfd commit ca03c51
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions manifests/mod/php.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
$package_name = undef,
$package_ensure = 'present',
$path = undef,
$extensions = ['.php'],
) {
if ! defined(Class['apache::mod::prefork']) {
fail('apache::mod::php requires apache::mod::prefork; please enable mpm_module => \'prefork\' on Class[\'apache\']')
}
validate_array($extensions)
::apache::mod { 'php5':
package => $package_name,
package_ensure => $package_ensure,
Expand All @@ -16,6 +18,7 @@
include ::apache::mod::dir
Class['::apache::mod::mime'] -> Class['::apache::mod::dir'] -> Class['::apache::mod::php']

# Template uses $extensions
file { 'php5.conf':
ensure => file,
path => "${::apache::mod_dir}/php5.conf",
Expand Down
8 changes: 5 additions & 3 deletions spec/acceptance/mod_php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,23 @@ class { 'apache::mod::php': }
end
end

context "custom php admin_flag and php_admin_value" do
context "custom extensions, php_admin_flag, and php_admin_value" do
it 'succeeds in puppeting php' do
pp= <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }
class { 'apache::mod::php':
extensions => ['.php','.php5'],
}
apache::vhost { 'php.example.com':
port => '80',
docroot => '/var/www/php',
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 { '/var/www/php/index.php':
file { '/var/www/php/index.php5':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
Expand Down
8 changes: 8 additions & 0 deletions spec/classes/mod/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
:content => "LoadModule php5_module alternative-path\n"
) }
end
context "with alternative extensions" do let :pre_condition do
'class { "apache": }'
end
let :params do
{ :extensions => ['.php','.php5']}
end
it { should contain_file("php5.conf").with_content =~ /AddHandler php5-script .php .php5\n/ }
end
context "with specific version" do
let :pre_condition do
'class { "apache": }'
Expand Down
2 changes: 1 addition & 1 deletion templates/mod/php5.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddHandler php5-script <%= @extensions.flatten.compact.join(' ') %>
AddType text/html .php

#
Expand Down

0 comments on commit ca03c51

Please sign in to comment.