[Pkg-owncloud-commits] [php-sabredav] 10/42: Add a test for expand() with floating date-time

David Prévot taffit at moszumanska.debian.org
Fri Nov 28 22:47:47 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit 4881c440035c3a15e247d2841860a5c5a2a0e564
Author: Armin Hackmann <armin at fruux.com>
Date:   Wed Nov 5 11:25:47 2014 +0100

    Add a test for expand() with floating date-time
---
 .../Sabre/CalDAV/ExpandEventsFloatingTimeTest.php  | 123 +++++++++++++++++++++
 1 file changed, 123 insertions(+)

diff --git a/tests/Sabre/CalDAV/ExpandEventsFloatingTimeTest.php b/tests/Sabre/CalDAV/ExpandEventsFloatingTimeTest.php
new file mode 100644
index 0000000..d0e45a9
--- /dev/null
+++ b/tests/Sabre/CalDAV/ExpandEventsFloatingTimeTest.php
@@ -0,0 +1,123 @@
+<?php
+
+namespace Sabre\CalDAV;
+use Sabre\HTTP;
+use Sabre\VObject;
+
+/**
+ * This unittest is created to check if expan() works correctly with
+ * floating times (using calendar-timezone information).
+ */
+class ExpandEventsFloatingTimeTest extends \Sabre\DAVServerTest {
+
+    protected $setupCalDAV = true;
+
+    protected $caldavCalendars = array(
+        array(
+            'id' => 1,
+            'name' => 'Calendar',
+            'principaluri' => 'principals/user1',
+            'uri' => 'calendar1',
+            'timezone' => 'BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:Europe/Berlin
+BEGIN:DAYLIGHT
+TZOFFSETFROM:+0100
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
+DTSTART:19810329T020000
+TZNAME:GMT+2
+TZOFFSETTO:+0200
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:+0200
+RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
+DTSTART:19961027T030000
+TZNAME:GMT+1
+TZOFFSETTO:+0100
+END:STANDARD
+END:VTIMEZONE
+END:VCALENDAR',
+        )
+    );
+
+    protected $caldavCalendarObjects = array(
+        1 => array(
+           'event.ics' => array(
+                'calendardata' => 'BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20140701T143658Z
+UID:dba46fe8-1631-4d98-a575-97963c364dfe
+DTEND:20141108T073000
+TRANSP:OPAQUE
+SUMMARY:Floating Time event, starting 05:30am Europe/Berlin
+DTSTART:20141108T053000
+DTSTAMP:20140701T143706Z
+SEQUENCE:1
+END:VEVENT
+END:VCALENDAR
+',
+            ),
+        ),
+    );
+
+    function testExpand() {
+
+        $request = HTTP\Sapi::createFromServerArray([
+            'REQUEST_METHOD' => 'REPORT',
+            'HTTP_CONTENT_TYPE' => 'application/xml',
+            'REQUEST_URI' => '/calendars/user1/calendar1',
+            'HTTP_DEPTH' => '1',
+        ]);
+
+        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
+<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
+    <D:prop>
+        <C:calendar-data>
+            <C:expand start="20141107T230000Z" end="20141108T225959Z"/>
+        </C:calendar-data>
+        <D:getetag/>
+    </D:prop>
+    <C:filter>
+        <C:comp-filter name="VCALENDAR">
+            <C:comp-filter name="VEVENT">
+                <C:time-range start="20141107T230000Z" end="20141108T225959Z"/>
+            </C:comp-filter>
+        </C:comp-filter>
+    </C:filter>
+</C:calendar-query>');
+
+        $response = $this->request($request);
+
+        // Everts super awesome xml parser.
+        $body = substr(
+            $response->body,
+            $start = strpos($response->body, 'BEGIN:VCALENDAR'),
+            strpos($response->body, 'END:VCALENDAR') - $start + 13
+        );
+        $body = str_replace('
','',$body);
+
+        $vObject = VObject\Reader::read($body);
+
+        // check if DTSTARTs and DTENDs are correct
+        foreach ($vObject->VEVENT as $vevent) {
+            /** @var $vevent Sabre\VObject\Component\VEvent */
+            foreach ($vevent->children as $child) {
+                /** @var $child Sabre\VObject\Property */
+
+                if ($child->name == 'DTSTART') {
+                    // DTSTART should be the UTC equivalent of given floating time
+                    $this->assertEquals($child->getValue(), '20141108T043000Z');
+                } elseif ($child->name == 'DTEND') {
+                    // DTEND should be the UTC equivalent of given floating time
+                    $this->assertEquals($child->getValue(), '20141108T063000Z');
+                }
+            }
+        }
+    }
+
+}
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list