diff --git a/attributes/default.rb b/attributes/default.rb index f2d03577d..5f8ad17e5 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -50,14 +50,14 @@ when 'debian' default['php']['conf_dir'] = '/etc/php5/cli' case node['platform'] - when 'ubuntu' - if node['platform_version'].to_f >= 12.10 - default['php']['ext_conf_dir'] = '/etc/php5/mods-available' - else - default['php']['ext_conf_dir'] = '/etc/php5/conf.d' - end + when 'ubuntu' + if node['platform_version'].to_f >= 12.10 + default['php']['ext_conf_dir'] = '/etc/php5/mods-available' else default['php']['ext_conf_dir'] = '/etc/php5/conf.d' + end + else + default['php']['ext_conf_dir'] = '/etc/php5/conf.d' end default['php']['packages'] = %w(php5-cgi php5 php5-dev php5-cli php-pear) default['php']['fpm_package'] = 'php5-fpm' diff --git a/libraries/matchers.rb b/libraries/matchers.rb index 21fdd9746..3546e5f40 100644 --- a/libraries/matchers.rb +++ b/libraries/matchers.rb @@ -3,12 +3,15 @@ def install_php_pear(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:php_pear, :install, resource_name) end + def remove_php_pear(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:php_pear, :remove, resource_name) end + def upgrade_php_pear(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:php_pear, :upgrade, resource_name) end + def purge_php_pear(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:php_pear, :purge, resource_name) end @@ -17,12 +20,15 @@ def purge_php_pear(resource_name) def discover_php_pear_channel(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:php_pear_channel, :discover, resource_name) end + def remove_php_pear_channel(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:php_pear_channel, :remove, resource_name) end + def update_php_pear_channel(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:php_pear_channel, :update, resource_name) end + def add_php_pear_channel(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:php_pear_channel, :add, resource_name) end diff --git a/providers/fpm_pool.rb b/providers/fpm_pool.rb index 8626ee647..90dc0adc0 100644 --- a/providers/fpm_pool.rb +++ b/providers/fpm_pool.rb @@ -26,10 +26,9 @@ def install_fpm_package # Install the FPM pacakge for this platform, if it's available # Fail the run if it's an unsupported OS (FPM pacakge name not populated) # also, this is skipped for source - if node['php']['install_method'] == 'source' - return - end - if node['php']['fpm_package'] == nil + return if node['php']['install_method'] == 'source' + + if node['php']['fpm_package'].nil? raise 'PHP-FPM package not found (you probably have an unsupported distro)' else file node['php']['fpm_default_conf'] do @@ -50,8 +49,8 @@ def register_fpm_service action :install do # Ensure the FPM pacakge is installed, and the service is registered - install_fpm_package() - register_fpm_service() + install_fpm_package + register_fpm_service # I wanted to have this as a function in itself, but doing this seems to # break testing suites? t = template "#{node['php']['fpm_pooldir']}/#{new_resource.pool_name}.conf" do @@ -77,7 +76,7 @@ def register_fpm_service action :uninstall do # Ensure the FPM pacakge is installed, and the service is registered - register_fpm_service() + register_fpm_service # Delete the FPM pool. f = file "#{node['php']['fpm_pooldir']}/#{new_resource.pool_name}" do action :delete diff --git a/providers/pear.rb b/providers/pear.rb index fe0c80249..10375870c 100644 --- a/providers/pear.rb +++ b/providers/pear.rb @@ -64,7 +64,6 @@ def whyrun_supported? Chef::Log.info("Removing #{@new_resource}") remove_package(@current_resource.package_name, @new_resource.version) end - else end end @@ -175,13 +174,13 @@ def remove_package(name, version) def enable_package(name) execute "/usr/sbin/php5enmod #{name}" do - only_if { platform?('ubuntu') && node['platform_version'].to_f >= 12.04 && ::File.exists?('/usr/sbin/php5enmod') } + only_if { platform?('ubuntu') && node['platform_version'].to_f >= 12.04 && ::File.exist?('/usr/sbin/php5enmod') } end end def disable_package(name) execute "/usr/sbin/php5dismod #{name}" do - only_if { platform?('ubuntu') && node['platform_version'].to_f >= 12.04 && ::File.exists?('/usr/sbin/php5dismod') } + only_if { platform?('ubuntu') && node['platform_version'].to_f >= 12.04 && ::File.exist?('/usr/sbin/php5dismod') } end end diff --git a/recipes/module_gd.rb b/recipes/module_gd.rb index c177a38e3..4236389bd 100644 --- a/recipes/module_gd.rb +++ b/recipes/module_gd.rb @@ -24,7 +24,7 @@ el5_range => 'php53-gd', 'default' => 'php-gd' }, - 'freebsd' => { + 'freebsd' => { 'default' => 'php56-gd' }, 'default' => 'php5-gd' diff --git a/spec/recipes/default_spec.rb b/spec/recipes/default_spec.rb index c6414e38f..905658d63 100644 --- a/spec/recipes/default_spec.rb +++ b/spec/recipes/default_spec.rb @@ -4,10 +4,10 @@ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) } context 'on freebsd' do - let(:chef_run) { + let(:chef_run) do ChefSpec::SoloRunner.new(platform: 'freebsd', version: '10.0') .converge(described_recipe) - } + end it 'installs php' do expect(chef_run).to install_package('php56') @@ -30,5 +30,4 @@ ) end end - end diff --git a/test/integration/default/serverspec/php_spec.rb b/test/integration/default/serverspec/php_spec.rb index 3d9bdb724..13a270244 100644 --- a/test/integration/default/serverspec/php_spec.rb +++ b/test/integration/default/serverspec/php_spec.rb @@ -4,17 +4,15 @@ set :backend, :exec describe 'PHP' do - it 'has php' do - expect(command('php -v').exit_status).to eq(0) + expect(command('php -v').exit_status).to eq(0) end it 'has the pear.php.net channel' do - expect(command('pear list-channels').stdout).to include('pear.php.net') + expect(command('pear list-channels').stdout).to include('pear.php.net') end it 'has the pecl.php.net channel' do - expect(command('pear list-channels').stdout).to include('pecl.php.net') + expect(command('pear list-channels').stdout).to include('pecl.php.net') end - end