[Pkg-owncloud-commits] [php-sabredav] 28/220: CalDAV tests are passing again (omg)

David Prévot taffit at moszumanska.debian.org
Thu May 12 01:21:04 UTC 2016


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

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

commit 55aff8e755101353ce9014408379fc29d288da29
Author: Evert Pot <me at evertpot.com>
Date:   Tue Oct 20 16:08:02 2015 -0400

    CalDAV tests are passing again (omg)
---
 lib/CalDAV/SharedCalendar.php              | 78 ++++++++++++++++++------
 lib/CalDAV/SharingPlugin.php               | 53 +++++++++-------
 lib/DAV/Tree.php                           |  2 +-
 tests/Sabre/CalDAV/Backend/MockSharing.php | 46 ++++++++++++--
 tests/Sabre/CalDAV/SharedCalendarTest.php  | 97 +++++++-----------------------
 tests/Sabre/CalDAV/SharingPluginTest.php   | 39 ++++--------
 6 files changed, 170 insertions(+), 145 deletions(-)

diff --git a/lib/CalDAV/SharedCalendar.php b/lib/CalDAV/SharedCalendar.php
index e3c04c2..c042030 100644
--- a/lib/CalDAV/SharedCalendar.php
+++ b/lib/CalDAV/SharedCalendar.php
@@ -92,7 +92,7 @@ class SharedCalendar extends Calendar implements ISharedCalendar {
      */
     function getOwner() {
 
-        return $this->calendarInfo['{http://sabredav.org/ns}owner-principal'];
+        return $this->calendarInfo['principaluri'];
 
     }
 
@@ -110,10 +110,7 @@ class SharedCalendar extends Calendar implements ISharedCalendar {
      */
     function getACL() {
 
-        // The top-level ACL only contains access information for the true
-        // owner of the calendar, so we need to add the information for the
-        // sharee.
-        $acl = parent::getACL();
+        $acl = [];
 
         switch ($this->getShareAccess()) {
             case SPlugin::ACCESS_NOTSHARED :
@@ -123,6 +120,11 @@ class SharedCalendar extends Calendar implements ISharedCalendar {
                     'principal' => $this->calendarInfo['principaluri'],
                     'protected' => true,
                 ];
+                $acl[] = [
+                    'privilege' => '{DAV:}share',
+                    'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write',
+                    'protected' => true,
+                ];
                 // No break intentional!
             case SPlugin::ACCESS_READWRITE :
                 $acl[] = [
@@ -130,6 +132,11 @@ class SharedCalendar extends Calendar implements ISharedCalendar {
                     'principal' => $this->calendarInfo['principaluri'],
                     'protected' => true,
                 ];
+                $acl[] = [
+                    'privilege' => '{DAV:}write',
+                    'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write',
+                    'protected' => true,
+                ];
                 // No break intentional!
             case SPlugin::ACCESS_READONLY :
                 $acl[] = [
@@ -138,10 +145,30 @@ class SharedCalendar extends Calendar implements ISharedCalendar {
                     'protected' => true,
                 ];
                 $acl[] = [
+                    'privilege' => '{DAV:}write-properties',
+                    'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write',
+                    'protected' => true,
+                ];
+                $acl[] = [
                     'privilege' => '{DAV:}read',
                     'principal' => $this->calendarInfo['principaluri'],
                     'protected' => true,
                 ];
+                $acl[] = [
+                    'privilege' => '{DAV:}read',
+                    'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read',
+                    'protected' => true,
+                ];
+                $acl[] = [
+                    'privilege' => '{DAV:}read',
+                    'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write',
+                    'protected' => true,
+                ];
+                $acl[] = [
+                    'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
+                    'principal' => '{DAV:}authenticated',
+                    'protected' => true,
+                ];
                 break;
         }
         return $acl;
@@ -180,12 +207,7 @@ class SharedCalendar extends Calendar implements ISharedCalendar {
      */
     function getChildACL() {
 
-        $acl = parent::getChildACL();
-        $acl[] = [
-            'privilege' => '{DAV:}read',
-            'principal' => $this->calendarInfo['principaluri'],
-            'protected' => true,
-        ];
+        $acl = [];
 
         switch ($this->getShareAccess()) {
             case SPlugin::ACCESS_NOTSHARED :
@@ -193,13 +215,33 @@ class SharedCalendar extends Calendar implements ISharedCalendar {
             case SPlugin::ACCESS_OWNER :
                 // No break intentional
             case SPlugin::ACCESS_READWRITE:
-                if (!$this->calendarInfo['{http://sabredav.org/ns}read-only']) {
-                    $acl[] = [
-                        'privilege' => '{DAV:}write',
-                        'principal' => $this->calendarInfo['principaluri'],
-                        'protected' => true,
-                    ];
-                }
+                $acl[] = [
+                    'privilege' => '{DAV:}write',
+                    'principal' => $this->calendarInfo['principaluri'],
+                    'protected' => true,
+                ];
+                $acl[] = [
+                    'privilege' => '{DAV:}write',
+                    'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write',
+                    'protected' => true,
+                ];
+                // No break intentional
+            case SPlugin::ACCESS_READONLY:
+                $acl[] = [
+                    'privilege' => '{DAV:}read',
+                    'principal' => $this->calendarInfo['principaluri'],
+                    'protected' => true,
+                ];
+                $acl[] = [
+                    'privilege' => '{DAV:}read',
+                    'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write',
+                    'protected' => true,
+                ];
+                $acl[] = [
+                    'privilege' => '{DAV:}read',
+                    'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read',
+                    'protected' => true,
+                ];
                 break;
         }
 
diff --git a/lib/CalDAV/SharingPlugin.php b/lib/CalDAV/SharingPlugin.php
index 492067a..9d0ebeb 100644
--- a/lib/CalDAV/SharingPlugin.php
+++ b/lib/CalDAV/SharingPlugin.php
@@ -88,8 +88,6 @@ class SharingPlugin extends DAV\ServerPlugin {
             throw new \LogicException('The generic "sharing" plugin must be loaded before the caldav sharing plugin. Call $server->addPlugin(new \Sabre\DAV\Sharing\Plugin()); before this one.');
         }
 
-        $server->resourceTypeMapping['Sabre\\CalDAV\\ISharedCalendar'] = '{' . Plugin::NS_CALENDARSERVER . '}shared';
-
         array_push(
             $this->server->protectedProperties,
             '{' . Plugin::NS_CALENDARSERVER . '}invite',
@@ -131,11 +129,13 @@ class SharingPlugin extends DAV\ServerPlugin {
 
         if ($node instanceof ISharedCalendar) {
 
+            /**
             $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}shared-url', function() use ($node) {
                 return new Href(
                     $node->getSharedUrl()
                 );
             });
+            **/
 
             $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}invite', function() use ($node) {
 
@@ -184,10 +184,18 @@ class SharingPlugin extends DAV\ServerPlugin {
      */
     function propFindLate(DAV\PropFind $propFind, DAV\INode $node) {
 
-        if ($node instanceof IShareableCalendar) {
+        if ($node instanceof ISharedCalendar) {
+            $shareAccess = $node->getShareAccess();
             if ($rt = $propFind->get('{DAV:}resourcetype')) {
-                if (count($node->getShares()) > 0) {
-                    $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared-owner');
+                switch($shareAccess) {
+                    case \Sabre\DAV\Sharing\Plugin::ACCESS_OWNER :
+                        $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared-owner');
+                        break;
+                    case \Sabre\DAV\Sharing\Plugin::ACCESS_READONLY :
+                    case \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE :
+                        $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared');
+                        break;
+
                 }
             }
             $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', function() {
@@ -216,21 +224,25 @@ class SharingPlugin extends DAV\ServerPlugin {
     function propPatch($path, DAV\PropPatch $propPatch) {
 
         $node = $this->server->tree->getNodeForPath($path);
-        if (!$node instanceof IShareableCalendar)
+        if (!$node instanceof ISharedCalendar)
             return;
 
-        $propPatch->handle('{DAV:}resourcetype', function($value) use ($node) {
-            if ($value->is('{' . Plugin::NS_CALENDARSERVER . '}shared-owner')) return false;
-            $shares = $node->getShares();
-            $remove = [];
-            foreach ($shares as $share) {
-                $remove[] = $share['href'];
-            }
-            $node->updateShares([], $remove);
+        if ($node->getShareAccess()===\Sabre\DAV\Sharing\Plugin::ACCESS_OWNER || $node->getShareAccess()===\Sabre\DAV\Sharing\Plugin::ACCESS_NOTSHARED) {
+
+            $propPatch->handle('{DAV:}resourcetype', function($value) use ($node) {
+                if ($value->is('{' . Plugin::NS_CALENDARSERVER . '}shared-owner')) return false;
+                $shares = $node->getShares();
+                $remove = [];
+                foreach ($shares as $share) {
+                    $remove[] = $share['href'];
+                }
+                $node->updateShares([], $remove);
+
+                return true;
 
-            return true;
+            });
 
-        });
+        }
 
     }
 
@@ -274,7 +286,6 @@ class SharingPlugin extends DAV\ServerPlugin {
 
             // Both the DAV:share-resource and CALENDARSERVER:share requests
             // behave identically.
-            case '{DAV:}share-resource' :
             case '{' . Plugin::NS_CALENDARSERVER . '}share' :
 
                 $sharingPlugin = $this->server->getPlugin('sharing');
@@ -337,7 +348,7 @@ class SharingPlugin extends DAV\ServerPlugin {
             case '{' . Plugin::NS_CALENDARSERVER . '}publish-calendar' :
 
                 // We can only deal with IShareableCalendar objects
-                if (!$node instanceof IShareableCalendar) {
+                if (!$node instanceof ISharedCalendar) {
                     return;
                 }
                 $this->server->transactionType = 'post-publish-calendar';
@@ -347,7 +358,7 @@ class SharingPlugin extends DAV\ServerPlugin {
 
                 // If there's no ACL support, we allow everything
                 if ($acl) {
-                    $acl->checkPrivileges($path, '{DAV:}write');
+                    $acl->checkPrivileges($path, '{DAV:}share');
                 }
 
                 $node->setPublishStatus(true);
@@ -365,7 +376,7 @@ class SharingPlugin extends DAV\ServerPlugin {
             case '{' . Plugin::NS_CALENDARSERVER . '}unpublish-calendar' :
 
                 // We can only deal with IShareableCalendar objects
-                if (!$node instanceof IShareableCalendar) {
+                if (!$node instanceof ISharedCalendar) {
                     return;
                 }
                 $this->server->transactionType = 'post-unpublish-calendar';
@@ -375,7 +386,7 @@ class SharingPlugin extends DAV\ServerPlugin {
 
                 // If there's no ACL support, we allow everything
                 if ($acl) {
-                    $acl->checkPrivileges($path, '{DAV:}write');
+                    $acl->checkPrivileges($path, '{DAV:}share');
                 }
 
                 $node->setPublishStatus(false);
diff --git a/lib/DAV/Tree.php b/lib/DAV/Tree.php
index f6e64bc..5929978 100644
--- a/lib/DAV/Tree.php
+++ b/lib/DAV/Tree.php
@@ -227,7 +227,7 @@ class Tree {
         // flushing the entire cache
         $path = trim($path, '/');
         foreach ($this->cache as $nodePath => $node) {
-            if ($nodePath == $path || strpos($nodePath, $path . '/') === 0)
+            if ($path === '' || $nodePath == $path || strpos($nodePath, $path . '/') === 0)
                 unset($this->cache[$nodePath]);
 
         }
diff --git a/tests/Sabre/CalDAV/Backend/MockSharing.php b/tests/Sabre/CalDAV/Backend/MockSharing.php
index 2156627..4de3428 100644
--- a/tests/Sabre/CalDAV/Backend/MockSharing.php
+++ b/tests/Sabre/CalDAV/Backend/MockSharing.php
@@ -19,6 +19,43 @@ class MockSharing extends Mock implements NotificationSupport, SharingSupport {
     }
 
     /**
+     * Returns a list of calendars for a principal.
+     *
+     * Every project is an array with the following keys:
+     *  * id, a unique id that will be used by other functions to modify the
+     *    calendar. This can be the same as the uri or a database key.
+     *  * uri, which the basename of the uri with which the calendar is
+     *    accessed.
+     *  * principalUri. The owner of the calendar. Almost always the same as
+     *    principalUri passed to this method.
+     *
+     * Furthermore it can contain webdav properties in clark notation. A very
+     * common one is '{DAV:}displayname'.
+     *
+     * @param string $principalUri
+     * @return array
+     */
+    function getCalendarsForUser($principalUri) {
+
+        $calendars = parent::getCalendarsForUser($principalUri);
+        foreach ($calendars as $k => $calendar) {
+
+            if (isset($calendar['share-access'])) {
+                continue;
+            }
+            if (!empty($this->shares[$calendar['id']])) {
+                $calendar['share-access'] = \Sabre\DAV\Sharing\Plugin::ACCESS_OWNER;
+            } else {
+                $calendar['share-access'] = \Sabre\DAV\Sharing\Plugin::ACCESS_NOTSHARED;
+            }
+            $calendars[$k] = $calendar;
+
+        }
+        return $calendars;
+
+    }
+
+    /**
      * Returns a list of notifications for a given principal url.
      *
      * The returned array should only consist of implementations of
@@ -47,7 +84,7 @@ class MockSharing extends Mock implements NotificationSupport, SharingSupport {
      */
     function deleteNotification($principalUri, NotificationInterface $notification) {
 
-        foreach($this->notifications[$principalUri] as $key=>$value) {
+        foreach ($this->notifications[$principalUri] as $key => $value) {
             if ($notification === $value) {
                 unset($this->notifications[$principalUri][$key]);
             }
@@ -84,12 +121,12 @@ class MockSharing extends Mock implements NotificationSupport, SharingSupport {
             $this->shares[$calendarId] = [];
         }
 
-        foreach($add as $val) {
+        foreach ($add as $val) {
             $val['status'] = CalDAV\SharingPlugin::STATUS_NORESPONSE;
             $this->shares[$calendarId][] = $val;
         }
 
-        foreach($this->shares[$calendarId] as $k=>$share) {
+        foreach ($this->shares[$calendarId] as $k => $share) {
 
             if (in_array($share['href'], $remove)) {
                 unset($this->shares[$calendarId][$k]);
@@ -153,7 +190,7 @@ class MockSharing extends Mock implements NotificationSupport, SharingSupport {
      */
     function setPublishStatus($calendarId, $value) {
 
-        foreach($this->calendars as $k=>$cal) {
+        foreach ($this->calendars as $k => $cal) {
             if ($cal['id'] === $calendarId) {
                 if (!$value) {
                     unset($cal['{http://calendarserver.org/ns/}publish-url']);
@@ -169,4 +206,3 @@ class MockSharing extends Mock implements NotificationSupport, SharingSupport {
     }
 
 }
-
diff --git a/tests/Sabre/CalDAV/SharedCalendarTest.php b/tests/Sabre/CalDAV/SharedCalendarTest.php
index cb595d3..8bac377 100644
--- a/tests/Sabre/CalDAV/SharedCalendarTest.php
+++ b/tests/Sabre/CalDAV/SharedCalendarTest.php
@@ -50,51 +50,30 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
     }
 
     function testGetOwner() {
-        $this->assertEquals('principals/owner', $this->getInstance()->getOwner());
+        $this->assertEquals('principals/sharee', $this->getInstance()->getOwner());
     }
 
     function testGetACL() {
 
         $expected = [
             [
-                'privilege' => '{DAV:}read',
-                'principal' => 'principals/owner',
-                'protected' => true,
-            ],
-
-            [
-                'privilege' => '{DAV:}read',
-                'principal' => 'principals/owner/calendar-proxy-write',
-                'protected' => true,
-            ],
-            [
-                'privilege' => '{DAV:}read',
-                'principal' => 'principals/owner/calendar-proxy-read',
-                'protected' => true,
-            ],
-            [
-                'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
-                'principal' => '{DAV:}authenticated',
-                'protected' => true,
-            ],
-            [
                 'privilege' => '{DAV:}write',
-                'principal' => 'principals/owner',
+                'principal' => 'principals/sharee',
                 'protected' => true,
             ],
             [
                 'privilege' => '{DAV:}write',
-                'principal' => 'principals/owner/calendar-proxy-write',
+                'principal' => 'principals/sharee/calendar-proxy-write',
                 'protected' => true,
             ],
             [
-                'privilege' => '{DAV:}write',
+                'privilege' => '{DAV:}write-properties',
                 'principal' => 'principals/sharee',
                 'protected' => true,
             ],
             [
                 'privilege' => '{DAV:}write-properties',
-                'principal' => 'principals/sharee',
+                'principal' => 'principals/sharee/calendar-proxy-write',
                 'protected' => true,
             ],
             [
@@ -102,89 +81,59 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
                 'principal' => 'principals/sharee',
                 'protected' => true,
             ],
-        ];
-
-        $this->assertEquals($expected, $this->getInstance()->getACL());
-
-    }
-
-    function testGetChildACL() {
-
-        $expected = [
             [
                 'privilege' => '{DAV:}read',
-                'principal' => 'principals/owner',
+                'principal' => 'principals/sharee/calendar-proxy-read',
                 'protected' => true,
             ],
             [
                 'privilege' => '{DAV:}read',
-                'principal' => 'principals/owner/calendar-proxy-write',
+                'principal' => 'principals/sharee/calendar-proxy-write',
                 'protected' => true,
             ],
             [
-                'privilege' => '{DAV:}read',
-                'principal' => 'principals/owner/calendar-proxy-read',
-                'protected' => true,
-            ],
-            [
-                'privilege' => '{DAV:}write',
-                'principal' => 'principals/owner',
-                'protected' => true,
-            ],
-            [
-                'privilege' => '{DAV:}write',
-                'principal' => 'principals/owner/calendar-proxy-write',
-                'protected' => true,
-            ],
-            [
-                'privilege' => '{DAV:}read',
-                'principal' => 'principals/sharee',
-                'protected' => true,
-            ],
-            [
-                'privilege' => '{DAV:}write',
-                'principal' => 'principals/sharee',
+                'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
+                'principal' => '{DAV:}authenticated',
                 'protected' => true,
             ],
         ];
 
-        $this->assertEquals($expected, $this->getInstance()->getChildACL());
+        $this->assertEquals($expected, $this->getInstance()->getACL());
 
     }
 
-    function testGetChildACLReadOnly() {
+    function testGetChildACL() {
 
         $expected = [
             [
-                'privilege' => '{DAV:}read',
-                'principal' => 'principals/owner',
+                'privilege' => '{DAV:}write',
+                'principal' => 'principals/sharee',
+                'protected' => true,
+            ],
+            [
+                'privilege' => '{DAV:}write',
+                'principal' => 'principals/sharee/calendar-proxy-write',
                 'protected' => true,
             ],
             [
                 'privilege' => '{DAV:}read',
-                'principal' => 'principals/owner/calendar-proxy-write',
+                'principal' => 'principals/sharee',
                 'protected' => true,
             ],
             [
                 'privilege' => '{DAV:}read',
-                'principal' => 'principals/owner/calendar-proxy-read',
+                'principal' => 'principals/sharee/calendar-proxy-write',
                 'protected' => true,
             ],
             [
                 'privilege' => '{DAV:}read',
-                'principal' => 'principals/sharee',
+                'principal' => 'principals/sharee/calendar-proxy-read',
                 'protected' => true,
             ],
-        ];
 
-        $props = [
-            'id'                                        => 1,
-            '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original',
-            '{http://sabredav.org/ns}owner-principal'   => 'principals/owner',
-            '{http://sabredav.org/ns}read-only'         => true,
-            'principaluri'                              => 'principals/sharee',
         ];
-        $this->assertEquals($expected, $this->getInstance($props)->getChildACL());
+
+        $this->assertEquals($expected, $this->getInstance()->getChildACL());
 
     }
 
diff --git a/tests/Sabre/CalDAV/SharingPluginTest.php b/tests/Sabre/CalDAV/SharingPluginTest.php
index 87c0395..34dd05a 100644
--- a/tests/Sabre/CalDAV/SharingPluginTest.php
+++ b/tests/Sabre/CalDAV/SharingPluginTest.php
@@ -24,9 +24,7 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
                 'principaluri'                                  => 'principals/user1',
                 'id'                                            => 2,
                 'uri'                                           => 'cal2',
-                '{' . Plugin::NS_CALENDARSERVER . '}shared-url' => 'calendars/user1/cal2',
-                '{http://sabredav.org/ns}owner-principal'       => 'principals/user2',
-                '{http://sabredav.org/ns}read-only'             => 'true',
+                'share-access'                                  => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE,
             ],
             [
                 'principaluri' => 'principals/user1',
@@ -38,7 +36,6 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
         parent::setUp();
 
         // Making the logged in user an admin, for full access:
-        $this->aclPlugin->adminPrincipals[] = 'principals/user1';
         $this->aclPlugin->adminPrincipals[] = 'principals/user2';
 
     }
@@ -81,11 +78,11 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
         ]);
 
         $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
-        $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']);
+        //$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']);
 
     }
 
-    function testUpdateProperties() {
+    function testUpdateResourceType() {
 
         $this->caldavBackend->updateShares(1,
             [
@@ -114,7 +111,7 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
         ]);
 
         $this->assertEquals([
-            '{DAV:}foo' => 403,
+            '{DAV:}foo' => 200,
         ], $result);
 
     }
@@ -162,11 +159,7 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
 
     function testShareRequest() {
 
-        $request = HTTP\Sapi::createFromServerArray([
-            'REQUEST_METHOD' => 'POST',
-            'REQUEST_URI'    => '/calendars/user1/cal1',
-            'CONTENT_TYPE'   => 'text/xml',
-        ]);
+        $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']);
 
         $xml = <<<RRR
 <?xml version="1.0"?>
@@ -184,8 +177,7 @@ RRR;
 
         $request->setBody($xml);
 
-        $response = $this->request($request);
-        $this->assertEquals(200, $response->status, $response->body);
+        $response = $this->request($request, 200);
 
         $this->assertEquals([[
             'href'       => 'mailto:joe at example.org',
@@ -195,6 +187,9 @@ RRR;
             'summary'    => '',
         ]], $this->caldavBackend->getShares(1));
 
+        // Wiping out tree cache
+        $this->server->tree->markDirty('');
+
         // Verifying that the calendar is now marked shared.
         $props = $this->server->getProperties('calendars/user1/cal1', ['{DAV:}resourcetype']);
         $this->assertTrue(
@@ -226,8 +221,7 @@ RRR;
 
         $request->setBody($xml);
 
-        $response = $this->request($request);
-        $this->assertEquals(403, $response->getStatus(), $response->getBody());
+        $response = $this->request($request, 403);
 
     }
 
@@ -295,11 +289,7 @@ RRR;
 
     function testPublish() {
 
-        $request = HTTP\Sapi::createFromServerArray([
-            'REQUEST_METHOD' => 'POST',
-            'REQUEST_URI'    => '/calendars/user1/cal1',
-            'CONTENT_TYPE'   => 'text/xml',
-        ]);
+        $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']);
 
         $xml = '<?xml version="1.0"?>
 <cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
@@ -344,9 +334,7 @@ RRR;
 ';
 
         $request->setBody($xml);
-
-        $response = $this->request($request);
-        $this->assertEquals(501, $response->status, $response->body);
+        $this->request($request, 403);
 
     }
 
@@ -364,8 +352,7 @@ RRR;
 
         $request->setBody($xml);
 
-        $response = $this->request($request);
-        $this->assertEquals(501, $response->status, $response->body);
+        $this->request($request, 403);
 
     }
 

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



More information about the Pkg-owncloud-commits mailing list