]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/Smarty/plugins/FunctionSugarTranslateTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / Smarty / plugins / FunctionSugarTranslateTest.php
1 <?php 
2
3 require_once 'include/Smarty/plugins/function.sugar_translate.php';
4 require_once 'include/Sugar_Smarty.php';
5
6 class FunctionSugarTranslateTest extends Sugar_PHPUnit_Framework_TestCase
7 {
8     public function providerJsEscapedSting()
9     {
10         return array(
11             array(
12                 "Friend's",
13                 "Friend\'s",
14                 ),
15             array(
16                 "Friend\'s",
17                 "Friend\\\\\\'s",
18                 ),
19             array(
20                 "Friend&#39;s",
21                 "Friend\'s",
22                 ),
23             array(
24                 "Friend&#39;'s",
25                 "Friend\'\'s",
26                 ),
27             array(
28                 "Friend&#039;s",
29                 "Friend\'s",
30                 ),
31             array(
32                 "Friend&#039;'s",
33                 "Friend\'\'s",
34                 ),
35             );
36     }
37
38     /**
39      * @dataProvider providerJsEscapedSting
40      * @ticket 41983
41      */
42     public function testJsEscapedSting($string, $returnedString) 
43     {
44         $langpack = new SugarTestLangPackCreator();
45         $langpack->setModString('LBL_TEST_JS_ESCAPED_STRING', $string, 'Contacts');
46         $langpack->save();
47
48         $smarty = new Sugar_Smarty;
49         
50         $this->assertEquals($returnedString, smarty_function_sugar_translate(
51             array(
52                 'label'  => 'LBL_TEST_JS_ESCAPED_STRING',
53                 'module' => 'Contacts',
54                 'for_js'  =>  true,
55             ),
56             $smarty)
57         );
58     }
59 }