From 7f795c935806d6d9989aa950ad6a60f5ddd311bd Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 17 Jan 2022 11:36:26 +1300 Subject: [PATCH] Max out smarty grumpiness --- CRM/Core/Smarty.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Smarty.php b/CRM/Core/Smarty.php index 49a40a4fe3ff..095e9f8bd03d 100644 --- a/CRM/Core/Smarty.php +++ b/CRM/Core/Smarty.php @@ -138,7 +138,7 @@ private function initialize() { } $this->register_function('crmURL', ['CRM_Utils_System', 'crmURL']); - if (CRM_Utils_Constant::value('CIVICRM_SMARTY_DEFAULT_ESCAPE')) { + if (CRM_Utils_Constant::value('CIVICRM_SMARTY_DEFAULT_ESCAPE') || self::isTestEnvironment()) { // When default escape is enabled if the core escape is called before // any custom escaping is done the modifier_escape function is not // found, so require_once straight away. Note this was hit on the basic @@ -158,6 +158,17 @@ private function initialize() { } } + /** + * Is this a test environment. + * + * Currently we just check the class name but it is possible to run tests in CMS frameworks. + * + * @return bool + */ + private static function isTestEnvironment(): bool { + return CRM_Core_Config::singleton()->userFramework === 'UnitTests'; + } + /** * Static instance provider. *