]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/CalDAV/Issue205Test.php
Merge remote branch 'friendica/master'
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / CalDAV / Issue205Test.php
1 <?php
2
3 use Sabre\VObject;
4
5 /**
6  * This unittest is created to check if a VALARM TRIGGER of PT0S is supported
7  *
8  *
9  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
10  * @author Evert Pot (http://www.rooftopsolutions.nl/)
11  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
12  */
13 class Sabre_CalDAV_Issue205Test extends Sabre_DAVServerTest {
14
15     protected $setupCalDAV = true;
16
17     protected $caldavCalendars = array(
18         array(
19             'id' => 1,
20             'name' => 'Calendar',
21             'principaluri' => 'principals/user1',
22             'uri' => 'calendar1',
23         )
24     );
25
26     protected $caldavCalendarObjects = array(
27         1 => array(
28             'event.ics' => array(
29                 'calendardata' => 'BEGIN:VCALENDAR
30 VERSION:2.0
31 BEGIN:VEVENT
32 UID:20120330T155305CEST-6585fBUVgV
33 DTSTAMP:20120330T135305Z
34 DTSTART;TZID=Europe/Berlin:20120326T155200
35 DTEND;TZID=Europe/Berlin:20120326T165200
36 SUMMARY:original summary
37 TRANSP:OPAQUE
38 BEGIN:VALARM
39 ACTION:AUDIO
40 ATTACH;VALUE=URI:Basso
41 TRIGGER:PT0S
42 END:VALARM
43 END:VEVENT
44 END:VCALENDAR
45 ',
46             ),
47         ),
48     );
49
50     function testIssue205() {
51
52         $request = new Sabre_HTTP_Request(array(
53             'REQUEST_METHOD' => 'REPORT',
54             'HTTP_CONTENT_TYPE' => 'application/xml',
55             'REQUEST_URI' => '/calendars/user1/calendar1',
56             'HTTP_DEPTH' => '1',
57         ));
58
59         $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
60 <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
61     <D:prop>
62         <C:calendar-data>
63             <C:expand start="20120325T220000Z" end="20120401T215959Z"/>
64         </C:calendar-data>
65         <D:getetag/>
66     </D:prop>
67     <C:filter>
68         <C:comp-filter name="VCALENDAR">
69             <C:comp-filter name="VEVENT">
70                 <C:comp-filter name="VALARM">
71                     <C:time-range start="20120325T220000Z" end="20120401T215959Z"/>
72                 </C:comp-filter>
73             </C:comp-filter>
74         </C:comp-filter>
75     </C:filter>
76 </C:calendar-query>');
77
78         $response = $this->request($request);
79
80         $this->assertFalse(strpos($response->body, '<s:exception>Exception</s:exception>'), 'Exception occurred: ' . $response->body);
81         $this->assertFalse(strpos($response->body, 'Unknown or bad format'), 'DateTime unknown format Exception: ' . $response->body);
82
83         // Everts super awesome xml parser.
84         $body = substr(
85             $response->body,
86             $start = strpos($response->body, 'BEGIN:VCALENDAR'),
87             strpos($response->body, 'END:VCALENDAR') - $start + 13
88         );
89         $body = str_replace('&#13;','',$body);
90
91         $vObject = VObject\Reader::read($body);
92
93         $this->assertEquals(1, count($vObject->VEVENT));
94
95     }
96 }