commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / tests / phpunit / CRM / Core / Smarty / plugins / CrmScopeTest.php
1 <?php
2
3 require_once 'CiviTest/CiviUnitTestCase.php';
4
5 /**
6 * Class CRM_Core_Smarty_plugins_CrmScopeTest
7 */
8 class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase {
9 public function setUp() {
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
18 /**
19 * @return array
20 */
21 public function scopeCases() {
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(
30 'x=1 x=2 x=3 x=2 x=1',
31 '{crmScope x=1}x={$x} {crmScope x=2}x={$x} {crmScope x=3}x={$x}{/crmScope} x={$x}{/crmScope} x={$x}{/crmScope}',
32 );
33 $cases[] = array('x=1,y=9', '{crmScope x=1 y=9}x={$x},y={$y}{/crmScope}');
34 $cases[] = array(
35 'x=1,y=9 x=1,y=8 x=1,y=9',
36 '{crmScope x=1 y=9}x={$x},y={$y} {crmScope y=8}x={$x},y={$y}{/crmScope} x={$x},y={$y}{/crmScope}',
37 );
38 $cases[] = array('x=', 'x={$x}');
39 return $cases;
40 }
41
42 /**
43 * @dataProvider scopeCases
44 * @param $expected
45 * @param $input
46 */
47 public function testBlank($expected, $input) {
48 $smarty = CRM_Core_Smarty::singleton();
49 $actual = $smarty->fetch('string:' . $input);
50 $this->assertEquals($expected, $actual, "Process input=[$input]");
51 }
52
53 }