]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/Smarty/plugins/FunctionMultienumToArrayTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / Smarty / plugins / FunctionMultienumToArrayTest.php
1 <?php
2 require_once('include/Smarty/plugins/function.multienum_to_array.php');
3 require_once 'include/Sugar_Smarty.php';
4
5 class FunctionMultienumToArrayTest extends Sugar_PHPUnit_Framework_TestCase
6 {
7     public function setUp()
8     {
9         $this->_smarty = new Sugar_Smarty;
10     }
11     
12     public function providerPassedString()
13     {
14         return array(
15             array("Employee^,^Boss","Cold Call",array('Employee','Boss')),
16             array("^Employee^,^Boss^","Cold Call",array('Employee','Boss')),
17             array("^Employee^","Cold Call",array('Employee')),
18             array("Employee","Cold Call",array('Employee')),
19             array("","^Cold Call^",array("Cold Call")),
20             array(array("Employee"),"Cold Call",array("Employee")),
21             array(NULL,array("Employee"),array("Employee")),
22             );
23     }
24     
25     /**
26      * @group bug21574
27      * @dataProvider providerPassedString
28      */
29         public function testPassedString(
30         $string,
31         $default,
32         $result
33         )
34     {
35         $params = array();
36         $params['string']  = $string;
37         $params['default'] = $default;
38         
39         $this->assertEquals($result, smarty_function_multienum_to_array($params, $this->_smarty));
40     }
41         
42         public function testAssignSmartyVariable()
43     {
44         $params = array();
45         $params['string']  = "^Employee^";
46         $params['default'] = "Cold Call";
47                 $params['assign'] = "multi";
48                 smarty_function_multienum_to_array($params, $this->_smarty);
49         
50         $this->assertEquals(
51             $this->_smarty->get_template_vars($params['assign']),
52             array("Employee")
53         );
54     }
55 }