~ubuntu-branches/ubuntu/vivid/php-horde-icalendar/vivid-proposed

« back to all changes in this revision

Viewing changes to Horde_Icalendar-2.0.8/test/Horde/Icalendar/ParseTest.php

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2014-06-05 20:31:26 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140605203126-geamf8wv7cvfrruh
Tags: 2.0.9-1
New upstream version 2.0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * @category   Horde
4
 
 * @package    Icalendar
5
 
 * @subpackage UnitTests
6
 
 */
7
 
 
8
 
/**
9
 
 * @category   Horde
10
 
 * @package    Icalendar
11
 
 * @subpackage UnitTests
12
 
 */
13
 
class Horde_Icalendar_ParseTest extends Horde_Test_Case
14
 
{
15
 
    public function testEmptyData()
16
 
    {
17
 
        $ical = new Horde_Icalendar();
18
 
        $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/empty.ics'));
19
 
        $this->assertEquals(
20
 
            array(),
21
 
            $ical->getComponents()
22
 
        );
23
 
        $ical->parsevCalendar('');
24
 
        $this->assertEquals(
25
 
            array(),
26
 
            $ical->getComponents()
27
 
        );
28
 
    }
29
 
 
30
 
    public function testEscapes()
31
 
    {
32
 
        $ical = new Horde_Icalendar();
33
 
        $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/escapes1.ics'));
34
 
        $this->assertEquals(
35
 
            array('There is a comma (escaped with a baskslash) in this sentence and some important words after it, see anything here?'),
36
 
            $ical->getComponent(0)->getAttributeValues('DESCRIPTION')
37
 
        );
38
 
        $this->assertEquals(
39
 
            array('There are important words after this dash - see anything here or have the words gone?'),
40
 
            $ical->getComponent(1)->getAttributeValues('DESCRIPTION')
41
 
        );
42
 
        $this->assertEquals(
43
 
            array('mailto:a@b.c'),
44
 
            $ical->getComponent(1)->getAttributeValues('ORGANIZER')
45
 
        );
46
 
        $this->assertEquals(
47
 
            array('Foo'),
48
 
            $ical->getComponent(0)->getAttributeValues('CATEGORIES')
49
 
        );
50
 
        $this->assertEquals(
51
 
            array('Foo', 'Foo,Bar', 'Bar'),
52
 
            $ical->getComponent(1)->getAttributeValues('CATEGORIES')
53
 
        );
54
 
    }
55
 
 
56
 
    public function testQuotedParameters()
57
 
    {
58
 
        $ical = new Horde_Icalendar();
59
 
        $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/quoted-params.ics'));
60
 
        $attr = $ical->getComponent(0)->getAttribute('ORGANIZER', true);
61
 
        $this->assertEquals(
62
 
            'Klä,rchen; Mül:ler',
63
 
            $attr[0]['CN']
64
 
        );
65
 
    }
66
 
 
67
 
    public function testVcalendar20()
68
 
    {
69
 
        $ical = new Horde_Icalendar();
70
 
        $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/vcal20.ics'));
71
 
 
72
 
        $this->assertEquals(
73
 
            array(
74
 
              0 => 
75
 
              array(
76
 
                'name' => 'PRODID',
77
 
                'params' => 
78
 
                array(
79
 
                ),
80
 
                'value' => '-//Google Inc//Google Calendar 70.9054//EN',
81
 
                'values' => 
82
 
                array(
83
 
                  0 => '-//Google Inc//Google Calendar 70.9054//EN',
84
 
                ),
85
 
              ),
86
 
              1 => 
87
 
              array(
88
 
                'name' => 'VERSION',
89
 
                'params' => 
90
 
                array(
91
 
                ),
92
 
                'value' => '2.0',
93
 
                'values' => 
94
 
                array(
95
 
                  0 => '2.0',
96
 
                ),
97
 
              ),
98
 
              2 => 
99
 
              array(
100
 
                'name' => 'CALSCALE',
101
 
                'params' => 
102
 
                array(
103
 
                ),
104
 
                'value' => 'GREGORIAN',
105
 
                'values' => 
106
 
                array(
107
 
                  0 => 'GREGORIAN',
108
 
                ),
109
 
              ),
110
 
              3 => 
111
 
              array(
112
 
                'name' => 'METHOD',
113
 
                'params' => 
114
 
                array(
115
 
                ),
116
 
                'value' => 'PUBLISH',
117
 
                'values' => 
118
 
                array(
119
 
                  0 => 'PUBLISH',
120
 
                ),
121
 
              ),
122
 
              4 => 
123
 
              array(
124
 
                'name' => 'X-WR-CALNAME',
125
 
                'params' => 
126
 
                array(
127
 
                ),
128
 
                'value' => 'PEAR - PHP Extension and Application Repository',
129
 
                'values' => 
130
 
                array(
131
 
                  0 => 'PEAR - PHP Extension and Application Repository',
132
 
                ),
133
 
              ),
134
 
              5 => 
135
 
              array(
136
 
                'name' => 'X-WR-TIMEZONE',
137
 
                'params' => 
138
 
                array(
139
 
                ),
140
 
                'value' => 'Atlantic/Reykjavik',
141
 
                'values' => 
142
 
                array(
143
 
                  0 => 'Atlantic/Reykjavik',
144
 
                ),
145
 
              ),
146
 
              6 => 
147
 
              array(
148
 
                'name' => 'X-WR-CALDESC',
149
 
                'params' => 
150
 
                array(
151
 
                ),
152
 
                'value' => 'pear.php.net activity calendar, bug triage, group meetings, qa, conferences or similar',
153
 
                'values' => 
154
 
                array(
155
 
                  0 => 'pear.php.net activity calendar, bug triage, group meetings, qa, conferences or similar',
156
 
                ),
157
 
              ),
158
 
            ),
159
 
            $ical->getAllAttributes()
160
 
        );
161
 
 
162
 
        $this->assertEquals(
163
 
            array(
164
 
              0 => 
165
 
              array(
166
 
                'name' => 'DTSTART',
167
 
                'params' => 
168
 
                array(
169
 
                ),
170
 
                'value' => 1224950400,
171
 
                'values' => 
172
 
                array(
173
 
                  0 => 1224950400,
174
 
                ),
175
 
              ),
176
 
              1 => 
177
 
              array(
178
 
                'name' => 'DTEND',
179
 
                'params' => 
180
 
                array(
181
 
                ),
182
 
                'value' => 1224968400,
183
 
                'values' => 
184
 
                array(
185
 
                  0 => 1224968400,
186
 
                ),
187
 
              ),
188
 
              2 => 
189
 
              array(
190
 
                'name' => 'DTSTAMP',
191
 
                'params' => 
192
 
                array(
193
 
                ),
194
 
                'value' => 1219138073,
195
 
                'values' => 
196
 
                array(
197
 
                  0 => 1219138073,
198
 
                ),
199
 
              ),
200
 
              3 => 
201
 
              array(
202
 
                'name' => 'UID',
203
 
                'params' => 
204
 
                array(
205
 
                ),
206
 
                'value' => 'ntnrt4go4482q2trk18bt62c0o@google.com',
207
 
                'values' => 
208
 
                array(
209
 
                  0 => 'ntnrt4go4482q2trk18bt62c0o@google.com',
210
 
                ),
211
 
              ),
212
 
              4 => 
213
 
              array(
214
 
                'name' => 'RECURRENCE-ID',
215
 
                'params' => 
216
 
                array(
217
 
                ),
218
 
                'value' => 1224950400,
219
 
                'values' => 
220
 
                array(
221
 
                  0 => 1224950400,
222
 
                ),
223
 
              ),
224
 
              5 => 
225
 
              array(
226
 
                'name' => 'CLASS',
227
 
                'params' => 
228
 
                array(
229
 
                ),
230
 
                'value' => 'PUBLIC',
231
 
                'values' => 
232
 
                array(
233
 
                  0 => 'PUBLIC',
234
 
                ),
235
 
              ),
236
 
              6 => 
237
 
              array(
238
 
                'name' => 'CREATED',
239
 
                'params' => 
240
 
                array(
241
 
                ),
242
 
                'value' => 1204763165,
243
 
                'values' => 
244
 
                array(
245
 
                  0 => 1204763165,
246
 
                ),
247
 
              ),
248
 
              7 => 
249
 
              array(
250
 
                'name' => 'DESCRIPTION',
251
 
                'params' => 
252
 
                array(
253
 
                ),
254
 
                'value' => 'Bug Triage session
255
 
 
256
 
Not been invited ? Want to attend ? Let us know and we\'ll add you!',
257
 
                'values' => 
258
 
                array(
259
 
                  0 => 'Bug Triage session
260
 
 
261
 
Not been invited ? Want to attend ? Let us know and we\'ll add you!',
262
 
                ),
263
 
              ),
264
 
              8 => 
265
 
              array(
266
 
                'name' => 'LAST-MODIFIED',
267
 
                'params' => 
268
 
                array(
269
 
                ),
270
 
                'value' => 1216413606,
271
 
                'values' => 
272
 
                array(
273
 
                  0 => 1216413606,
274
 
                ),
275
 
              ),
276
 
              9 => 
277
 
              array(
278
 
                'name' => 'LOCATION',
279
 
                'params' => 
280
 
                array(
281
 
                ),
282
 
                'value' => '#pear-bugs Efnet',
283
 
                'values' => 
284
 
                array(
285
 
                  0 => '#pear-bugs Efnet',
286
 
                ),
287
 
              ),
288
 
              10 => 
289
 
              array(
290
 
                'name' => 'SEQUENCE',
291
 
                'params' => 
292
 
                array(
293
 
                ),
294
 
                'value' => 2,
295
 
                'values' => 
296
 
                array(
297
 
                  0 => 2,
298
 
                ),
299
 
              ),
300
 
              11 => 
301
 
              array(
302
 
                'name' => 'STATUS',
303
 
                'params' => 
304
 
                array(
305
 
                ),
306
 
                'value' => 'CONFIRMED',
307
 
                'values' => 
308
 
                array(
309
 
                  0 => 'CONFIRMED',
310
 
                ),
311
 
              ),
312
 
              12 => 
313
 
              array(
314
 
                'name' => 'SUMMARY',
315
 
                'params' => 
316
 
                array(
317
 
                ),
318
 
                'value' => 'Bug Triage',
319
 
                'values' => 
320
 
                array(
321
 
                  0 => 'Bug Triage',
322
 
                ),
323
 
              ),
324
 
              13 => 
325
 
              array(
326
 
                'name' => 'TRANSP',
327
 
                'params' => 
328
 
                array(
329
 
                ),
330
 
                'value' => 'OPAQUE',
331
 
                'values' => 
332
 
                array(
333
 
                  0 => 'OPAQUE',
334
 
                ),
335
 
              ),
336
 
              14 => 
337
 
              array(
338
 
                'name' => 'CATEGORIES',
339
 
                'params' => 
340
 
                array(
341
 
                ),
342
 
                'value' => 'foo,bar,fuz buz,blah, blah',
343
 
                'values' => 
344
 
                array(
345
 
                  0 => 'foo',
346
 
                  1 => 'bar',
347
 
                  2 => 'fuz buz',
348
 
                  3 => 'blah, blah',
349
 
                ),
350
 
              ),
351
 
            ),
352
 
            $ical->getComponent(0)->getAllAttributes()
353
 
        );
354
 
    }
355
 
 
356
 
    public function testBug7423()
357
 
    {
358
 
        $ical = new Horde_Icalendar();
359
 
        $ical->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/bug7423.ics'));
360
 
        $this->assertEquals(
361
 
            array('SUMMARY' => 'birthday'),
362
 
            $ical->getComponent(0)->toHash(true)
363
 
        );
364
 
    }
365
 
}