1<?php
2
3namespace Sabre\CalDAV;
4use Sabre\VObject;
5use Sabre\DAV;
6
7class Issue172Test extends \PHPUnit_Framework_TestCase {
8
9    // DateTimeZone() native name: America/Los_Angeles (GMT-8 in January)
10    function testBuiltInTimezoneName() {
11        $input = <<<HI
12BEGIN:VCALENDAR
13VERSION:2.0
14BEGIN:VEVENT
15DTSTART;TZID=America/Los_Angeles:20120118T204500
16DTEND;TZID=America/Los_Angeles:20120118T214500
17END:VEVENT
18END:VCALENDAR
19HI;
20        $validator = new CalendarQueryValidator();
21        $filters = array(
22            'name' => 'VCALENDAR',
23            'comp-filters' => array(
24                array(
25                    'name' => 'VEVENT',
26                    'comp-filters' => array(),
27                    'prop-filters' => array(),
28                    'is-not-defined' => false,
29                    'time-range' => array(
30                        'start' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'),
31                        'end'   => new \DateTime('2012-01-18 21:00:00 GMT-08:00'),
32                    ),
33                ),
34            ),
35            'prop-filters' => array(),
36        );
37        $input = VObject\Reader::read($input);
38        $this->assertTrue($validator->validate($input,$filters));
39    }
40
41    // Pacific Standard Time, translates to America/Los_Angeles (GMT-8 in January)
42    function testOutlookTimezoneName() {
43        $input = <<<HI
44BEGIN:VCALENDAR
45VERSION:2.0
46BEGIN:VTIMEZONE
47TZID:Pacific Standard Time
48BEGIN:STANDARD
49DTSTART:16010101T030000
50TZOFFSETFROM:+0200
51TZOFFSETTO:+0100
52RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
53END:STANDARD
54BEGIN:DAYLIGHT
55DTSTART:16010101T020000
56TZOFFSETFROM:+0100
57TZOFFSETTO:+0200
58RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
59END:DAYLIGHT
60END:VTIMEZONE
61BEGIN:VEVENT
62DTSTART;TZID=Pacific Standard Time:20120113T100000
63DTEND;TZID=Pacific Standard Time:20120113T110000
64END:VEVENT
65END:VCALENDAR
66HI;
67        $validator = new CalendarQueryValidator();
68        $filters = array(
69            'name' => 'VCALENDAR',
70            'comp-filters' => array(
71                array(
72                    'name' => 'VEVENT',
73                    'comp-filters' => array(),
74                    'prop-filters' => array(),
75                    'is-not-defined' => false,
76                    'time-range' => array(
77                        'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'),
78                        'end'   => new \DateTime('2012-01-13 10:30:00 GMT-08:00'),
79                    ),
80                ),
81            ),
82            'prop-filters' => array(),
83        );
84        $input = VObject\Reader::read($input);
85        $this->assertTrue($validator->validate($input,$filters));
86    }
87
88    // X-LIC-LOCATION, translates to America/Los_Angeles (GMT-8 in January)
89    function testLibICalLocationName() {
90        $input = <<<HI
91BEGIN:VCALENDAR
92VERSION:2.0
93BEGIN:VTIMEZONE
94TZID:My own timezone name
95X-LIC-LOCATION:America/Los_Angeles
96BEGIN:STANDARD
97DTSTART:16010101T030000
98TZOFFSETFROM:+0200
99TZOFFSETTO:+0100
100RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
101END:STANDARD
102BEGIN:DAYLIGHT
103DTSTART:16010101T020000
104TZOFFSETFROM:+0100
105TZOFFSETTO:+0200
106RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
107END:DAYLIGHT
108END:VTIMEZONE
109BEGIN:VEVENT
110DTSTART;TZID=My own timezone name:20120113T100000
111DTEND;TZID=My own timezone name:20120113T110000
112END:VEVENT
113END:VCALENDAR
114HI;
115        $validator = new CalendarQueryValidator();
116        $filters = array(
117            'name' => 'VCALENDAR',
118            'comp-filters' => array(
119                array(
120                    'name' => 'VEVENT',
121                    'comp-filters' => array(),
122                    'prop-filters' => array(),
123                    'is-not-defined' => false,
124                    'time-range' => array(
125                        'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'),
126                        'end'   => new \DateTime('2012-01-13 10:30:00 GMT-08:00'),
127                    ),
128                ),
129            ),
130            'prop-filters' => array(),
131        );
132        $input = VObject\Reader::read($input);
133        $this->assertTrue($validator->validate($input,$filters));
134    }
135}
136