]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/MassUpdateTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / MassUpdateTest.php
1 <?php
2 require_once 'include/MassUpdate.php';
3 require_once 'include/dir_inc.php';
4
5 class MassUpdateTest extends Sugar_PHPUnit_Framework_TestCase
6 {
7     public function setUp()
8     {
9                 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
10                 $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
11         }
12
13     public function tearDown()
14     {
15         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
16         unset($GLOBALS['current_user']);
17         unset($GLOBALS['app_strings']);
18     }
19     
20     /**
21      * @group bug12300
22      */
23     public function testAdddateWorksWithMultiByteCharacters()
24     {
25         $mass = new MassUpdate();
26         $displayname = "开始日期:";
27         $varname = "date_start";
28         
29         $result = $mass->addDate($displayname , $varname);
30         $pos_f = strrpos($result, $GLOBALS['app_strings']['LBL_MASSUPDATE_DATE']);
31         $this->assertTrue((bool) $pos_f);
32     }
33     
34     /**
35      * @group bug23900
36      */
37     public function testAddStatus() 
38     {
39         $mass = new MassUpdate();
40         $options = array (
41             '10' => 'ten',
42             '20' => 'twenty',
43             '30' => 'thirty',
44             );
45         $result = $mass->addStatus('test_dom', 'test_dom', $options);
46         preg_match_all('/value=[\'\"].*?[\'\"]/si', $result, $matches);
47         $this->assertTrue(isset($matches));
48         $this->assertTrue($matches[0][0] == "value=''");
49         $this->assertTrue($matches[0][1] == "value='10'");
50         $this->assertTrue($matches[0][3] == "value='30'");              
51     }
52     
53     /**
54      * @group bug23900
55      */
56     public function testAddStatusMulti() 
57     {
58         $mass = new MassUpdate();
59         $options = array (
60             '10' => 'ten',
61             '20' => 'twenty',
62             '30' => 'thirty',
63             );
64         
65         $result = $mass->addStatusMulti('test_dom', 'test_dom', $options);
66         preg_match_all('/value=[\'\"].*?[\'\"]/si', $result, $matches);
67         $this->assertTrue(isset($matches));
68         $this->assertTrue($matches[0][0] == "value=''");
69         $this->assertTrue($matches[0][1] == "value='10'");
70         $this->assertTrue($matches[0][3] == "value='30'");              
71     }
72 }