From 327108365920032341bd10f251adfd84916656af Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Wed, 22 Jul 2020 00:21:14 -0400 Subject: [PATCH] avoid messages not being shown --- templates/CRM/common/info.tpl | 2 +- tests/phpunit/CRM/Core/SessionTest.php | 48 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/CRM/Core/SessionTest.php diff --git a/templates/CRM/common/info.tpl b/templates/CRM/common/info.tpl index aa000e5790..002f88f31a 100644 --- a/templates/CRM/common/info.tpl +++ b/templates/CRM/common/info.tpl @@ -8,7 +8,7 @@ +--------------------------------------------------------------------+ *} {* Handles display of passed $infoMessage. *} -{if $infoMessage} +{if $infoMessage or $infoTitle}
{$infoTitle} diff --git a/tests/phpunit/CRM/Core/SessionTest.php b/tests/phpunit/CRM/Core/SessionTest.php new file mode 100644 index 0000000000..16588876aa --- /dev/null +++ b/tests/phpunit/CRM/Core/SessionTest.php @@ -0,0 +1,48 @@ +clearTemplateVars(); + } + + /** + * Test that the template setStatus uses gives reasonable output. + * Test with text only. + */ + public function testSetStatusWithTextOnly() { + $smarty = CRM_Core_Smarty::singleton(); + $smarty->assign('infoMessage', 'Your refridgerator door is open.'); + $output = $smarty->fetch('CRM/common/info.tpl'); + $this->assertStringContainsString('Your refridgerator door is open.', $output); + } + + /** + * Test that the template setStatus uses gives reasonable output. + * Test with title only. + */ + public function testSetStatusWithTitleOnly() { + $smarty = CRM_Core_Smarty::singleton(); + $smarty->assign('infoTitle', 'Error Error Error.'); + $output = $smarty->fetch('CRM/common/info.tpl'); + $this->assertStringContainsString('Error Error Error.', $output); + } + + /** + * Test that the template setStatus uses gives reasonable output. + * Test with both text and title. + */ + public function testSetStatusWithBoth() { + $smarty = CRM_Core_Smarty::singleton(); + $smarty->assign('infoTitle', 'Spoiler alert!'); + $smarty->assign('infoMessage', 'Your refridgerator door is open.'); + $output = $smarty->fetch('CRM/common/info.tpl'); + $this->assertStringContainsString('Spoiler alert!', $output); + $this->assertStringContainsString('Your refridgerator door is open.', $output); + } + +} -- 2.25.1