tests/phpunit - Declare `@group headless`
[civicrm-core.git] / tests / phpunit / CRM / Core / Smarty / plugins / CrmScopeTest.php
1 <?php
2
3 /**
4 * Class CRM_Core_Smarty_plugins_CrmScopeTest
5 * @group headless
6 */
7 class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase {
8 public function setUp() {
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
17 /**
18 * @return array
19 */
20 public function scopeCases() {
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}');
28 $cases[] = array(
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}',
31 );
32 $cases[] = array('x=1,y=9', '{crmScope x=1 y=9}x={$x},y={$y}{/crmScope}');
33 $cases[] = array(
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}',
36 );
37 $cases[] = array('x=', 'x={$x}');
38 return $cases;
39 }
40
41 /**
42 * @dataProvider scopeCases
43 * @param $expected
44 * @param $input
45 */
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]");
50 }
51
52 }