setPreference('number_grouping_seperator', ',', 0, 'global'); $current_user->setPreference('decimal_seperator', '.', 0, 'global'); $current_user->save(); //Force reset on dec_sep and num_grp_sep because the dec_sep and num_grp_sep values are stored as static variables get_number_seperators(true); } public function tearDown() { unset($GLOBALS['current_user']); SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); get_number_seperators(true); } public function testUnformatNumber() { global $current_user; $testValue = "$100,000.50"; $unformattedValue = unformat_number($testValue); $this->assertEquals($unformattedValue, 100000.50, "Assert that $100,000.50 becomes 100000.50. Formatted value is: ".$unformattedValue); //Switch the num_grp_sep and dec_sep values $current_user->setPreference('num_grp_sep', '.'); $current_user->setPreference('dec_sep', ','); $current_user->save(); //Force reset on dec_sep and num_grp_sep because the dec_sep and num_grp_sep values are stored as static variables get_number_seperators(true); $testValue = "$100.000,50"; $unformattedValue = unformat_number($testValue); $this->assertEquals($unformattedValue, 100000.50, "Assert that $100.000,50 becomes 100000.50. Formatted value is: ".$unformattedValue); } public function testFormatNumber() { global $current_user; $testValue = "100000.50"; $formattedValue = format_number($testValue); $this->assertEquals($formattedValue, "100,000.50", "Assert that 100000.50 becomes 100,000.50. Formatted value is: ".$formattedValue); //Switch the num_grp_sep and dec_sep values $current_user->setPreference('num_grp_sep', '.'); $current_user->setPreference('dec_sep', ','); $current_user->save(); //Force reset on dec_sep and num_grp_sep because the dec_sep and num_grp_sep values are stored as static variables get_number_seperators(true); $testValue = "100000.50"; $formattedValue = format_number($testValue); $this->assertEquals($formattedValue, "100.000,50", "Assert that 100000.50 becomes 100.000,50. Formatted value is: ".$formattedValue); } } ?>