@@ -838,6 +838,205 @@ function validate_database(){
838838 refute_output
839839}
840840
841+ # ----------------------------------------------------------#
842+ # MULTIPHP #
843+ # ----------------------------------------------------------#
844+
845+ @test " Multiphp: Default php Backend version" {
846+ def_phpver=$( multiphp_default_version)
847+ multi_domain=" multiphp.${domain} "
848+
849+ run v-add-web-domain $user $multi_domain 198.18.0.125
850+ assert_success
851+ refute_output
852+
853+ echo -e " <?php\necho PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
854+ validate_web_domain $user $multi_domain " $def_phpver " ' php-test.php'
855+ rm " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
856+
857+ }
858+
859+ @test " Multiphp: Change backend version - PHP v5.6" {
860+ test_phpver=' 5.6'
861+ multi_domain=" multiphp.${domain} "
862+
863+ if [ ! -d " /etc/php/${test_phpver} /fpm/pool.d/" ]; then
864+ skip " PHP ${test_phpver} not installed"
865+ fi
866+
867+ run v-change-web-domain-backend-tpl $user $multi_domain ' PHP-5_6' ' yes'
868+ assert_success
869+ refute_output
870+
871+ # Changing web backend will create a php-fpm pool config in the corresponding php folder
872+ assert_file_exist " /etc/php/${test_phpver} /fpm/pool.d/${multi_domain} .conf"
873+
874+ # A single php-fpm pool config file must be present
875+ num_fpm_config_files=" $( find -L /etc/php/ -name " ${multi_domain} .conf" | wc -l) "
876+ assert_equal " $num_fpm_config_files " ' 1'
877+
878+ echo -e " <?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
879+ validate_web_domain $user $multi_domain " hestia-multiphptest:$test_phpver " ' php-test.php'
880+ rm " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
881+ }
882+
883+ @test " Multiphp: Change backend version - PHP v7.0" {
884+ test_phpver=' 7.0'
885+ multi_domain=" multiphp.${domain} "
886+
887+ if [ ! -d " /etc/php/${test_phpver} /fpm/pool.d/" ]; then
888+ skip " PHP ${test_phpver} not installed"
889+ fi
890+
891+ run v-change-web-domain-backend-tpl $user $multi_domain ' PHP-7_0' ' yes'
892+ assert_success
893+ refute_output
894+
895+ # Changing web backend will create a php-fpm pool config in the corresponding php folder
896+ assert_file_exist " /etc/php/${test_phpver} /fpm/pool.d/${multi_domain} .conf"
897+
898+ # A single php-fpm pool config file must be present
899+ num_fpm_config_files=" $( find -L /etc/php/ -name " ${multi_domain} .conf" | wc -l) "
900+ assert_equal " $num_fpm_config_files " ' 1'
901+
902+ echo -e " <?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
903+ validate_web_domain $user $multi_domain " hestia-multiphptest:$test_phpver " ' php-test.php'
904+ rm " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
905+ }
906+
907+ @test " Multiphp: Change backend version - PHP v7.1" {
908+ test_phpver=' 7.1'
909+ multi_domain=" multiphp.${domain} "
910+
911+ if [ ! -d " /etc/php/${test_phpver} /fpm/pool.d/" ]; then
912+ skip " PHP ${test_phpver} not installed"
913+ fi
914+
915+ run v-change-web-domain-backend-tpl $user $multi_domain ' PHP-7_1' ' yes'
916+ assert_success
917+ refute_output
918+
919+ # Changing web backend will create a php-fpm pool config in the corresponding php folder
920+ assert_file_exist " /etc/php/${test_phpver} /fpm/pool.d/${multi_domain} .conf"
921+
922+ # A single php-fpm pool config file must be present
923+ num_fpm_config_files=" $( find -L /etc/php/ -name " ${multi_domain} .conf" | wc -l) "
924+ assert_equal " $num_fpm_config_files " ' 1'
925+
926+ echo -e " <?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
927+ validate_web_domain $user $multi_domain " hestia-multiphptest:$test_phpver " ' php-test.php'
928+ rm " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
929+ }
930+
931+ @test " Multiphp: Change backend version - PHP v7.2" {
932+ test_phpver=' 7.2'
933+ multi_domain=" multiphp.${domain} "
934+
935+ if [ ! -d " /etc/php/${test_phpver} /fpm/pool.d/" ]; then
936+ skip " PHP ${test_phpver} not installed"
937+ fi
938+
939+ run v-change-web-domain-backend-tpl $user $multi_domain ' PHP-7_2' ' yes'
940+ assert_success
941+ refute_output
942+
943+ # Changing web backend will create a php-fpm pool config in the corresponding php folder
944+ assert_file_exist " /etc/php/${test_phpver} /fpm/pool.d/${multi_domain} .conf"
945+
946+ # A single php-fpm pool config file must be present
947+ num_fpm_config_files=" $( find -L /etc/php/ -name " ${multi_domain} .conf" | wc -l) "
948+ assert_equal " $num_fpm_config_files " ' 1'
949+
950+ echo -e " <?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
951+ validate_web_domain $user $multi_domain " hestia-multiphptest:$test_phpver " ' php-test.php'
952+ rm " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
953+ }
954+
955+ @test " Multiphp: Change backend version - PHP v7.3" {
956+ test_phpver=' 7.3'
957+ multi_domain=" multiphp.${domain} "
958+
959+ if [ ! -d " /etc/php/${test_phpver} /fpm/pool.d/" ]; then
960+ skip " PHP ${test_phpver} not installed"
961+ fi
962+
963+ run v-change-web-domain-backend-tpl $user $multi_domain ' PHP-7_3' ' yes'
964+ assert_success
965+ refute_output
966+
967+ # Changing web backend will create a php-fpm pool config in the corresponding php folder
968+ assert_file_exist " /etc/php/${test_phpver} /fpm/pool.d/${multi_domain} .conf"
969+
970+ # A single php-fpm pool config file must be present
971+ num_fpm_config_files=" $( find -L /etc/php/ -name " ${multi_domain} .conf" | wc -l) "
972+ assert_equal " $num_fpm_config_files " ' 1'
973+
974+ echo -e " <?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
975+ validate_web_domain $user $multi_domain " hestia-multiphptest:$test_phpver " ' php-test.php'
976+ rm " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
977+ }
978+
979+ @test " Multiphp: Change backend version - PHP v7.4" {
980+ test_phpver=' 7.4'
981+ multi_domain=" multiphp.${domain} "
982+
983+ if [ ! -d " /etc/php/${test_phpver} /fpm/pool.d/" ]; then
984+ skip " PHP ${test_phpver} not installed"
985+ fi
986+
987+ run v-change-web-domain-backend-tpl $user $multi_domain ' PHP-7_4' ' yes'
988+ assert_success
989+ refute_output
990+
991+ # Changing web backend will create a php-fpm pool config in the corresponding php folder
992+ assert_file_exist " /etc/php/${test_phpver} /fpm/pool.d/${multi_domain} .conf"
993+
994+ # A single php-fpm pool config file must be present
995+ num_fpm_config_files=" $( find -L /etc/php/ -name " ${multi_domain} .conf" | wc -l) "
996+ assert_equal " $num_fpm_config_files " ' 1'
997+
998+ echo -e " <?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
999+ validate_web_domain $user $multi_domain " hestia-multiphptest:$test_phpver " ' php-test.php'
1000+ rm " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
1001+ }
1002+
1003+ @test " Multiphp: Change backend version - PHP v8.0" {
1004+ test_phpver=' 8.0'
1005+ multi_domain=" multiphp.${domain} "
1006+
1007+ if [ ! -d " /etc/php/${test_phpver} /fpm/pool.d/" ]; then
1008+ skip " PHP ${test_phpver} not installed"
1009+ fi
1010+
1011+ run v-change-web-domain-backend-tpl $user $multi_domain ' PHP-8_0' ' yes'
1012+ assert_success
1013+ refute_output
1014+
1015+ # Changing web backend will create a php-fpm pool config in the corresponding php folder
1016+ assert_file_exist " /etc/php/${test_phpver} /fpm/pool.d/${multi_domain} .conf"
1017+
1018+ # A single php-fpm pool config file must be present
1019+ num_fpm_config_files=" $( find -L /etc/php/ -name " ${multi_domain} .conf" | wc -l) "
1020+ assert_equal " $num_fpm_config_files " ' 1'
1021+
1022+ echo -e " <?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > " $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php"
1023+ validate_web_domain $user $multi_domain " hestia-multiphptest:$test_phpver " ' php-test.php'
1024+ rm $HOMEDIR /$user /web/$multi_domain /public_html/php-test.php
1025+ }
1026+
1027+ @test " Multiphp: Cleanup" {
1028+ multi_domain=" multiphp.${domain} "
1029+
1030+ run v-delete-web-domain $user $multi_domain ' yes'
1031+ assert_success
1032+ refute_output
1033+
1034+ # No php-fpm pool config file must be present
1035+ num_fpm_config_files=" $( find -L /etc/php/ -name " ${multi_domain} .conf" | wc -l) "
1036+ assert_equal " $num_fpm_config_files " ' 0'
1037+ }
1038+
1039+
8411040# ----------------------------------------------------------#
8421041# DNS #
8431042# ----------------------------------------------------------#
0 commit comments