From ce178428476558e56f1ec115e5e520efacf9ba73 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 10 Jun 2023 14:40:06 -0700 Subject: [PATCH] CrmScopeTest - Use explicit value for default/global example Before: We rely on default/global value of `x=UNDEFINED` or `x=NULL`. But this is a bit tempermental. After: Clear default. Note: There's a prior commit which adds another test (CRM_Core_SmartyTest) where the global value is specifically undefined or specifically null. So that still has coverage. --- tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php b/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php index 03b5d695a6..36c3e2497d 100644 --- a/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php +++ b/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php @@ -24,9 +24,9 @@ class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase { $cases = []; $cases[] = ['', '{crmScope}{/crmScope}']; $cases[] = ['', '{crmScope x=1}{/crmScope}']; - $cases[] = ['x=', 'x={$x}']; + $cases[] = ['x=0', 'x={$x}']; $cases[] = ['x=1', '{crmScope x=1}x={$x}{/crmScope}']; - $cases[] = ['x=1', '{$x}{crmScope x=1}x={$x}{/crmScope}{$x}']; + $cases[] = ['x=0 x=1 x=0', 'x={$x} {crmScope x=1}x={$x}{/crmScope} x={$x}']; $cases[] = ['x=1 x=2 x=1', '{crmScope x=1}x={$x} {crmScope x=2}x={$x}{/crmScope} x={$x}{/crmScope}']; $cases[] = [ 'x=1 x=2 x=3 x=2 x=1', @@ -37,7 +37,7 @@ class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase { 'x=1,y=9 x=1,y=8 x=1,y=9', '{crmScope x=1 y=9}x={$x},y={$y} {crmScope y=8}x={$x},y={$y}{/crmScope} x={$x},y={$y}{/crmScope}', ]; - $cases[] = ['x=', 'x={$x}']; + $cases[] = ['x=0', 'x={$x}']; return $cases; } @@ -48,6 +48,7 @@ class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase { */ public function testBlank($expected, $input) { $smarty = CRM_Core_Smarty::singleton(); + $smarty->assign('x', 0); $actual = $smarty->fetch('string:' . $input); $this->assertEquals($expected, $actual, "Process input=[$input]"); } -- 2.25.1