0011078: CalDav calender not working after upgrade from 2013.10
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 20 Jun 2016 12:22:58 +0000 (14:22 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 22 Jun 2016 13:31:05 +0000 (15:31 +0200)
* postgres handles container id as ints ...
* reactivates some of the disabled tests

see also
0011668: fix Calendar_Frontend_* Tests with postgresql backend

https://forge.tine20.org/view.php?id=11078

Change-Id: I25133d32c9cd9ea9b9be00c2b111f640fc13d84c
Reviewed-on: http://gerrit.tine20.com/customers/3261
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Frontend/CalDAVTest.php
tine20/Calendar/Frontend/WebDAV.php
tine20/Tinebase/WebDav/Collection/AbstractContainerTree.php

index 1f1da4f..9e2f1e7 100644 (file)
@@ -27,10 +27,6 @@ class Calendar_Frontend_CalDAVTest extends TestCase
      */
     public function testGetChildren()
     {
-        if ($this->_dbIsPgsql()) {
-            $this->markTestSkipped('0011668: fix Calendar_Frontend_* Tests with postgresql backend');
-        }
-
         $_SERVER['HTTP_USER_AGENT'] = 'Mac_OS_X/10.9 (13A603) CalendarAgent/174';
         
         $collection = new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT . '/' . Tinebase_Core::getUser()->contact_id, true);
@@ -51,17 +47,32 @@ class Calendar_Frontend_CalDAVTest extends TestCase
      */
     public function testGetChild()
     {
-        if ($this->_dbIsPgsql()) {
-            $this->markTestSkipped('0011668: fix Calendar_Frontend_* Tests with postgresql backend');
-        }
-
         $collection = new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT . '/' . Tinebase_Core::getUser()->contact_id, true);
         
         $child = $collection->getChild($this->_getCalendarTestContainer()->getId());
         
         $this->assertTrue($child instanceof Calendar_Frontend_WebDAV_Container);
     }
-    
+
+    /**
+     * testGetChildrenWithSharedFolder
+     *
+     * @see 0011078: CalDav calender not working after upgrade from 2013.10 (postgresql)
+     */
+    public function testGetChildrenWithSharedFolder()
+    {
+        $this->_getCalendarTestContainer(Tinebase_Model_Container::TYPE_SHARED);
+        $calendarRoot = \Sabre\CalDAV\Plugin::CALENDAR_ROOT;
+        $_SERVER['REQUEST_URI'] = '/tine20/' . $calendarRoot;
+        $collection = new Calendar_Frontend_WebDAV($calendarRoot, true);
+
+        $children = $collection->getChildren();
+
+        $this->assertTrue(is_array($children));
+        $this->assertTrue(count($children) > 0);
+        $this->assertTrue($children[0] instanceof Calendar_Frontend_WebDAV);
+    }
+
     /**
      * test get calendar inbox
      */
@@ -87,10 +98,6 @@ class Calendar_Frontend_CalDAVTest extends TestCase
      */
     public function testGetTasksChild()
     {
-        if ($this->_dbIsPgsql()) {
-            $this->markTestSkipped('0011668: fix Calendar_Frontend_* Tests with postgresql backend');
-        }
-
         $_SERVER['HTTP_USER_AGENT'] = 'Mac_OS_X/10.9 (13A603) CalendarAgent/174';
         
         $collection = new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT . '/' . Tinebase_Core::getUser()->contact_id, true);
@@ -111,14 +118,10 @@ class Calendar_Frontend_CalDAVTest extends TestCase
      */
     public function testGetTasksChildMacOSX()
     {
-        if ($this->_dbIsPgsql()) {
-            $this->markTestSkipped('0011668: fix Calendar_Frontend_* Tests with postgresql backend');
-        }
-
         $_SERVER['HTTP_USER_AGENT'] = 'Mac_OS_X/10.9 (13A603) CalendarAgent/174';
         
-        $collection = new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT, true);
-        $children = $this->testGetChildren();
+        new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT, true);
+        $this->testGetChildren();
     }
     
     /**
@@ -221,15 +224,16 @@ class Calendar_Frontend_CalDAVTest extends TestCase
     }
     
     /**
-     * 
+     * fetch test calendar for app
+     *
      * @return Tinebase_Model_Container
      */
-    protected function _getCalendarTestContainer()
+    protected function _getCalendarTestContainer($type = Tinebase_Model_Container::TYPE_PERSONAL)
     {
         $container = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array(
             'name'              => Tinebase_Record_Abstract::generateUID(),
             'model'             => 'Calendar_Model_Event',
-            'type'              => Tinebase_Model_Container::TYPE_PERSONAL,
+            'type'              => $type,
             'backend'           => 'Sql',
             'application_id'    => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(),
         )));
index 055d55b..0892842 100644 (file)
@@ -45,10 +45,6 @@ class Calendar_Frontend_WebDAV extends Tinebase_WebDav_Collection_AbstractContai
      */
     public function getChild($name)
     {
-        if (! is_string($name)) {
-            throw new Tinebase_Exception_UnexpectedValue('name should be a string');
-        }
-
         // do this only for caldav requests
         if ($this->_useIdAsName && count($this->_getPathParts()) == 2 && in_array($name, array('inbox', 'outbox', 'dropbox'))) {
             switch ($name) {
index 9b21459..f2496a1 100644 (file)
@@ -155,15 +155,15 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                         } elseif ($this->_useIdAsName) {
                             // first try to fetch by uuid ...
                             try {
-                                $container = Tinebase_Container::getInstance()->getByProperty($name, 'uuid');
+                                $container = Tinebase_Container::getInstance()->getByProperty((string) $name, 'uuid');
                             } catch (Tinebase_Exception_NotFound $tenf) {
                                 // ... if that fails by id
                                 $container = Tinebase_Container::getInstance()->getContainerById($name);
                             }
                         } else {
                             $container = Tinebase_Container::getInstance()->getContainerByName(
-                                $this->_getApplicationName(), 
-                                $name, 
+                                $this->_getApplicationName(),
+                                (string) $name,
                                 Tinebase_Model_Container::TYPE_SHARED
                             );
                         }
@@ -206,8 +206,8 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                             
                         } else { 
                             $container = Tinebase_Container::getInstance()->getContainerByName(
-                                $this->_getApplicationName(), 
-                                $name,
+                                $this->_getApplicationName(),
+                                (string) $name,
                                 Tinebase_Model_Container::TYPE_PERSONAL, 
                                 $accountId
                             );