]> git.mxchange.org Git - friendica-addons.git/blobdiff - dav/SabreDAV/tests/Sabre/CalDAV/Backend/AbstractTest.php
Initial Release of the calendar plugin
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / CalDAV / Backend / AbstractTest.php
diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Backend/AbstractTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/Backend/AbstractTest.php
new file mode 100644 (file)
index 0000000..5e393f5
--- /dev/null
@@ -0,0 +1,86 @@
+<?php
+
+class Sabre_CalDAV_Backend_AbstractTest extends PHPUnit_Framework_TestCase {
+
+    function testUpdateCalendar() {
+
+        $abstract = new Sabre_CalDAV_Backend_AbstractMock();
+        $this->assertEquals(false, $abstract->updateCalendar('randomid', array('{DAV:}displayname' => 'anything')));
+
+    }
+
+    function testCalendarQuery() {
+
+        $abstract = new Sabre_CalDAV_Backend_AbstractMock();
+        $filters = array(
+            'name' => 'VCALENDAR',
+            'comp-filters' => array(
+                array(
+                    'name' => 'VEVENT',
+                    'comp-filters' => array(),
+                    'prop-filters' => array(),
+                    'is-not-defined' => false,
+                    'time-range' => null,
+                ),
+            ),
+            'prop-filters' => array(),
+            'is-not-defined' => false,
+            'time-range' => null,
+        );
+
+        $this->assertEquals(array(
+            'event1.ics',
+        ), $abstract->calendarQuery(1, $filters));
+
+    }
+
+}
+
+class Sabre_CalDAV_Backend_AbstractMock extends Sabre_CalDAV_Backend_Abstract {
+
+    function getCalendarsForUser($principalUri) { }
+    function createCalendar($principalUri,$calendarUri,array $properties) { }
+    function deleteCalendar($calendarId) { }
+    function getCalendarObjects($calendarId) { 
+
+        return array(
+            array(
+                'id' => 1,
+                'calendarid' => 1,
+                'uri' => 'event1.ics',
+            ),
+            array(
+                'id' => 2,
+                'calendarid' => 1,
+                'uri' => 'task1.ics',
+            ),
+        );
+
+    }
+    function getCalendarObject($calendarId,$objectUri) { 
+
+        switch($objectUri) {
+
+            case 'event1.ics' :
+                return array(
+                    'id' => 1,
+                    'calendarid' => 1,
+                    'uri' => 'event1.ics',
+                    'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
+                );
+            case 'task1.ics' :
+                return array(
+                    'id' => 1,
+                    'calendarid' => 1,
+                    'uri' => 'event1.ics',
+                    'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n",
+                );
+
+        }
+
+    }
+    function createCalendarObject($calendarId,$objectUri,$calendarData) { }
+    function updateCalendarObject($calendarId,$objectUri,$calendarData) { }
+    function deleteCalendarObject($calendarId,$objectUri) { }
+
+}