Merge pull request #13259 from agh1/disabled-expired-mem
[civicrm-core.git] / tests / phpunit / CRM / Core / Smarty / plugins / CrmScopeTest.php
CommitLineData
9915ae36
TO
1<?php
2
aba1cd8b
EM
3/**
4 * Class CRM_Core_Smarty_plugins_CrmScopeTest
acb109b7 5 * @group headless
aba1cd8b 6 */
9915ae36 7class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase {
00be9182 8 public function setUp() {
9915ae36
TO
9 parent::setUp();
10 require_once 'CRM/Core/Smarty.php';
11
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();
15 }
16
e9479dcf
EM
17 /**
18 * @return array
19 */
00be9182 20 public function scopeCases() {
9915ae36
TO
21 $cases = array();
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}');
92915c55
TO
28 $cases[] = array(
29 'x=1 x=2 x=3 x=2 x=1',
408b79bf 30 '{crmScope x=1}x={$x} {crmScope x=2}x={$x} {crmScope x=3}x={$x}{/crmScope} x={$x}{/crmScope} x={$x}{/crmScope}',
92915c55 31 );
9915ae36 32 $cases[] = array('x=1,y=9', '{crmScope x=1 y=9}x={$x},y={$y}{/crmScope}');
92915c55
TO
33 $cases[] = array(
34 'x=1,y=9 x=1,y=8 x=1,y=9',
408b79bf 35 '{crmScope x=1 y=9}x={$x},y={$y} {crmScope y=8}x={$x},y={$y}{/crmScope} x={$x},y={$y}{/crmScope}',
92915c55 36 );
9915ae36
TO
37 $cases[] = array('x=', 'x={$x}');
38 return $cases;
39 }
40
41 /**
42 * @dataProvider scopeCases
1e1fdcf6
EM
43 * @param $expected
44 * @param $input
9915ae36 45 */
00be9182 46 public function testBlank($expected, $input) {
9915ae36
TO
47 $smarty = CRM_Core_Smarty::singleton();
48 $actual = $smarty->fetch('string:' . $input);
49 $this->assertEquals($expected, $actual, "Process input=[$input]");
50 }
51
52}