0011172: optimize getGroupmemberships in Principalbackend
authorCornelius Weiß <mail@corneliusweiss.de>
Fri, 14 Aug 2015 11:37:20 +0000 (13:37 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 14 Aug 2015 13:13:14 +0000 (15:13 +0200)
* improve test for delegations

Change-Id: Id3cad080344db630567f1a74aaeef3753eb6f563
Reviewed-on: http://gerrit.tine20.com/customers/2112
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Frontend/CalDAV/ProxyTest.php

index b41e19c..c180707 100644 (file)
@@ -34,7 +34,31 @@ class Calendar_Frontend_CalDAV_ProxyTest extends TestCase
     protected function setUp()
     {
         parent::setUp();
-        
+
+        // create shared folder and other users folder
+        $this->sharedContainer = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array(
+            'name'           => __CLASS__ . Tinebase_Record_Abstract::generateUID(),
+            'type'           => Tinebase_Model_Container::TYPE_SHARED,
+            'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(),
+            'backend'        => 'Sql'
+        )));
+
+        $sclever = Tinebase_Helper::array_value('sclever', Zend_Registry::get('personas'));
+        $this->otherUsersContainer = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array(
+            'name'           => __CLASS__ . Tinebase_Record_Abstract::generateUID(),
+            'type'           => Tinebase_Model_Container::TYPE_PERSONAL,
+            'owner_id'       => $sclever->getId(),
+            'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(),
+            'backend'        => 'Sql'
+        )));
+        Tinebase_Container::getInstance()->addGrants($this->otherUsersContainer, Tinebase_Acl_Rights::ACCOUNT_TYPE_USER, Tinebase_Core::getUser(), array(
+            Tinebase_Model_Grants::GRANT_READ,
+            Tinebase_Model_Grants::GRANT_SYNC,
+        ), true);
+
+        // clear container caches (brute force)
+        Tinebase_Core::getCache()->clean(Zend_Cache::CLEANING_MODE_ALL);
+
         $this->server = new Sabre\DAV\Server(new Tinebase_WebDav_Root());
         $this->server->debugExceptions = true;
         $this->server->addPlugin(new \Sabre\CalDAV\Plugin());
@@ -77,7 +101,7 @@ class Calendar_Frontend_CalDAV_ProxyTest extends TestCase
         $this->server->httpRequest = $request;
         $this->server->exec();
         //var_dump($this->response->body);
-        
+
         $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status);
         
         $responseDoc = new DOMDocument();
@@ -94,6 +118,13 @@ class Calendar_Frontend_CalDAV_ProxyTest extends TestCase
         $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/cs:calendar-proxy-write-for');
         $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
         #$this->assertEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
+
+        $nodes = $xpath->query('///d:response/d:href[text()="/principals/users/shared/"]');
+        $this->assertEquals(1, $nodes->length, "shared principal is missing in \n" . $responseDoc->saveXML());
+
+        $sclever = Tinebase_Helper::array_value('sclever', Zend_Registry::get('personas'));
+        $nodes = $xpath->query('///d:response/d:href[text()="/principals/users/'. $sclever->contact_id .'/"]');
+        $this->assertEquals(1, $nodes->length, "sclevers principal is missing in \n" .$responseDoc->saveXML());
     }
     
     /**