From 41be0e7fb959398ff9ad5cc306c98a05f4717f0e Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Wed, 4 Sep 2024 16:15:31 +0200 Subject: [PATCH] Set environment variable `CIVICRM_SMARTY_AUTOLOAD_PATH` in Docker container to avoid a PHP error --- tests/docker-phpunit.sh | 11 +++++++++++ tests/docker-prepare.sh | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/docker-phpunit.sh b/tests/docker-phpunit.sh index 2b0fc69..37b04c9 100755 --- a/tests/docker-phpunit.sh +++ b/tests/docker-phpunit.sh @@ -9,6 +9,17 @@ if [ ! -e tools/phpunit/vendor/bin ]; then "$SCRIPT_DIR/docker-prepare.sh" fi +# CIVICRM_SMARTY_AUTOLOAD_PATH is not set in the container's civicrm.settings.php so we have to do it here. +# Otherwise this results in this error: +# Fatal error: Cannot declare class Smarty, because the name is already in use in /var/www/html/sites/all/modules/civicrm/packages/smarty5/Smarty.php on line 4 +# +smarty=$(printf '%s\n' /var/www/html/sites/all/modules/civicrm/packages/smarty* | sort -r | head -n1) +if [ -e "$smarty/Smarty.php" ]; then + export CIVICRM_SMARTY_AUTOLOAD_PATH="$smarty/Smarty.php" +elif [ -e "$smarty/vendor/autoload.php" ]; then + export CIVICRM_SMARTY_AUTOLOAD_PATH="$smarty/vendor/autoload.php" +fi + export XDEBUG_MODE=coverage # TODO: Remove when not needed, anymore. # In Docker container with CiviCRM 5.5? all deprecations are reported as direct diff --git a/tests/docker-prepare.sh b/tests/docker-prepare.sh index 2eea5cf..60cc170 100755 --- a/tests/docker-prepare.sh +++ b/tests/docker-prepare.sh @@ -1,8 +1,8 @@ #!/bin/bash set -eu -o pipefail -XCM_VERSION=1.12.0 -IDENTITYTRACKER_VERSION=1.4-alpha4 +XCM_VERSION=1.13.1 +IDENTITYTRACKER_VERSION=1.4.0 EXT_DIR=$(dirname "$(dirname "$(realpath "$0")")") EXT_NAME=$(basename "$EXT_DIR")