]> git.mxchange.org Git - friendica-addons.git/blobdiff - dav/SabreDAV/tests/Sabre/CalDAV/Backend/Mock.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / CalDAV / Backend / Mock.php
index 511dd9fd2a61f1d027886ae2df4102f1a5f72c53..d9a5a7a0f00cb99342060c59491e47668df96b6c 100644 (file)
@@ -1,14 +1,16 @@
 <?php
 
-class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
+class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract implements Sabre_CalDAV_Backend_NotificationSupport {
 
     private $calendarData;
     private $calendars;
+    private $notifications;
 
-    function __construct(array $calendars, array $calendarData) {
+    function __construct(array $calendars, array $calendarData, array $notifications = array()) {
 
         $this->calendars = $calendars;
         $this->calendarData = $calendarData;
+        $this->notifications = $notifications;
 
     }
 
@@ -58,7 +60,15 @@ class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
      */
     function createCalendar($principalUri,$calendarUri,array $properties) {
 
-        throw new Exception('Not implemented');
+        $id = Sabre_DAV_UUIDUtil::getUUID();
+        $this->calendars[] = array_merge(array(
+            'id' => $id,
+            'principaluri' => $principalUri,
+            'uri' => $calendarUri,
+            '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT','VTODO')),
+        ), $properties);
+
+        return $id;
 
     }
 
@@ -112,7 +122,11 @@ class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
      */
     public function deleteCalendar($calendarId) {
 
-        throw new Exception('Not implemented');
+        foreach($this->calendars as $k=>$calendar) {
+            if ($calendar['id'] === $calendarId) {
+                unset($this->calendars[$k]);
+            }
+        }
 
     }
 
@@ -227,4 +241,37 @@ class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
 
     }
 
+    /**
+     * Returns a list of notifications for a given principal url.
+     *
+     * The returned array should only consist of implementations of
+     * Sabre_CalDAV_Notifications_INotificationType.
+     *
+     * @param string $principalUri
+     * @return array
+     */
+    public function getNotificationsForPrincipal($principalUri) {
+
+        if (isset($this->notifications[$principalUri])) {
+            return $this->notifications[$principalUri];
+        }
+        return array();
+
+    }
+
+    /**
+     * This deletes a specific notifcation.
+     *
+     * This may be called by a client once it deems a notification handled.
+     *
+     * @param string $principalUri
+     * @param Sabre_CalDAV_Notifications_INotificationType $notification
+     * @return void
+     */
+    public function deleteNotification($principalUri, Sabre_CalDAV_Notifications_INotificationType $notification) {
+
+        throw new Sabre_DAV_Exception_NotImplemented('This doesn\'t work!');
+
+    }
+
 }