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