3 class Bug30709 extends Sugar_PHPUnit_Framework_TestCase {
6 //Create the language files with bad name
7 if(file_exists('custom/include/language/en_us.lang.php')) {
8 copy('custom/include/language/en_us.lang.php', 'custom/include/language/en_us.lang.php.backup');
11 //Simulate the .bak file that was created
12 if( $fh = @fopen('custom/include/language/en_us.lang.php.bak', 'w+') )
16 \$app_list_strings['this would have been missed!'] = array (
22 \$app_list_strings['a_test_1'] = array (
28 //a_test_1 is the same, nothing was wrong with it
29 \$app_list_strings['a_test_that_is_okay'] = array (
35 //b_test_2 has four entries, but "4"
36 \$app_list_strings['b_test_2'] = array (
43 //c_test_3 has four entries
44 \$app_list_strings['c_test_3'] = array (
51 \$GLOBALS['app_list_strings']['b_test_2'] = array (
58 \$GLOBALS['app_list_strings']['c_test_3'] = array (
66 \$GLOBALS['app_list_strings']['c_test_3'] = array (
80 //Simulate the .php file that was created
81 if( $fh = @fopen('custom/include/language/en_us.lang.php', 'w+') )
85 \$GLOBALS['app_list_strings']['a_test_that_is_okay'] = array (
91 \$GLOBALS['app_list_strings']['a_test__'] = array (
97 \$GLOBALS['app_list_strings']['b_test__'] = array (
104 \$GLOBALS['app_list_strings']['c_test__'] = array (
113 fputs( $fh, $string);
119 function tearDown() {
120 if(file_exists('custom/include/language/en_us.lang.php.backup')) {
121 copy('custom/include/language/en_us.lang.php.backup', 'custom/include/language/en_us.lang.php');
122 unlink('custom/include/language/en_us.lang.php.backup');
124 unlink('custom/include/language/en_us.lang.php');
127 if(file_exists('custom/include/language/en_us.lang.php.bak')) {
128 unlink('custom/include/language/en_us.lang.php.bak');
131 if(file_exists('custom/include/language/en_us.lang.php.php_bak')) {
132 unlink('custom/include/language/en_us.lang.php.php_bak');
135 $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
136 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
140 function test_dropdown_fixed() {
141 require_once('modules/UpgradeWizard/uw_utils.php');
144 //Check to make sure we don't have the buggy format where '$GLOBALS["app_list_strings"] = array (...' was declared
145 $contents = file_get_contents('custom/include/language/en_us.lang.php');
147 unset($GLOBALS['app_list_strings']);
148 require('custom/include/language/en_us.lang.php');
150 $this->assertTrue(isset($GLOBALS['app_list_strings']['this_would_have_been_missed_']));
152 preg_match_all('/a_test_that_is_okay/', $contents, $matches);
153 $this->assertEquals(count($matches[0]),1);
155 $this->assertEquals(count($GLOBALS['app_list_strings']['a_test_that_is_okay']),3);
157 preg_match_all('/b_test__/', $contents, $matches);
158 $this->assertEquals(count($matches[0]),2);
160 $this->assertEquals(count($GLOBALS['app_list_strings']['b_test__']),4);
162 preg_match_all('/c_test__/', $contents, $matches);
163 $this->assertEquals(count($matches[0]),2);
165 $this->assertEquals(count($GLOBALS['app_list_strings']['c_test__']),5);