Merge branch 'MDL-50050-master' of git://github.com/lameze/moodle

This commit is contained in:
Dan Poltawski 2016-04-05 16:23:24 +01:00
commit 245192accc
4 changed files with 22 additions and 122 deletions

View file

@ -46,20 +46,6 @@ class core_date_legacy_testcase extends advanced_testcase {
$this->assertSame('99', $user->timezone);
}
public function test_get_list_of_timezones() {
// Use timezones that are not problematic, this way we may test before
// and after the big tz rewrite.
$list = get_list_of_timezones();
$this->assertDebuggingCalled();
$this->assertArrayHasKey('Europe/London', $list);
$this->assertArrayHasKey('Pacific/Auckland', $list);
$this->assertArrayHasKey('America/New_York', $list);
$this->assertArrayHasKey('Europe/Berlin', $list);
$this->assertArrayHasKey('Europe/Prague', $list);
$this->assertArrayHasKey('Australia/Perth', $list);
$this->assertArrayHasKey('Australia/Lord_Howe', $list);
}
public function test_get_user_timezone() {
global $CFG, $USER;
@ -133,44 +119,6 @@ class core_date_legacy_testcase extends advanced_testcase {
$this->assertSame('Europe/Berlin', $tz);
}
public function test_get_timezone_offset() {
// This is a useless function, the timezone offset may be changing!
$this->assertSame(60 * 60 * -5, get_timezone_offset('America/New_York'));
$this->assertDebuggingCalled();
$this->assertSame(60 * 60 * -1, get_timezone_offset(-1));
$this->assertSame(60 * 60 * 1, get_timezone_offset(1));
$this->assertSame(60 * 60 * 1, get_timezone_offset('Europe/Prague'));
$this->assertSame(60 * 60 * 8, get_timezone_offset('Australia/Perth'));
$this->assertSame(60 * 60 * 12, get_timezone_offset('Pacific/Auckland'));
// Known half an hour offsets.
$this->assertEquals(60 * 60 * -4.5, get_timezone_offset('-4.5'));
$this->assertEquals(60 * 60 * -4.5, get_timezone_offset('America/Caracas'));
$this->assertEquals(60 * 60 * 4.5, get_timezone_offset('4.5'));
$this->assertEquals(60 * 60 * 4.5, get_timezone_offset('Asia/Kabul'));
$this->assertEquals(60 * 60 * 5.5, get_timezone_offset('5.5'));
$this->assertEquals(60 * 60 * 5.5, get_timezone_offset('Asia/Kolkata'));
$this->assertEquals(60 * 60 * 6.5, get_timezone_offset('6.5'));
$this->assertEquals(60 * 60 * 6.5, get_timezone_offset('Asia/Rangoon'));
$this->assertEquals(60 * 60 * 9.5, get_timezone_offset('9.5'));
$this->assertEquals(60 * 60 * 9.5, get_timezone_offset('Australia/Darwin'));
$this->resetDebugging();
}
public function test_get_user_timezone_offset() {
// This is a useless function, the timezone offset may be changing!
$this->assertSame(-5.0, get_user_timezone_offset('America/New_York'));
$this->assertDebuggingCalled();
$this->assertSame(-1.0, get_user_timezone_offset(-1));
$this->assertSame(1.0, get_user_timezone_offset(1));
$this->assertSame(1.0, get_user_timezone_offset('Europe/Prague'));
$this->assertSame(8.0, get_user_timezone_offset('Australia/Perth'));
$this->assertSame(12.0, get_user_timezone_offset('Pacific/Auckland'));
$this->resetDebugging();
}
public function test_dst_offset_on() {
$time = gmmktime(1, 1, 1, 3, 1, 2015);
$this->assertSame(3600, dst_offset_on($time, 'Pacific/Auckland'));

View file

@ -302,7 +302,6 @@ class core_statslib_testcase extends advanced_testcase {
$dataset = $this->load_xml_data_file(__DIR__."/fixtures/statslib-test01.xml");
$DB->delete_records('log');
// Don't ask. I don't think get_timezone_offset works correctly.
$date = new DateTime('now', core_date::get_server_timezone_object());
$day = self::DAY - $date->getOffset();