]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/UpgradeWizard/Bug30709_Part_2_Test.php
Added unit tests.
[Github/sugarcrm.git] / tests / modules / UpgradeWizard / Bug30709_Part_2_Test.php
1 <?php
2 class Bug30709_Part_2_Test extends  Sugar_PHPUnit_Framework_TestCase {
3
4 function setUp() {
5     //Create the language files with bad name
6     if(file_exists('custom/include/language/en_us.lang.php')) {
7        copy('custom/include/language/en_us.lang.php', 'custom/include/language/en_us.lang.php.backup');
8     }
9         
10     if( $fh = @fopen('custom/include/language/en_us.lang.php', 'w+') )
11     {
12 $string = <<<EOQ
13 <?php
14 \$GLOBALS['app_list_strings'] = array (
15   'test'=>array(
16     'abc' => 'ABC',
17     'cbs' => 'CBS',
18     'nbc' => 'NBC',
19   ),
20   'lead_source_dom' =>
21   array (
22     '' => '',
23     'Cold Call' => 'Cold Call',
24     'Existing Customer' => 'Existing Customer',
25     'Self Generated' => 'Self Generated',
26     'Employee' => 'Employee',
27     'Partner' => 'Partner',
28     'Public Relations' => 'Public Relations',
29     'Direct Mail' => 'Direct Mail',
30     'Conference' => 'Conference',
31     'Trade Show' => 'Trade Show',
32     'Web Site' => 'Web Site',
33     'Word of mouth' => 'Word of mouth',
34     'Email' => 'Email',
35     'Campaign'=>'Campaign',
36     'Other' => 'Other',
37   ),
38   'opportunity_type_dom' =>
39   array (
40     '' => '',
41     'Existing Business' => 'Existing Business',
42     'New Business' => 'New Business',
43   ),
44   'moduleList' =>
45   array (
46     'Home' => 'Home',
47     'Dashboard' => 'Dashboard',
48     'Contacts' => 'Contacts',
49     'Accounts' => 'Accounts Module',
50     'Opportunities' => 'Opportunities',
51     'Cases' => 'Cases',
52     'Notes' => 'Notes',
53     'Calls' => 'Calls',
54     'Emails' => 'Emails',
55     'Meetings' => 'Meetings',
56     'Tasks' => 'Tasks',
57     'Calendar' => 'Calendar',
58     'Leads' => 'Leads',
59     'Currencies' => 'Currencies',
60     'Contracts' => 'Contracts',
61     'Quotes' => 'Quotes',
62     'Products' => 'Products',
63     'ProductCategories' => 'Product Categories',
64     'ProductTypes' => 'Product Types',
65     'ProductTemplates' => 'Product Catalog',
66     'Reports' => 'Reports',
67     'Reports_1' => 'Reports',
68     'Forecasts' => 'Forecasts',
69     'ForecastSchedule' => 'Forecast Schedule',
70     'MergeRecords' => 'Merge Records',
71     'Quotas' => 'Quotas',
72     'Teams' => 'Teams',
73     'Activities' => 'Activities',
74     'Bugs' => 'Bug Tracker',
75     'Feeds' => 'RSS',
76     'iFrames' => 'My Portal',
77     'TimePeriods' => 'Time Periods',
78     'Project' => 'Projects',
79     'ProjectTask' => 'Project Tasks',
80     'Campaigns' => 'Campaigns',
81     'CampaignLog' => 'Campaign Log',
82     'Documents' => 'Documents',
83     'Sync' => 'Sync',
84     'WorkFlow' => 'Work Flow',
85     'Users' => 'Users',
86     'Releases' => 'Releases',
87     'Prospects' => 'Targets',
88     'Queues' => 'Queues',
89     'EmailMarketing' => 'Email Marketing',
90     'EmailTemplates' => 'Email Templates',
91     'ProspectLists' => 'Target Lists',
92     'SavedSearch' => 'Saved Searches',
93     'Trackers' => 'Trackers',
94     'TrackerPerfs' => 'Tracker Performance',
95     'TrackerSessions' => 'Tracker Sessions',
96     'TrackerQueries' => 'Tracker Queries',
97     'FAQ' => 'FAQ',
98     'Newsletters' => 'Newsletters',
99     'SugarFeed' => 'Sugar Feed',
100     'Library' => 'Library',
101     'EmailAddresses' => 'Email Address',
102     'KBDocuments' => 'Knowledge Base',
103     'my_personal_module' => 'My Personal Module',    
104   ),
105 );
106
107 \$GLOBALS['app_strings']['LBL_TEST'] = 'This is a test';
108 EOQ;
109        fputs( $fh, $string);
110        fclose( $fh );
111     }
112 }
113
114 function tearDown() {
115     if(file_exists('custom/include/language/en_us.lang.php.backup')) {
116        copy('custom/include/language/en_us.lang.php.backup', 'custom/include/language/en_us.lang.php');
117        unlink('custom/include/language/en_us.lang.php.backup');  
118     } else {
119        unlink('custom/include/language/en_us.lang.php');
120     }
121     
122     if(file_exists('custom/include/language/en_us.lang.php.bak')) {
123        unlink('custom/include/language/en_us.lang.php.bak');
124     }   
125
126     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
127     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
128 }
129
130 function test_dropdown_fixed() {        
131     require_once('modules/UpgradeWizard/uw_utils.php');
132     fix_dropdown_list();
133         
134     //Check to make sure we don't have the buggy format where '$GLOBALS["app_list_strings"] = array (...' was declared
135     $contents = file_get_contents('custom/include/language/en_us.lang.php');
136     //$this->assertFalse(preg_match('/\$GLOBALS\[\s*[\"|\']app_list_strings[\"|\']\s*\]\s+=\s+array\s+\(/', $contents));
137
138     unset($GLOBALS['app_list_strings']);
139     require('custom/include/language/en_us.lang.php');
140     $this->assertEquals(count($GLOBALS['app_list_strings']),2);
141     $this->assertTrue(isset($GLOBALS['app_list_strings']['moduleList']['my_personal_module']));
142     $this->assertEquals($GLOBALS['app_list_strings']['moduleList']['Accounts'],'Accounts Module');
143     $this->assertEquals(count($GLOBALS['app_strings']),1);
144     $this->assertEquals($GLOBALS['app_strings']['LBL_TEST'],'This is a test');
145 }
146
147
148 }
149
150 ?>