# Inspec test for recipe irrigate-php::php74

# The Inspec reference, with examples and extensive documentation, can be
# found at http://inspec.io/docs/reference/resources/

control 'php74' do
  describe command('yum repolist') do
    its('stdout') { should include 'remi-php74' }
    its('stdout') { should include 'remi-php74-debuginfo' }
    its('stdout') { should include 'remi74-safe' }
  end

  packages = %w(
    autoconf
    bzip2-devel
    epel-release
    freetype-devel
    gcc-c++
    glibc
    gmp-devel
    httpd-devel
    ImageMagick
    ImageMagick-devel
    libcurl-devel
    libdb4-devel
    libevent
    libjpeg-turbo
    libjpeg-turbo-devel
    libmcrypt
    libmcrypt-devel
    libmemcached
    libpng-devel
    libtiff
    libtiff-devel
    libxml2-devel
    make
    memcached
    mhash
    mhash-devel
    mod_ssl
    openssl-devel
    php74
    php74-php
    php74-php-bcmath
    php74-php-cli
    php74-php-common
    php74-php-devel
    php74-php-gd
    php74-php-gmp
    php74-php-ldap
    php74-php-mbstring
    php74-php-mysqlnd
    php74-php-opcache
    php74-php-pear
    php74-php-pecl-imagick
    php74-php-pecl-imagick-devel
    php74-php-pecl-mcrypt
    php74-php-pecl-memcache
    php74-php-pecl-memcached
    php74-php-pecl-redis5
    php74-php-pecl-ssh2
    php74-php-pecl-uploadprogress
    php74-php-pecl-zip
    php74-php-pgsql
    php74-php-phpiredis
    php74-php-soap
    php74-php-xml
    unixODBC
    unixODBC-devel
  )

  packages.each do |name|
    describe package name do
      it { should be_installed }
    end
  end

  require 'erb'
  template_sh = File.read('templates/default/remi-php74.sh.erb')
  rendered_content_sh = ERB.new(template_sh).result(binding)
  describe file '/etc/profile.d/remi-php74.sh' do
    it { should exist }
    its('owner') { should eq 'root' }
    its('group') { should eq 'root' }
    its('mode') { should cmp '0644' }
    its('content') { should eq rendered_content_sh }
  end

  describe file '/etc/opt/remi/php74/php.ini' do
    it { should exist }
    its('owner') { should eq 'root' }
    its('group') { should eq 'root' }
    its('mode') { should cmp '0644' }
  end

  describe file '/usr/local/bin/php74' do
    it { should be_symlink }
    its('link_path') { should eq '/opt/remi/php74/root/usr/bin/php' }
  end

  describe file '/usr/local/bin/php' do
    it { should be_symlink }
    its('link_path') { should eq '/opt/remi/php74/root/usr/bin/php' }
  end
end
