From ecf875301062319541b210600363c95f972fa33d Mon Sep 17 00:00:00 2001 From: Carl George Date: Dec 17 2020 16:50:11 +0000 Subject: Add module-aware php tests --- diff --git a/tests/p_php/0_install_php-cli.sh b/tests/p_php/0_install_php-cli.sh index 24a93ff..92bf070 100755 --- a/tests/p_php/0_install_php-cli.sh +++ b/tests/p_php/0_install_php-cli.sh @@ -2,5 +2,6 @@ # Author: Christoph Galuschka t_Log "Running $0 - attempting to install php-cli." +t_SkipReleaseGreaterThan 7 'use module-aware tests instead' t_InstallPackage php-cli diff --git a/tests/p_php/10-php-test.sh b/tests/p_php/10-php-test.sh index 82f57bc..6508534 100755 --- a/tests/p_php/10-php-test.sh +++ b/tests/p_php/10-php-test.sh @@ -3,6 +3,7 @@ # Author: Christoph Galuschka t_Log "Running $0 - php test: looking for Zend Engine in phpinfo()." +t_SkipReleaseGreaterThan 7 'use module-aware tests instead' FILE='/var/tmp/php-test.php' diff --git a/tests/p_php/20-php-mysql-test.sh b/tests/p_php/20-php-mysql-test.sh index 5417f1d..f827e49 100755 --- a/tests/p_php/20-php-mysql-test.sh +++ b/tests/p_php/20-php-mysql-test.sh @@ -4,6 +4,7 @@ # reusing the script from LAMP-Tests t_Log "Running $0 - php-cli basic interaction with mysql test." +t_SkipReleaseGreaterThan 7 'use module-aware tests instead' # Install php-mysql/php-mysqld module depending on version # we need a working and running mysql server diff --git a/tests/p_php_7.2/10_php_api.sh b/tests/p_php_7.2/10_php_api.sh new file mode 100755 index 0000000..c445c6f --- /dev/null +++ b/tests/p_php_7.2/10_php_api.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +t_Log "Running $0 - verify PHP API in phpinfo()" +t_SkipReleaseLessThan 8 'no modularity' + +t_EnableModuleStream php:7.2 +t_InstallPackage php-cli + +t_Log "Executing phpinfo()" +output=$(php -d 'date.timezone=UTC' -r 'phpinfo();') +t_CheckExitStatus $? + +API='20170718' + +t_Log "Verifying PHP API matches $API" +grep -q "PHP API => $API" <<< $output +t_CheckExitStatus $? + +t_RemovePackage php-cli +t_ResetModule php httpd nginx diff --git a/tests/p_php_7.2/20_php_mariadb.sh b/tests/p_php_7.2/20_php_mariadb.sh new file mode 100755 index 0000000..244e050 --- /dev/null +++ b/tests/p_php_7.2/20_php_mariadb.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +t_Log "Running $0 - PHP/MariaDB interaction" +t_SkipReleaseLessThan 8 'no modularity' + +t_EnableModuleStream php:7.2 +t_InstallPackageMinimal php-cli php-mysqlnd mariadb-server + +t_Log "starting mariadb service" +systemctl --quiet start mariadb +t_CheckExitStatus $? + +t_Log "create a test database" +mysql << EOF +DROP DATABASE IF EXISTS phptests; +CREATE DATABASE phptests; +USE phptests; +CREATE TABLE tests (name VARCHAR(20)); +GRANT ALL ON phptests.* TO 'centos'@'localhost' IDENTIFIED BY 'qa'; +FLUSH PRIVILEGES; +EOF +t_CheckExitStatus $? + +t_Log "write to test database via PHP" +php << EOF &> /dev/null + +EOF +t_CheckExitStatus $? + +t_Log "read from test database via PHP" +php << EOF | grep -q '1' + +EOF +t_CheckExitStatus $? + +t_Log "stopping mariadb service" +systemctl --quiet stop mariadb +t_CheckExitStatus $? + +t_Log "deleting database files" +find /var/lib/mysql -mindepth 1 -delete +t_CheckExitStatus $? + +t_RemovePackage php-cli php-mysqlnd mariadb-server +t_ResetModule php httpd nginx mariadb diff --git a/tests/p_php_7.3/10_php_api.sh b/tests/p_php_7.3/10_php_api.sh new file mode 100755 index 0000000..4463b0a --- /dev/null +++ b/tests/p_php_7.3/10_php_api.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +t_Log "Running $0 - verify PHP API in phpinfo()" +t_SkipReleaseLessThan 8 'no modularity' + +t_EnableModuleStream php:7.3 +t_InstallPackage php-cli + +t_Log "Executing phpinfo()" +output=$(php -d 'date.timezone=UTC' -r 'phpinfo();') +t_CheckExitStatus $? + +API='20180731' + +t_Log "Verifying PHP API matches $API" +grep -q "PHP API => $API" <<< $output +t_CheckExitStatus $? + +t_RemovePackage php-cli +t_ResetModule php httpd nginx diff --git a/tests/p_php_7.3/20_php_mariadb.sh b/tests/p_php_7.3/20_php_mariadb.sh new file mode 100755 index 0000000..c60b09c --- /dev/null +++ b/tests/p_php_7.3/20_php_mariadb.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +t_Log "Running $0 - PHP/MariaDB interaction" +t_SkipReleaseLessThan 8 'no modularity' + +t_EnableModuleStream php:7.3 +t_InstallPackageMinimal php-cli php-mysqlnd mariadb-server + +t_Log "starting mariadb service" +systemctl --quiet start mariadb +t_CheckExitStatus $? + +t_Log "create a test database" +mysql << EOF +DROP DATABASE IF EXISTS phptests; +CREATE DATABASE phptests; +USE phptests; +CREATE TABLE tests (name VARCHAR(20)); +GRANT ALL ON phptests.* TO 'centos'@'localhost' IDENTIFIED BY 'qa'; +FLUSH PRIVILEGES; +EOF +t_CheckExitStatus $? + +t_Log "write to test database via PHP" +php << EOF &> /dev/null + +EOF +t_CheckExitStatus $? + +t_Log "read from test database via PHP" +php << EOF | grep -q '1' + +EOF +t_CheckExitStatus $? + +t_Log "stopping mariadb service" +systemctl --quiet stop mariadb +t_CheckExitStatus $? + +t_Log "deleting database files" +find /var/lib/mysql -mindepth 1 -delete +t_CheckExitStatus $? + +t_RemovePackage php-cli php-mysqlnd mariadb-server +t_ResetModule php httpd nginx mariadb