3 class Bug32382Test extends Sugar_PHPUnit_Framework_TestCase
5 public function setUp()
7 //Create the language files with bad name
8 if(file_exists('custom/include/language/en_us.lang.php')) {
9 copy('custom/include/language/en_us.lang.php', 'custom/include/language/en_us.lang.php.backup');
12 //Simulate the .bak file that was created
13 if( $fh = @fopen('custom/include/language/en_us.lang.php.bak', 'w+') )
17 \$app_list_strings['this would have been missed!'] = array (
23 \$app_list_strings['a_test_1'] = array (
29 //a_test_1 is the same, nothing was wrong with it
30 \$app_list_strings['a_test_that_is_okay'] = array (
36 //b_test_2 has four entries, but "4"
37 \$app_list_strings['b_test_2'] = array (
44 //c_test_3 has four entries
45 \$app_list_strings['c_test_3'] = array (
52 \$GLOBALS['app_list_strings']['b_test_2'] = array (
59 \$GLOBALS['app_list_strings']['c_test_3'] = array (
67 \$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 (
111 fputs( $fh, $string);
117 public function tearDown()
119 if(file_exists('custom/include/language/en_us.lang.php.backup')) {
120 copy('custom/include/language/en_us.lang.php.backup', 'custom/include/language/en_us.lang.php');
121 unlink('custom/include/language/en_us.lang.php.backup');
123 unlink('custom/include/language/en_us.lang.php');
126 if(file_exists('custom/include/language/en_us.lang.php.bak')) {
127 unlink('custom/include/language/en_us.lang.php.bak');
130 if(file_exists('custom/include/language/en_us.lang.php.php_bak')) {
131 unlink('custom/include/language/en_us.lang.php.php_bak');
134 $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
135 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
138 public function test_dropdown_fixed()
140 require_once('modules/UpgradeWizard/uw_utils.php');
143 //Check to make sure we don't have the buggy format where '$GLOBALS["app_list_strings"] = array (...' was declared
144 $contents = file_get_contents('custom/include/language/en_us.lang.php');
146 unset($GLOBALS['app_list_strings']);
147 require('custom/include/language/en_us.lang.php');
149 $this->assertTrue(isset($GLOBALS['app_list_strings']['this_would_have_been_missed_']), "Assert that 'this would have been missed! key was fixed");
151 preg_match_all('/a_test_that_is_okay/', $contents, $matches);
152 $this->assertEquals(count($matches[0]), 1, "Assert that a_test_is_okay entry exists");
154 $this->assertEquals(count($GLOBALS['app_list_strings']['a_test_that_is_okay']), 3, "Assert that a_test_that_is_okay has 3 items");
156 preg_match_all('/b_test__/', $contents, $matches);
157 $this->assertEquals(count($matches[0]), 2, "Assert that b_test__ is declared twice");
159 $this->assertEquals(count($GLOBALS['app_list_strings']['b_test__']), 4, "Assert that b_test__ is additive and has 4 entries");
161 preg_match_all('/c_test__/', $contents, $matches);
162 $this->assertEquals(count($matches[0]), 2, "Assert that c_test__ is declared twice");
164 $this->assertEquals(count($GLOBALS['app_list_strings']['c_test__']), 5, "Assert that c_test__ is additive and contains 5 entries");