Browse files

MDL-27863 moodlelib: - fixed testcase faliure in MDL-27577

  • Loading branch information...
1 parent 57e034c commit ec059157674fe75f50dda6e8a11389b4a15dfdbe Rajesh Taneja committed Jun 15, 2011
Showing with 27 additions and 0 deletions.
  1. +27 −0 lib/simpletest/testmoodlelib.php
View
27 lib/simpletest/testmoodlelib.php
@@ -863,9 +863,21 @@ public function test_userdate() {
$oldlocale = setlocale(LC_TIME, '0');
setlocale(LC_TIME, 'en_AU.UTF-8');
+ //set default timezone to Australia/Perth, else time calulated
+ //will not match expected values. Before that save system defaults.
+ $systemdefaulttimezone = date_default_timezone_get();
+ date_default_timezone_set('Australia/Perth');
+
+ //get instance of textlib for strtolower
+ $textlib = textlib_get_instance();
foreach ($testvalues as $vals) {
$USER->timezone = $vals['usertimezone'];
$actualoutput = userdate($vals['time'], '%A, %d %B %Y, %I:%M %p', $vals['timezone']);
+
+ //On different systems case of AM PM changes so compare case insenitive
+ $vals['expectedoutput'] = $textlib->strtolower($vals['expectedoutput']);
+ $actualoutput = $textlib->strtolower($actualoutput);
+
$this->assertEqual($vals['expectedoutput'], $actualoutput,
"Expected: {$vals['expectedoutput']} => Actual: {$actualoutput},
Please check if timezones are updated (Site adminstration -> location -> update timezone)");
@@ -879,6 +891,8 @@ public function test_userdate() {
$CFG->forcetimezone = $cfgforcetimezone;
}
+ //restore system default values.
+ date_default_timezone_set($systemdefaulttimezone);
setlocale(LC_TIME, $oldlocale);
}
@@ -1023,6 +1037,13 @@ public function test_make_timestamp() {
$oldlocale = setlocale(LC_TIME, '0');
setlocale(LC_TIME, 'en_AU.UTF-8');
+ //set default timezone to Australia/Perth, else time calulated
+ //will not match expected values. Before that save system defaults.
+ $systemdefaulttimezone = date_default_timezone_get();
+ date_default_timezone_set('Australia/Perth');
+
+ //get instance of textlib for strtolower
+ $textlib = textlib_get_instance();
//Test make_timestamp with all testvals and assert if anything wrong.
foreach ($testvalues as $vals) {
$USER->timezone = $vals['usertimezone'];
@@ -1037,6 +1058,10 @@ public function test_make_timestamp() {
$vals['applydst']
);
+ //On different systems case of AM PM changes so compare case insenitive
+ $vals['expectedoutput'] = $textlib->strtolower($vals['expectedoutput']);
+ $actualoutput = $textlib->strtolower($actualoutput);
+
$this->assertEqual($vals['expectedoutput'], $actualoutput,
"Expected: {$vals['expectedoutput']} => Actual: {$actualoutput},
Please check if timezones are updated (Site adminstration -> location -> update timezone)");
@@ -1050,6 +1075,8 @@ public function test_make_timestamp() {
$CFG->forcetimezone = $cfgforcetimezone;
}
+ //restore system default values.
+ date_default_timezone_set($systemdefaulttimezone);
setlocale(LC_TIME, $oldlocale);
}
}

0 comments on commit ec05915

Please sign in to comment.