]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/UpgradeWizard/Bug30709_Part_2_Test.php
Release 6.2.0
[Github/sugarcrm.git] / tests / modules / UpgradeWizard / Bug30709_Part_2_Test.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5  * 
6  * This program is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  * 
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
16  * details.
17  * 
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  * 
23  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25  * 
26  * The interactive user interfaces in modified source and object code versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  * 
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the "Powered by
32  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33  * technical reasons, the Appropriate Legal Notices must display the words
34  * "Powered by SugarCRM".
35  ********************************************************************************/
36
37 class Bug30709_Part_2_Test extends  Sugar_PHPUnit_Framework_TestCase {
38
39 function setUp() {
40     //Create the language files with bad name
41     if(file_exists('custom/include/language/en_us.lang.php')) {
42        copy('custom/include/language/en_us.lang.php', 'custom/include/language/en_us.lang.php.backup');
43     }
44         
45     if( $fh = @fopen('custom/include/language/en_us.lang.php', 'w+') )
46     {
47 $string = <<<EOQ
48 <?php
49 \$GLOBALS['app_list_strings'] = array (
50   'test'=>array(
51     'abc' => 'ABC',
52     'cbs' => 'CBS',
53     'nbc' => 'NBC',
54   ),
55   'lead_source_dom' =>
56   array (
57     '' => '',
58     'Cold Call' => 'Cold Call',
59     'Existing Customer' => 'Existing Customer',
60     'Self Generated' => 'Self Generated',
61     'Employee' => 'Employee',
62     'Partner' => 'Partner',
63     'Public Relations' => 'Public Relations',
64     'Direct Mail' => 'Direct Mail',
65     'Conference' => 'Conference',
66     'Trade Show' => 'Trade Show',
67     'Web Site' => 'Web Site',
68     'Word of mouth' => 'Word of mouth',
69     'Email' => 'Email',
70     'Campaign'=>'Campaign',
71     'Other' => 'Other',
72   ),
73   'opportunity_type_dom' =>
74   array (
75     '' => '',
76     'Existing Business' => 'Existing Business',
77     'New Business' => 'New Business',
78   ),
79   'moduleList' =>
80   array (
81     'Home' => 'Home',
82     'Dashboard' => 'Dashboard',
83     'Contacts' => 'Contacts',
84     'Accounts' => 'Accounts Module',
85     'Opportunities' => 'Opportunities',
86     'Cases' => 'Cases',
87     'Notes' => 'Notes',
88     'Calls' => 'Calls',
89     'Emails' => 'Emails',
90     'Meetings' => 'Meetings',
91     'Tasks' => 'Tasks',
92     'Calendar' => 'Calendar',
93     'Leads' => 'Leads',
94     'Currencies' => 'Currencies',
95     'Contracts' => 'Contracts',
96     'Quotes' => 'Quotes',
97     'Products' => 'Products',
98     'ProductCategories' => 'Product Categories',
99     'ProductTypes' => 'Product Types',
100     'ProductTemplates' => 'Product Catalog',
101     'Reports' => 'Reports',
102     'Reports_1' => 'Reports',
103     'Forecasts' => 'Forecasts',
104     'ForecastSchedule' => 'Forecast Schedule',
105     'MergeRecords' => 'Merge Records',
106     'Quotas' => 'Quotas',
107     'Teams' => 'Teams',
108     'Activities' => 'Activities',
109     'Bugs' => 'Bug Tracker',
110     'Feeds' => 'RSS',
111     'iFrames' => 'My Portal',
112     'TimePeriods' => 'Time Periods',
113     'Project' => 'Projects',
114     'ProjectTask' => 'Project Tasks',
115     'Campaigns' => 'Campaigns',
116     'CampaignLog' => 'Campaign Log',
117     'Documents' => 'Documents',
118     'Sync' => 'Sync',
119     'WorkFlow' => 'Work Flow',
120     'Users' => 'Users',
121     'Releases' => 'Releases',
122     'Prospects' => 'Targets',
123     'Queues' => 'Queues',
124     'EmailMarketing' => 'Email Marketing',
125     'EmailTemplates' => 'Email Templates',
126     'ProspectLists' => 'Target Lists',
127     'SavedSearch' => 'Saved Searches',
128     'Trackers' => 'Trackers',
129     'TrackerPerfs' => 'Tracker Performance',
130     'TrackerSessions' => 'Tracker Sessions',
131     'TrackerQueries' => 'Tracker Queries',
132     'FAQ' => 'FAQ',
133     'Newsletters' => 'Newsletters',
134     'SugarFeed' => 'Sugar Feed',
135     'Library' => 'Library',
136     'EmailAddresses' => 'Email Address',
137     'KBDocuments' => 'Knowledge Base',
138     'my_personal_module' => 'My Personal Module',    
139   ),
140 );
141
142 \$GLOBALS['app_strings']['LBL_TEST'] = 'This is a test';
143 EOQ;
144        fputs( $fh, $string);
145        fclose( $fh );
146     }
147 }
148
149 function tearDown() {
150     if(file_exists('custom/include/language/en_us.lang.php.backup')) {
151        copy('custom/include/language/en_us.lang.php.backup', 'custom/include/language/en_us.lang.php');
152        unlink('custom/include/language/en_us.lang.php.backup');  
153     } else {
154        unlink('custom/include/language/en_us.lang.php');
155     }
156     
157     if(file_exists('custom/include/language/en_us.lang.php.bak')) {
158        unlink('custom/include/language/en_us.lang.php.bak');
159     }   
160
161     $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
162     $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
163 }
164
165 function test_dropdown_fixed() {        
166     require_once('modules/UpgradeWizard/uw_utils.php');
167     fix_dropdown_list();
168         
169     //Check to make sure we don't have the buggy format where '$GLOBALS["app_list_strings"] = array (...' was declared
170     $contents = file_get_contents('custom/include/language/en_us.lang.php');
171     //$this->assertFalse(preg_match('/\$GLOBALS\[\s*[\"|\']app_list_strings[\"|\']\s*\]\s+=\s+array\s+\(/', $contents));
172
173     unset($GLOBALS['app_list_strings']);
174     require('custom/include/language/en_us.lang.php');
175     $this->assertEquals(count($GLOBALS['app_list_strings']),2);
176     $this->assertTrue(isset($GLOBALS['app_list_strings']['moduleList']['my_personal_module']));
177     $this->assertEquals($GLOBALS['app_list_strings']['moduleList']['Accounts'],'Accounts Module');
178     $this->assertEquals(count($GLOBALS['app_strings']),1);
179     $this->assertEquals($GLOBALS['app_strings']['LBL_TEST'],'This is a test');
180 }
181
182
183 }
184
185 ?>