4 * Class CRM_Core_Smarty_plugins_CrmScopeTest
7 class CRM_Core_Smarty_plugins_CrmScopeTest
extends CiviUnitTestCase
{
8 public function setUp() {
10 require_once 'CRM/Core/Smarty.php';
12 // Templates should normally be file names, but for unit-testing it's handy to use "string:" notation
13 require_once 'CRM/Core/Smarty/resources/String.php';
14 civicrm_smarty_register_string_resource();
20 public function scopeCases() {
22 $cases[] = array('', '{crmScope}{/crmScope}');
23 $cases[] = array('', '{crmScope x=1}{/crmScope}');
24 $cases[] = array('x=', 'x={$x}');
25 $cases[] = array('x=1', '{crmScope x=1}x={$x}{/crmScope}');
26 $cases[] = array('x=1', '{$x}{crmScope x=1}x={$x}{/crmScope}{$x}');
27 $cases[] = array('x=1 x=2 x=1', '{crmScope x=1}x={$x} {crmScope x=2}x={$x}{/crmScope} x={$x}{/crmScope}');
29 'x=1 x=2 x=3 x=2 x=1',
30 '{crmScope x=1}x={$x} {crmScope x=2}x={$x} {crmScope x=3}x={$x}{/crmScope} x={$x}{/crmScope} x={$x}{/crmScope}',
32 $cases[] = array('x=1,y=9', '{crmScope x=1 y=9}x={$x},y={$y}{/crmScope}');
34 'x=1,y=9 x=1,y=8 x=1,y=9',
35 '{crmScope x=1 y=9}x={$x},y={$y} {crmScope y=8}x={$x},y={$y}{/crmScope} x={$x},y={$y}{/crmScope}',
37 $cases[] = array('x=', 'x={$x}');
42 * @dataProvider scopeCases
46 public function testBlank($expected, $input) {
47 $smarty = CRM_Core_Smarty
::singleton();
48 $actual = $smarty->fetch('string:' . $input);
49 $this->assertEquals($expected, $actual, "Process input=[$input]");