ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
TestUtil.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\CalDAV;
4 
5 class TestUtil {
6 
7  static function getBackend() {
8 
9  $backend = new Backend\Mock();
10  $calendarId = $backend->createCalendar(
11  'principals/user1',
12  'UUID-123467',
13  [
14  '{DAV:}displayname' => 'user1 calendar',
15  '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description',
16  '{http://apple.com/ns/ical/}calendar-order' => '1',
17  '{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
18  ]
19  );
20  $backend->createCalendar(
21  'principals/user1',
22  'UUID-123468',
23  [
24  '{DAV:}displayname' => 'user1 calendar2',
25  '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description',
26  '{http://apple.com/ns/ical/}calendar-order' => '1',
27  '{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
28  ]
29  );
30  $backend->createCalendarObject($calendarId, 'UUID-2345', self::getTestCalendarData());
31  return $backend;
32 
33  }
34 
35  static function getTestCalendarData($type = 1) {
36 
37  $calendarData = 'BEGIN:VCALENDAR
38 VERSION:2.0
39 PRODID:-//Apple Inc.//iCal 4.0.1//EN
40 CALSCALE:GREGORIAN
41 BEGIN:VTIMEZONE
42 TZID:Asia/Seoul
43 BEGIN:DAYLIGHT
44 TZOFFSETFROM:+0900
45 RRULE:FREQ=YEARLY;UNTIL=19880507T150000Z;BYMONTH=5;BYDAY=2SU
46 DTSTART:19870510T000000
47 TZNAME:GMT+09:00
48 TZOFFSETTO:+1000
49 END:DAYLIGHT
50 BEGIN:STANDARD
51 TZOFFSETFROM:+1000
52 DTSTART:19881009T000000
53 TZNAME:GMT+09:00
54 TZOFFSETTO:+0900
55 END:STANDARD
56 END:VTIMEZONE
57 BEGIN:VEVENT
58 CREATED:20100225T154229Z
59 UID:39A6B5ED-DD51-4AFE-A683-C35EE3749627
60 TRANSP:TRANSPARENT
61 SUMMARY:Something here
62 DTSTAMP:20100228T130202Z';
63 
64  switch ($type) {
65  case 1 :
66  $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDTEND;TZID=Asia/Seoul:20100223T070000\n";
67  break;
68  case 2 :
69  $calendarData .= "\nDTSTART:20100223T060000\nDTEND:20100223T070000\n";
70  break;
71  case 3 :
72  $calendarData .= "\nDTSTART;VALUE=DATE:20100223\nDTEND;VALUE=DATE:20100223\n";
73  break;
74  case 4 :
75  $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:PT1H\n";
76  break;
77  case 5 :
78  $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:-P5D\n";
79  break;
80  case 6 :
81  $calendarData .= "\nDTSTART;VALUE=DATE:20100223\n";
82  break;
83  case 7 :
84  $calendarData .= "\nDTSTART;VALUE=DATETIME:20100223T060000\n";
85  break;
86 
87  // No DTSTART, so intentionally broken
88  case 'X' :
89  $calendarData .= "\n";
90  break;
91  }
92 
93 
94  $calendarData .= 'ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
95 SEQUENCE:2
96 END:VEVENT
97 END:VCALENDAR';
98 
99  return $calendarData;
100 
101  }
102 
103  static function getTestTODO($type = 'due') {
104 
105  switch ($type) {
106 
107  case 'due' :
108  $extra = "DUE:20100104T000000Z";
109  break;
110  case 'due2' :
111  $extra = "DUE:20060104T000000Z";
112  break;
113  case 'due_date' :
114  $extra = "DUE;VALUE=DATE:20060104";
115  break;
116  case 'due_tz' :
117  $extra = "DUE;TZID=Asia/Seoul:20060104T000000Z";
118  break;
119  case 'due_dtstart' :
120  $extra = "DTSTART:20050223T060000Z\nDUE:20060104T000000Z";
121  break;
122  case 'due_dtstart2' :
123  $extra = "DTSTART:20090223T060000Z\nDUE:20100104T000000Z";
124  break;
125  case 'dtstart' :
126  $extra = 'DTSTART:20100223T060000Z';
127  break;
128  case 'dtstart2' :
129  $extra = 'DTSTART:20060223T060000Z';
130  break;
131  case 'dtstart_date' :
132  $extra = 'DTSTART;VALUE=DATE:20100223';
133  break;
134  case 'dtstart_tz' :
135  $extra = 'DTSTART;TZID=Asia/Seoul:20100223T060000Z';
136  break;
137  case 'dtstart_duration' :
138  $extra = "DTSTART:20061023T060000Z\nDURATION:PT1H";
139  break;
140  case 'dtstart_duration2' :
141  $extra = "DTSTART:20101023T060000Z\nDURATION:PT1H";
142  break;
143  case 'completed' :
144  $extra = 'COMPLETED:20060601T000000Z';
145  break;
146  case 'completed2' :
147  $extra = 'COMPLETED:20090601T000000Z';
148  break;
149  case 'created' :
150  $extra = 'CREATED:20060601T000000Z';
151  break;
152  case 'created2' :
153  $extra = 'CREATED:20090601T000000Z';
154  break;
155  case 'completedcreated' :
156  $extra = "CREATED:20060601T000000Z\nCOMPLETED:20070101T000000Z";
157  break;
158  case 'completedcreated2' :
159  $extra = "CREATED:20090601T000000Z\nCOMPLETED:20100101T000000Z";
160  break;
161  case 'notime' :
162  $extra = 'X-FILLER:oh hello';
163  break;
164  default :
165  throw new Exception('Unknown type: ' . $type);
166 
167  }
168 
169  $todo = 'BEGIN:VCALENDAR
170 VERSION:2.0
171 PRODID:-//Example Corp.//CalDAV Client//EN
172 BEGIN:VTODO
173 DTSTAMP:20060205T235335Z
174 ' . $extra . '
175 STATUS:NEEDS-ACTION
176 SUMMARY:Task #1
177 UID:DDDEEB7915FA61233B861457@example.com
178 BEGIN:VALARM
179 ACTION:AUDIO
180 TRIGGER;RELATED=START:-PT10M
181 END:VALARM
182 END:VTODO
183 END:VCALENDAR';
184 
185  return $todo;
186 
187  }
188 
189 }
$type
static getTestTODO($type='due')
Definition: TestUtil.php:103
static getTestCalendarData($type=1)
Definition: TestUtil.php:35
static getBackend()
Definition: TestUtil.php:7