INFRA-132 - FunctionDeclarationArgumentSpacing.SpaceBeforeEquals
[civicrm-core.git] / tests / phpunit / CRM / Core / Smarty / plugins / CrmScopeTest.php
CommitLineData
9915ae36
TO
1<?php
2
3require_once 'CiviTest/CiviUnitTestCase.php';
4
aba1cd8b
EM
5/**
6 * Class CRM_Core_Smarty_plugins_CrmScopeTest
7 */
9915ae36 8class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase {
00be9182 9 public function setUp() {
9915ae36
TO
10 parent::setUp();
11 require_once 'CRM/Core/Smarty.php';
12
13 // Templates should normally be file names, but for unit-testing it's handy to use "string:" notation
14 require_once 'CRM/Core/Smarty/resources/String.php';
15 civicrm_smarty_register_string_resource();
16 }
17
e9479dcf
EM
18 /**
19 * @return array
20 */
00be9182 21 public function scopeCases() {
9915ae36
TO
22 $cases = array();
23 $cases[] = array('', '{crmScope}{/crmScope}');
24 $cases[] = array('', '{crmScope x=1}{/crmScope}');
25 $cases[] = array('x=', 'x={$x}');
26 $cases[] = array('x=1', '{crmScope x=1}x={$x}{/crmScope}');
27 $cases[] = array('x=1', '{$x}{crmScope x=1}x={$x}{/crmScope}{$x}');
28 $cases[] = array('x=1 x=2 x=1', '{crmScope x=1}x={$x} {crmScope x=2}x={$x}{/crmScope} x={$x}{/crmScope}');
29 $cases[] = array('x=1 x=2 x=3 x=2 x=1', '{crmScope x=1}x={$x} {crmScope x=2}x={$x} {crmScope x=3}x={$x}{/crmScope} x={$x}{/crmScope} x={$x}{/crmScope}');
30 $cases[] = array('x=1,y=9', '{crmScope x=1 y=9}x={$x},y={$y}{/crmScope}');
31 $cases[] = array('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}');
32 $cases[] = array('x=', 'x={$x}');
33 return $cases;
34 }
35
36 /**
37 * @dataProvider scopeCases
38 */
00be9182 39 public function testBlank($expected, $input) {
9915ae36
TO
40 $smarty = CRM_Core_Smarty::singleton();
41 $actual = $smarty->fetch('string:' . $input);
42 $this->assertEquals($expected, $actual, "Process input=[$input]");
43 }
44
45}