aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php239
1 files changed, 106 insertions, 133 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php
index 337b658f4..f71c19523 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php
@@ -2,7 +2,8 @@
namespace Sabre\CalDAV;
-use Sabre\DAVACL;
+use Sabre\DAV\Sharing;
+use Sabre\DAV\Xml\Element\Sharee;
class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
@@ -11,96 +12,95 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
function getInstance(array $props = null) {
if (is_null($props)) {
- $props = array(
- 'id' => 1,
+ $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' => false,
- 'principaluri' => 'principals/sharee',
- );
+ '{http://sabredav.org/ns}owner-principal' => 'principals/owner',
+ '{http://sabredav.org/ns}read-only' => false,
+ 'share-access' => Sharing\Plugin::ACCESS_READWRITE,
+ 'principaluri' => 'principals/sharee',
+ ];
}
$this->backend = new Backend\MockSharing(
- array($props),
- array(),
- array()
+ [$props],
+ [],
+ []
);
- $this->backend->updateShares(1, array(
- array(
- 'href' => 'mailto:removeme@example.org',
- 'commonName' => 'To be removed',
- 'readOnly' => true,
- ),
- ), array());
+
+ $sharee = new Sharee();
+ $sharee->href = 'mailto:removeme@example.org';
+ $sharee->properties['{DAV:}displayname'] = 'To be removed';
+ $sharee->access = Sharing\Plugin::ACCESS_READ;
+ $this->backend->updateInvites(1, [$sharee]);
return new SharedCalendar($this->backend, $props);
}
- function testGetSharedUrl() {
- $this->assertEquals('calendars/owner/original', $this->getInstance()->getSharedUrl());
- }
+ function testGetInvites() {
- function testGetShares() {
+ $sharee = new Sharee();
+ $sharee->href = 'mailto:removeme@example.org';
+ $sharee->properties['{DAV:}displayname'] = 'To be removed';
+ $sharee->access = Sharing\Plugin::ACCESS_READ;
+ $sharee->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE;
- $this->assertEquals(array(array(
- 'href' => 'mailto:removeme@example.org',
- 'commonName' => 'To be removed',
- 'readOnly' => true,
- 'status' => SharingPlugin::STATUS_NORESPONSE,
- )), $this->getInstance()->getShares());
+ $this->assertEquals(
+ [$sharee],
+ $this->getInstance()->getInvites()
+ );
}
function testGetOwner() {
- $this->assertEquals('principals/owner', $this->getInstance()->getOwner());
+ $this->assertEquals('principals/sharee', $this->getInstance()->getOwner());
}
function testGetACL() {
- $expected = array(
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner',
+ $expected = [
+ [
+ 'privilege' => '{DAV:}write',
+ 'principal' => 'principals/sharee',
'protected' => true,
- ),
-
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-write',
+ ],
+ [
+ 'privilege' => '{DAV:}write',
+ 'principal' => 'principals/sharee/calendar-proxy-write',
'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-read',
+ ],
+ [
+ 'privilege' => '{DAV:}write-properties',
+ 'principal' => 'principals/sharee',
'protected' => true,
- ),
- array(
- 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
- 'principal' => '{DAV:}authenticated',
+ ],
+ [
+ 'privilege' => '{DAV:}write-properties',
+ 'principal' => 'principals/sharee/calendar-proxy-write',
'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/owner',
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/sharee',
'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/owner/calendar-proxy-write',
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/sharee/calendar-proxy-read',
'protected' => true,
- ),
- array(
+ ],
+ [
'privilege' => '{DAV:}read',
- 'principal' => 'principals/sharee',
+ 'principal' => 'principals/sharee/calendar-proxy-write',
'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/sharee',
+ ],
+ [
+ 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
+ 'principal' => '{DAV:}authenticated',
'protected' => true,
- ),
- );
+ ],
+ ];
$this->assertEquals($expected, $this->getInstance()->getACL());
@@ -108,96 +108,69 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
function testGetChildACL() {
- $expected = array(
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-write',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-read',
- 'protected' => true,
- ),
- array(
+ $expected = [
+ [
'privilege' => '{DAV:}write',
- 'principal' => 'principals/owner',
+ 'principal' => 'principals/sharee',
'protected' => true,
- ),
- array(
+ ],
+ [
'privilege' => '{DAV:}write',
- 'principal' => 'principals/owner/calendar-proxy-write',
+ 'principal' => 'principals/sharee/calendar-proxy-write',
'protected' => true,
- ),
- array(
+ ],
+ [
'privilege' => '{DAV:}read',
'principal' => 'principals/sharee',
'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/sharee',
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/sharee/calendar-proxy-write',
'protected' => true,
- ),
- );
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/sharee/calendar-proxy-read',
+ 'protected' => true,
+ ],
+
+ ];
$this->assertEquals($expected, $this->getInstance()->getChildACL());
}
- function testGetChildACLReadOnly() {
+ function testUpdateInvites() {
- $expected = array(
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-write',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-read',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/sharee',
- 'protected' => true,
- ),
- );
+ $instance = $this->getInstance();
+ $newSharees = [
+ new Sharee(),
+ new Sharee()
+ ];
+ $newSharees[0]->href = 'mailto:test@example.org';
+ $newSharees[0]->properties['{DAV:}displayname'] = 'Foo Bar';
+ $newSharees[0]->comment = 'Booh';
+ $newSharees[0]->access = Sharing\Plugin::ACCESS_READWRITE;
- $props = array(
- '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());
+ $newSharees[1]->href = 'mailto:removeme@example.org';
+ $newSharees[1]->access = Sharing\Plugin::ACCESS_NOACCESS;
+
+ $instance->updateInvites($newSharees);
+
+ $expected = [
+ clone $newSharees[0]
+ ];
+ $expected[0]->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE;
+ $this->assertEquals($expected, $instance->getInvites());
}
- /**
- * @expectedException InvalidArgumentException
- */
- public function testCreateInstanceMissingArg() {
+ function testPublish() {
- $this->getInstance(array(
- 'id' => 1,
- '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original',
- '{http://sabredav.org/ns}read-only' => false,
- 'principaluri' => 'principals/sharee',
- ));
+ $instance = $this->getInstance();
+ $this->assertNull($instance->setPublishStatus(true));
+ $this->assertNull($instance->setPublishStatus(false));
}
-
}