Skip to content

Commit 7a019a5

Browse files
LupulScIT-Raphael
authored andcommitted
Add multiphp 5.6 - 8.0 tests
1 parent b6baa7a commit 7a019a5

File tree

1 file changed

+185
-0
lines changed

1 file changed

+185
-0
lines changed

test/test.bats

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,191 @@ function validate_webmail_domain() {
506506
}
507507

508508

509+
#----------------------------------------------------------#
510+
# MULTIPHP #
511+
#----------------------------------------------------------#
512+
513+
@test "Multiphp: Default php Backend version" {
514+
def_phpver=$(multiphp_default_version)
515+
multi_domain="multiphp.${domain}"
516+
517+
run v-add-web-domain $user $multi_domain 198.18.0.125
518+
assert_success
519+
refute_output
520+
521+
echo -e "<?php\necho PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
522+
validate_web_domain $user $multi_domain "$def_phpver" 'php-test.php'
523+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
524+
525+
}
526+
527+
@test "Multiphp: Change backend version - PHP v5.6" {
528+
test_phpver='5.6'
529+
multi_domain="multiphp.${domain}"
530+
531+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
532+
skip "PHP ${test_phpver} not installed"
533+
fi
534+
535+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-5_6' 'yes'
536+
assert_success
537+
refute_output
538+
539+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
540+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
541+
542+
# A single php-fpm pool config file must be present
543+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
544+
assert_equal "$num_fpm_config_files" '1'
545+
546+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
547+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
548+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
549+
}
550+
551+
@test "Multiphp: Change backend version - PHP v7.0" {
552+
test_phpver='7.0'
553+
multi_domain="multiphp.${domain}"
554+
555+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
556+
skip "PHP ${test_phpver} not installed"
557+
fi
558+
559+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_0' 'yes'
560+
assert_success
561+
refute_output
562+
563+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
564+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
565+
566+
# A single php-fpm pool config file must be present
567+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
568+
assert_equal "$num_fpm_config_files" '1'
569+
570+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
571+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
572+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
573+
}
574+
575+
@test "Multiphp: Change backend version - PHP v7.1" {
576+
test_phpver='7.1'
577+
multi_domain="multiphp.${domain}"
578+
579+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
580+
skip "PHP ${test_phpver} not installed"
581+
fi
582+
583+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_1' 'yes'
584+
assert_success
585+
refute_output
586+
587+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
588+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
589+
590+
# A single php-fpm pool config file must be present
591+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
592+
assert_equal "$num_fpm_config_files" '1'
593+
594+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
595+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
596+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
597+
}
598+
599+
@test "Multiphp: Change backend version - PHP v7.2" {
600+
test_phpver='7.2'
601+
multi_domain="multiphp.${domain}"
602+
603+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
604+
skip "PHP ${test_phpver} not installed"
605+
fi
606+
607+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_2' 'yes'
608+
assert_success
609+
refute_output
610+
611+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
612+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
613+
614+
# A single php-fpm pool config file must be present
615+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
616+
assert_equal "$num_fpm_config_files" '1'
617+
618+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
619+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
620+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
621+
}
622+
623+
@test "Multiphp: Change backend version - PHP v7.3" {
624+
test_phpver='7.3'
625+
multi_domain="multiphp.${domain}"
626+
627+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
628+
skip "PHP ${test_phpver} not installed"
629+
fi
630+
631+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_3' 'yes'
632+
assert_success
633+
refute_output
634+
635+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
636+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
637+
638+
# A single php-fpm pool config file must be present
639+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
640+
assert_equal "$num_fpm_config_files" '1'
641+
642+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
643+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
644+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
645+
}
646+
647+
@test "Multiphp: Change backend version - PHP v7.4" {
648+
test_phpver='7.4'
649+
multi_domain="multiphp.${domain}"
650+
651+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
652+
skip "PHP ${test_phpver} not installed"
653+
fi
654+
655+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_4' 'yes'
656+
assert_success
657+
refute_output
658+
659+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
660+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
661+
662+
# A single php-fpm pool config file must be present
663+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
664+
assert_equal "$num_fpm_config_files" '1'
665+
666+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
667+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
668+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
669+
}
670+
671+
@test "Multiphp: Change backend version - PHP v8.0" {
672+
test_phpver='8.0'
673+
multi_domain="multiphp.${domain}"
674+
675+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
676+
skip "PHP ${test_phpver} not installed"
677+
fi
678+
679+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-8_0' 'yes'
680+
assert_success
681+
refute_output
682+
683+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
684+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
685+
686+
# A single php-fpm pool config file must be present
687+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
688+
assert_equal "$num_fpm_config_files" '1'
689+
690+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
691+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
692+
rm $HOMEDIR/$user/web/$multi_domain/public_html/php-test.php
693+
}
509694
#----------------------------------------------------------#
510695
# DNS #
511696
#----------------------------------------------------------#

0 commit comments

Comments
 (0)