2012-07-08 13:12:58 -04:00
|
|
|
<?php
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
namespace Sabre\VObject;
|
|
|
|
|
|
|
|
class TimezoneUtilTest extends \PHPUnit_Framework_TestCase {
|
2012-07-08 13:12:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider getMapping
|
|
|
|
*/
|
|
|
|
function testCorrectTZ($timezoneName) {
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$tz = new \DateTimeZone($timezoneName);
|
2012-07-08 13:12:58 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMapping() {
|
|
|
|
|
|
|
|
// PHPUNit requires an array of arrays
|
|
|
|
return array_map(
|
|
|
|
function($value) {
|
|
|
|
return array($value);
|
|
|
|
},
|
2012-08-11 04:07:19 -04:00
|
|
|
TimeZoneUtil::$map
|
2012-07-08 13:12:58 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testExchangeMap() {
|
|
|
|
|
|
|
|
$vobj = <<<HI
|
|
|
|
BEGIN:VCALENDAR
|
|
|
|
METHOD:REQUEST
|
|
|
|
VERSION:2.0
|
|
|
|
BEGIN:VTIMEZONE
|
|
|
|
TZID:foo
|
|
|
|
X-MICROSOFT-CDO-TZID:2
|
|
|
|
BEGIN:STANDARD
|
|
|
|
DTSTART:16010101T030000
|
|
|
|
TZOFFSETFROM:+0200
|
|
|
|
TZOFFSETTO:+0100
|
|
|
|
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
|
|
|
|
END:STANDARD
|
|
|
|
BEGIN:DAYLIGHT
|
|
|
|
DTSTART:16010101T020000
|
|
|
|
TZOFFSETFROM:+0100
|
|
|
|
TZOFFSETTO:+0200
|
|
|
|
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU
|
|
|
|
END:DAYLIGHT
|
|
|
|
END:VTIMEZONE
|
|
|
|
BEGIN:VEVENT
|
|
|
|
DTSTAMP:20120416T092149Z
|
|
|
|
DTSTART;TZID="foo":20120418T1
|
|
|
|
00000
|
|
|
|
SUMMARY:Begin Unterhaltsreinigung
|
|
|
|
UID:040000008200E00074C5B7101A82E0080000000010DA091DC31BCD01000000000000000
|
|
|
|
0100000008FECD2E607780649BE5A4C9EE6418CBC
|
|
|
|
DTEND;TZID="Sarajevo, Skopje, Sofija, Vilnius, Warsaw, Zagreb":20120418T103
|
|
|
|
000
|
|
|
|
END:VEVENT
|
|
|
|
END:VCALENDAR
|
|
|
|
HI;
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$tz = TimeZoneUtil::getTimeZone('foo', Reader::read($vobj));
|
2012-07-08 13:12:58 -04:00
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$this->assertEquals(new \DateTimeZone('Europe/Sarajevo'), $tz);
|
2012-07-08 13:12:58 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testUnknownExchangeId() {
|
|
|
|
|
|
|
|
$vobj = <<<HI
|
|
|
|
BEGIN:VCALENDAR
|
|
|
|
METHOD:REQUEST
|
|
|
|
VERSION:2.0
|
|
|
|
BEGIN:VTIMEZONE
|
|
|
|
TZID:foo
|
|
|
|
X-MICROSOFT-CDO-TZID:2000
|
|
|
|
BEGIN:STANDARD
|
|
|
|
DTSTART:16010101T030000
|
|
|
|
TZOFFSETFROM:+0200
|
|
|
|
TZOFFSETTO:+0100
|
|
|
|
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
|
|
|
|
END:STANDARD
|
|
|
|
BEGIN:DAYLIGHT
|
|
|
|
DTSTART:16010101T020000
|
|
|
|
TZOFFSETFROM:+0100
|
|
|
|
TZOFFSETTO:+0200
|
|
|
|
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU
|
|
|
|
END:DAYLIGHT
|
|
|
|
END:VTIMEZONE
|
|
|
|
BEGIN:VEVENT
|
|
|
|
DTSTAMP:20120416T092149Z
|
|
|
|
DTSTART;TZID="foo":20120418T1
|
|
|
|
00000
|
|
|
|
SUMMARY:Begin Unterhaltsreinigung
|
|
|
|
UID:040000008200E00074C5B7101A82E0080000000010DA091DC31BCD01000000000000000
|
|
|
|
0100000008FECD2E607780649BE5A4C9EE6418CBC
|
|
|
|
DTEND;TZID="Sarajevo, Skopje, Sofija, Vilnius, Warsaw, Zagreb":20120418T103
|
|
|
|
000
|
|
|
|
END:VEVENT
|
|
|
|
END:VCALENDAR
|
|
|
|
HI;
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$tz = TimeZoneUtil::getTimeZone('foo', Reader::read($vobj));
|
2012-07-08 13:12:58 -04:00
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$this->assertEquals(new \DateTimeZone(date_default_timezone_get()), $tz);
|
2012-07-08 13:12:58 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testWindowsTimeZone() {
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$tz = TimeZoneUtil::getTimeZone('Eastern Standard Time');
|
|
|
|
$this->assertEquals(new \DateTimeZone('America/New_York'), $tz);
|
2012-07-08 13:12:58 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testFallBack() {
|
|
|
|
|
|
|
|
$vobj = <<<HI
|
|
|
|
BEGIN:VCALENDAR
|
|
|
|
METHOD:REQUEST
|
|
|
|
VERSION:2.0
|
|
|
|
BEGIN:VTIMEZONE
|
|
|
|
TZID:foo
|
|
|
|
BEGIN:STANDARD
|
|
|
|
DTSTART:16010101T030000
|
|
|
|
TZOFFSETFROM:+0200
|
|
|
|
TZOFFSETTO:+0100
|
|
|
|
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
|
|
|
|
END:STANDARD
|
|
|
|
BEGIN:DAYLIGHT
|
|
|
|
DTSTART:16010101T020000
|
|
|
|
TZOFFSETFROM:+0100
|
|
|
|
TZOFFSETTO:+0200
|
|
|
|
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU
|
|
|
|
END:DAYLIGHT
|
|
|
|
END:VTIMEZONE
|
|
|
|
BEGIN:VEVENT
|
|
|
|
DTSTAMP:20120416T092149Z
|
|
|
|
DTSTART;TZID="foo":20120418T1
|
|
|
|
00000
|
|
|
|
SUMMARY:Begin Unterhaltsreinigung
|
|
|
|
UID:040000008200E00074C5B7101A82E0080000000010DA091DC31BCD01000000000000000
|
|
|
|
0100000008FECD2E607780649BE5A4C9EE6418CBC
|
|
|
|
000
|
|
|
|
END:VEVENT
|
|
|
|
END:VCALENDAR
|
|
|
|
HI;
|
2012-08-11 04:07:19 -04:00
|
|
|
$tz = TimeZoneUtil::getTimeZone('foo', Reader::read($vobj));
|
2012-07-08 13:12:58 -04:00
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$this->assertEquals(new \DateTimeZone(date_default_timezone_get()), $tz);
|
2012-07-08 13:12:58 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|