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