[Pkg-owncloud-commits] [php-sabredav] 42/220: Updating to match new draft. New sharee object.
David Prévot
taffit at moszumanska.debian.org
Thu May 12 01:21:05 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 4291c4b8402cc4d3cd06cfa61910ddc20ecfea89
Author: Evert Pot <me at evertpot.com>
Date: Mon Jan 11 20:33:52 2016 -0500
Updating to match new draft. New sharee object.
---
lib/DAV/Sharing/ISharedNode.php | 49 +++++-----
lib/DAV/Sharing/Plugin.php | 57 +++++-------
lib/DAV/Sharing/Sharee.php | 64 +++++++++++++
lib/DAV/Xml/Property/ShareAccess.php | 61 +++++++++++--
lib/DAV/Xml/Property/ShareMode.php | 79 ----------------
lib/DAV/Xml/Request/ShareResource.php | 106 ++++++++--------------
tests/Sabre/DAV/Mock/ShareableNode.php | 62 -------------
tests/Sabre/DAV/Mock/SharedNode.php | 92 +++++++++++++++++++
tests/Sabre/DAV/Sharing/PluginTest.php | 18 +++-
tests/Sabre/DAV/Xml/Property/ShareAccessTest.php | 53 +++++++++++
tests/Sabre/DAV/Xml/Property/ShareModeTest.php | 36 --------
tests/Sabre/DAV/Xml/Request/ShareResourceTest.php | 78 ++++++++--------
12 files changed, 408 insertions(+), 347 deletions(-)
diff --git a/lib/DAV/Sharing/ISharedNode.php b/lib/DAV/Sharing/ISharedNode.php
index dae0428..3cf10d7 100644
--- a/lib/DAV/Sharing/ISharedNode.php
+++ b/lib/DAV/Sharing/ISharedNode.php
@@ -9,7 +9,7 @@ use Sabre\DAV\INode;
* because it's possible for an owner to share the resource, or because this is
* an instance of a shared resource.
*
- * @copyright Copyright (C) 2007-2015 fruux GmbH. (https://fruux.com/)
+ * @copyright Copyright (C) fruux GmbH. (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -26,39 +26,44 @@ interface ISharedNode extends INode {
function getShareAccess();
/**
- * Updates the list of shares.
+ * This function must return a URI that uniquely identifies the shared
+ * resource. This URI should be identical across instances, and is
+ * also used in several other XML bodies to connect invites to
+ * resources.
*
- * The first array is a list of people that are to be added to the
- * shared resource.
+ * This may simply be a relative reference to the original shared instance,
+ * but it could also be a urn. As long as it's a valid URI and unique.
*
- * Every element in the add array has the following properties:
- * * href - A url. Usually a mailto: address
- * * summary - A description of the share, can also be false
- * * readOnly - A boolean value
- *
- * In addition to that, the array might have any additional properties,
- * specified in clark-notation, such as '{DAV:}displayname'.
+ * @return string
+ */
+ function getShareResourceUri();
+
+ /**
+ * Updates the list of sharees.
*
- * Every element in the remove array is just the url of the sharee that's
- * to be removed.
+ * Every item must be a Sharee object.
*
- * @param array $add
- * @param array $remove
+ * @param Sharee[] $sharees
* @return void
*/
- function updateShares(array $add, array $remove);
+ function updateInvites(array $sharees);
/**
* Returns the list of people whom this resource is shared with.
*
- * Every element in this array should have the following properties:
- * * href - Often a mailto: address
- * * commonName - Optional, for example a first + last name
- * * status - See the Sabre\DAV\Sharing\Plugin::STATUS_ constants.
- * * access - one of the Sabre\DAV\Sharing\Plugin::ACCESS_ constants.
+ * Every item in the returned array must be a Sharee object with
+ * at least the following properties set:
+ *
+ * * $href
+ * * $shareAccess
+ * * $inviteStatus
+ *
+ * and optionally:
+ *
+ * * $properties
*
* @return array
*/
- function getShares();
+ function getInvites();
}
diff --git a/lib/DAV/Sharing/Plugin.php b/lib/DAV/Sharing/Plugin.php
index 74be944..57850bf 100644
--- a/lib/DAV/Sharing/Plugin.php
+++ b/lib/DAV/Sharing/Plugin.php
@@ -26,9 +26,15 @@ use Sabre\HTTP\ResponseInterface;
class Plugin extends ServerPlugin {
const ACCESS_NOTSHARED = 0;
- const ACCESS_OWNER = 1;
- const ACCESS_READONLY = 2;
+ const ACCESS_SHAREDOWNER = 1;
+ const ACCESS_READ = 2;
const ACCESS_READWRITE = 3;
+ const ACCESS_NOACCESS = 4;
+
+ const INVITE_NORESPONSE = 1;
+ const INVITE_ACCEPTED = 2;
+ const INVITE_DECLINED = 3;
+ const INVITE_INVALID = 4;
/**
* Reference to SabreDAV server object.
@@ -95,26 +101,14 @@ class Plugin extends ServerPlugin {
/**
* Updates the list of sharees on a shared resource.
*
- * The set array is a list of people that are to be added to the
- * shared resource.
- *
- * Every element in the add array has the following properties:
- * * href - A url. Usually a mailto: address
- * * summary - A description of the share, can also be false
- * * readOnly - A boolean value
- *
- * In addition to that, the array might have any additional properties,
- * specified in clark-notation, such as '{DAV:}displayname'.
- *
- * Every element in the remove array is just the url of the sharee that's
- * to be removed.
+ * The sharees array is a list of people that are to be added modified
+ * or removed in the list of shares.
*
* @param string $path
- * @param array $set
- * @param array $remove
+ * @param Sharee[] $sharees
* @return void
*/
- function shareResource($path, $set, $remove) {
+ function shareResource($path, array $sharees) {
try {
$node = $this->server->tree->getNodeForPath($path);
@@ -137,7 +131,7 @@ class Plugin extends ServerPlugin {
$acl->checkPrivileges($path, '{DAV:}share');
}
- $node->updateShares($set, $remove);
+ $node->updateShares($sharees);
}
@@ -153,25 +147,22 @@ class Plugin extends ServerPlugin {
function propFind(PropFind $propFind, INode $node) {
if ($node instanceof ISharedNode) {
- $propFind->handle('{DAV:}share-mode', function() use ($node) {
- switch ($node->getShareAccess()) {
- case self::ACCESS_NOTSHARED :
- return null;
- case self::ACCESS_OWNER :
- return new Property\ShareMode(Property\ShareMode::SHAREDOWNER);
- case self::ACCESS_READONLY :
- return new Property\ShareMode(Property\ShareMode::SHARED);
- case self::ACCESS_READWRITE :
- return new Property\ShareMode(Property\ShareMode::SHARED);
-
- }
- });
$propFind->handle('{DAV:}share-access', function() use ($node) {
return new Property\ShareAccess($node->getShareAccess());
});
+ $propFind->handle('{DAV:}invite', function() use ($node) {
+
+ return new Property\Invites($node->getInvites());
+
+ });
+ $propFind->handle('{DAV:}share-resource-uri', function() use ($node) {
+
+ return new Property\Href($node->getShareResourceUri());
+
+ });
}
@@ -204,7 +195,7 @@ class Plugin extends ServerPlugin {
case '{DAV:}share-resource':
- $this->shareResource($path, $message->set, $message->remove);
+ $this->shareResource($path, $message->sharees);
$response->setStatus(200);
// Adding this because sending a response body may cause issues,
// and I wanted some type of indicator the response was handled.
diff --git a/lib/DAV/Sharing/Sharee.php b/lib/DAV/Sharing/Sharee.php
new file mode 100644
index 0000000..3b4abf1
--- /dev/null
+++ b/lib/DAV/Sharing/Sharee.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Sabre\DAV\Sharing;
+
+/**
+ * This class acts as a value object for sharees. It's used to send around
+ * information about sharees.
+ *
+ * @copyright Copyright (C) fruux GmbH. (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Sharee {
+
+ /**
+ * A URL. Usually a mailto: address, could also be a principal url.
+ * This uniquely identifies the sharee.
+ *
+ * @var string
+ */
+ public $href;
+
+ /**
+ * A list of WebDAV properties that describe the sharee. This might for
+ * example contain a {DAV:}displayname with the real name of the user.
+ *
+ * @var array
+ */
+ public $properties = [];
+
+ /**
+ * Share access level. One of the Sabre\DAV\Sharing\Plugin::ACCESS
+ * constants.
+ *
+ * Can be one of:
+ *
+ * ACCESS_READ
+ * ACCESS_READWRITE
+ * ACCESS_SHAREDOWNER
+ * ACCESS_NOACCESS
+ *
+ * depending on context.
+ *
+ * @var int
+ */
+ public $shareAccess;
+
+ /**
+ * When a sharee is originally invited to a share, the sharer may add
+ * a comment. This will be placed in this property.
+ *
+ * @var string
+ */
+ public $comment;
+
+ /**
+ * The status of the invite, should be one of the
+ * Sabre\DAV\Sharing\Plugin::INVITE constants.
+ *
+ * @var int
+ */
+ public $invite;
+
+}
diff --git a/lib/DAV/Xml/Property/ShareAccess.php b/lib/DAV/Xml/Property/ShareAccess.php
index b79bf51..b40626d 100644
--- a/lib/DAV/Xml/Property/ShareAccess.php
+++ b/lib/DAV/Xml/Property/ShareAccess.php
@@ -2,9 +2,11 @@
namespace Sabre\DAV\Xml\Property;
-use Sabre\Xml\Writer;
-use Sabre\Xml\XmlSerializable;
use Sabre\DAV\Sharing\Plugin as SharingPlugin;
+use Sabre\DAV\Exception\BadRequest;
+use Sabre\Xml\Element;
+use Sabre\Xml\Reader;
+use Sabre\Xml\Writer;
/**
* This class represents the {DAV:}share-access property.
@@ -20,7 +22,7 @@ use Sabre\DAV\Sharing\Plugin as SharingPlugin;
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class ShareAccess implements XmlSerializable {
+class ShareAccess implements Element {
/**
* Either SHARED or SHAREDOWNER
@@ -80,18 +82,63 @@ class ShareAccess implements XmlSerializable {
case SharingPlugin::ACCESS_NOTSHARED :
$writer->writeElement('{DAV:}not-shared');
break;
- case SharingPlugin::ACCESS_OWNER :
+ case SharingPlugin::ACCESS_SHAREDOWNER :
$writer->writeElement('{DAV:}shared-owner');
break;
- case SharingPlugin::ACCESS_READONLY :
- $writer->writeElement('{DAV:}shared-readonly');
+ case SharingPlugin::ACCESS_READ :
+ $writer->writeElement('{DAV:}read');
break;
case SharingPlugin::ACCESS_READWRITE :
- $writer->writeElement('{DAV:}shared-readwrite');
+ $writer->writeElement('{DAV:}read-write');
+ break;
+ case SharingPlugin::ACCESS_NOACCESS :
+ $writer->writeElement('{DAV:}no-access');
break;
}
}
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statictly, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * You are responsible for advancing the reader to the next element. Not
+ * doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @param Reader $reader
+ * @return mixed
+ */
+ static function xmlDeserialize(Reader $reader) {
+
+ $elems = $reader->parseInnerTree();
+ $value = null;
+ foreach($elems as $elem) {
+ switch($elem['name']) {
+ case '{DAV:}not-shared' :
+ return new self(SharingPlugin::ACCESS_NOTSHARED);
+ case '{DAV:}sharedowner' :
+ return new self(SharingPlugin::ACCESS_SHAREDOWNER);
+ case '{DAV:}read' :
+ return new self(SharingPlugin::ACCESS_READ);
+ case '{DAV:}read-write' :
+ return new self(SharingPlugin::ACCESS_READWRITE);
+ case '{DAV:}no-access' :
+ return new self(SharingPlugin::ACCESS_NOACCESS);
+ }
+ }
+ throw new BadRequest('Invalid value for {DAV:}share-access element');
+
+ }
}
diff --git a/lib/DAV/Xml/Property/ShareMode.php b/lib/DAV/Xml/Property/ShareMode.php
deleted file mode 100644
index f5fd67d..0000000
--- a/lib/DAV/Xml/Property/ShareMode.php
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Xml\Property;
-
-use Sabre\Xml\Writer;
-use Sabre\Xml\XmlSerializable;
-
-/**
- * This class represents the {DAV:}share-mode property.
- *
- * This property is defined here:
- * https://tools.ietf.org/html/draft-pot-webdav-resource-sharing-02#section-5.2.1
- *
- * This property is used to indicate if a resource is a shared resource, and
- * whether the instance of the shared resource is the original instance, or
- * an instance belonging to a sharee.
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://www.rooftopsolutions.nl/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class ShareMode implements XmlSerializable {
-
- const SHARED = 1;
- const SHAREDOWNER = 2;
-
- /**
- * Either SHARED or SHAREDOWNER
- *
- * @var int
- */
- protected $value;
-
- /**
- * Creates the property
- *
- * @param int $shareModeType Either SHARED or SHAREDOWNER.
- */
- function __construct($shareModeType) {
-
- $this->value = $shareModeType;
-
- }
-
- /**
- * The xmlSerialize method is called during xml writing.
- *
- * Use the $writer argument to write its own xml serialization.
- *
- * An important note: do _not_ create a parent element. Any element
- * implementing XmlSerializble should only ever write what's considered
- * its 'inner xml'.
- *
- * The parent of the current element is responsible for writing a
- * containing element.
- *
- * This allows serializers to be re-used for different element names.
- *
- * If you are opening new elements, you must also close them again.
- *
- * @param Writer $writer
- * @return void
- */
- function xmlSerialize(Writer $writer) {
-
- switch ($this->value) {
-
- case self::SHARED :
- $writer->writeElement('{DAV:}shared');
- break;
- case self::SHAREDOWNER :
- $writer->writeElement('{DAV:}shared-owner');
- break;
-
- }
-
- }
-
-}
diff --git a/lib/DAV/Xml/Request/ShareResource.php b/lib/DAV/Xml/Request/ShareResource.php
index 59e8dad..316de7d 100644
--- a/lib/DAV/Xml/Request/ShareResource.php
+++ b/lib/DAV/Xml/Request/ShareResource.php
@@ -4,6 +4,9 @@ namespace Sabre\DAV\Xml\Request;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
+use Sabre\Xml\Deserializer;
+use Sabre\DAV\Sharing\Sharee;
+use Sabre\DAV\Exception\BadRequest;
/**
* ShareResource request parser.
@@ -19,39 +22,20 @@ use Sabre\Xml\XmlDeserializable;
class ShareResource implements XmlDeserializable {
/**
- * The list of new people added or updated.
+ * The list of new people added or updated or removed from the share.
*
- * Every element has the following keys:
- * 1. href - An email address
- * 2. comment - An optional description of the share
- * 3. readOnly - true or false
- *
- * In addition to that, it might contain a list of webdav properties
- * associated with the sharer. The most common one is {DAV:}displayname.
- *
- * @var array
- */
- public $set = [];
-
- /**
- * List of people removed from the share list.
- *
- * The list is a flat list of email addresses (including mailto:).
- *
- * @var array
+ * @var Sharee[]
*/
- public $remove = [];
+ public $sharees = [];
/**
* Constructor
*
- * @param array $set
- * @param array $remove
+ * @param Sharee[] $sharees
*/
- function __construct(array $set, array $remove) {
+ function __construct(array $sharees) {
- $this->set = $set;
- $this->remove = $remove;
+ $this->sharees = $sharees;
}
@@ -79,58 +63,42 @@ class ShareResource implements XmlDeserializable {
static function xmlDeserialize(Reader $reader) {
$elems = $reader->parseInnerTree([
- '{DAV:}set-invitee' => 'Sabre\\Xml\\Element\\KeyValue',
- '{DAV:}remove-invitee' => 'Sabre\\Xml\\Element\\KeyValue',
+ '{DAV:}sharee' => function(Reader $reader) {
+ return Deserializer\keyValue($reader, 'DAV:');
+ },
+ '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess',
+ '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue',
]);
- $set = [];
- $remove = [];
+ $sharees = [];
foreach ($elems as $elem) {
- switch ($elem['name']) {
-
- case '{DAV:}set-invitee' :
- $sharee = $elem['value'];
-
- $setInvitee = [
- 'href' => null,
- 'comment' => null,
- 'readOnly' => false,
- ];
- foreach ($sharee as $key => $value) {
-
- switch ($key) {
-
- case '{DAV:}href' :
- $setInvitee['href'] = $value;
- break;
- case '{DAV:}comment' :
- $setInvitee['comment'] = $value;
- break;
- case '{DAV:}read' :
- $setInvitee['readOnly'] = true;
- break;
- case '{DAV:}read-write' :
- $setInvitee['readOnly'] = false;
- break;
- default :
- $setInvitee[$key] = $value;
- break;
-
- }
-
- }
- $set[] = $setInvitee;
- break;
-
- case '{DAV:}remove-invitee' :
- $remove[] = $elem['value']['{DAV:}href'];
- break;
+ if ($elem['name'] !== '{DAV:}sharee') continue;
+ $xsharee = $elem['value'];
+
+ $sharee = new Sharee();
+ if (!isset($xsharee['href'])) {
+ throw new BadRequest('Every {DAV:}sharee must have a {DAV:}href child-element');
+ }
+ $sharee->href = $xsharee['href'];
+
+ if (isset($xsharee['prop'])) {
+ $sharee->properties = $xsharee['prop'];
+ }
+ if (isset($xsharee['comment'])) {
+ $sharee->comment = $xsharee['comment'];
}
+ if (!isset($xsharee['share-access'])) {
+ throw new BadRequest('Every {DAV:}sharee must have a {DAV:}share-access child element');
+ }
+ $sharee->access = $xsharee['share-access']->getValue();
+
+ $sharees[] = $sharee;
+
}
- return new self($set, $remove);
+ return new self($sharees);
}
diff --git a/tests/Sabre/DAV/Mock/ShareableNode.php b/tests/Sabre/DAV/Mock/ShareableNode.php
deleted file mode 100644
index af77cc0..0000000
--- a/tests/Sabre/DAV/Mock/ShareableNode.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Mock;
-
-use Sabre\DAV\Sharing\IShareableNode;
-
-class ShareableNode extends \Sabre\DAV\Node implements IShareableNode {
-
- protected $name;
-
- function __construct($name) {
-
- $this->name = $name;
-
- }
-
- function getName() {
-
- return $this->name;
-
- }
-
- /**
- * Updates the list of shares.
- *
- * The first array is a list of people that are to be added to the
- * shared resource.
- *
- * Every element in the add array has the following properties:
- * * href - A url. Usually a mailto: address
- * * summary - A description of the share, can also be false
- * * readOnly - A boolean value
- *
- * In addition to that, the array might have any additional properties,
- * specified in clark-notation, such as '{DAV:}displayname'.
- *
- * Every element in the remove array is just the url of the sharee that's
- * to be removed.
- *
- * @param array $add
- * @param array $remove
- * @return void
- */
- function updateShares(array $add, array $remove) {
-
- }
-
- /**
- * Returns the list of people whom this resource is shared with.
- *
- * Every element in this array should have the following properties:
- * * href - Often a mailto: address
- * * commonName - Optional, for example a first + last name
- * * status - See the Sabre\DAV\Sharing\Plugin::STATUS_ constants.
- * * readOnly - boolean
- *
- * @return array
- */
- function getShares();
-
-
-}
diff --git a/tests/Sabre/DAV/Mock/SharedNode.php b/tests/Sabre/DAV/Mock/SharedNode.php
new file mode 100644
index 0000000..59258fb
--- /dev/null
+++ b/tests/Sabre/DAV/Mock/SharedNode.php
@@ -0,0 +1,92 @@
+<?php
+
+namespace Sabre\DAV\Mock;
+
+use Sabre\DAV\Sharing\ISharedNode;
+use Sabre\DAV\Sharing\Sharee;
+
+class SharedNode extends \Sabre\DAV\Node implements ISharedNode {
+
+ protected $name;
+ protected $access;
+
+ function __construct($name, $access) {
+
+ $this->name = $name;
+ $this->access = $access;
+
+ }
+
+ function getName() {
+
+ return $this->name;
+
+ }
+
+ /**
+ * Returns the 'access level' for the instance of this shared resource.
+ *
+ * The value should be one of the Sabre\DAV\Sharing\Plugin::ACCESS_
+ * constants.
+ *
+ * @return int
+ */
+ function getShareAccess() {
+
+ return $this->access;
+
+ }
+
+ /**
+ * This function must return a URI that uniquely identifies the shared
+ * resource. This URI should be identical across instances, and is
+ * also used in several other XML bodies to connect invites to
+ * resources.
+ *
+ * This may simply be a relative reference to the original shared instance,
+ * but it could also be a urn. As long as it's a valid URI and unique.
+ *
+ * @return string
+ */
+ function getShareResourceUri() {
+
+ throw new \Exception('Not implemented');
+
+ }
+
+ /**
+ * Updates the list of sharees.
+ *
+ * Every item must be a Sharee object.
+ *
+ * @param Sharee[] $sharees
+ * @return void
+ */
+ function updateInvites(array $sharees) {
+
+ throw new \Exception('Not implemented');
+
+ }
+
+ /**
+ * Returns the list of people whom this resource is shared with.
+ *
+ * Every item in the returned array must be a Sharee object with
+ * at least the following properties set:
+ *
+ * * $href
+ * * $shareAccess
+ * * $inviteStatus
+ *
+ * and optionally:
+ *
+ * * $properties
+ *
+ * @return array
+ */
+ function getInvites() {
+
+ throw new \Exception('Not implemented');
+
+ }
+}
diff --git a/tests/Sabre/DAV/Sharing/PluginTest.php b/tests/Sabre/DAV/Sharing/PluginTest.php
index aa3c37a..9746461 100644
--- a/tests/Sabre/DAV/Sharing/PluginTest.php
+++ b/tests/Sabre/DAV/Sharing/PluginTest.php
@@ -3,6 +3,7 @@
namespace Sabre\DAV\Sharing;
use Sabre\DAV\Mock;
+use Sabre\DAV\Xml\Property;
class PluginTest extends \Sabre\DAVServerTest {
@@ -10,7 +11,10 @@ class PluginTest extends \Sabre\DAVServerTest {
function setUpTree() {
- $this->tree[] = new Mock\ShareableNode();
+ $this->tree[] = new Mock\SharedNode(
+ 'shareable',
+ Plugin::ACCESS_READWRITE
+ );
}
@@ -18,10 +22,18 @@ class PluginTest extends \Sabre\DAVServerTest {
$result = $this->server->getPropertiesForPath(
'shareable',
- ['{DAV:}share-mode']
+ ['{DAV:}share-access']
);
- $expected = [];
+ $expected = [
+ [
+ 200 => [
+ '{DAV:}share-access' => new Property\ShareAccess(Plugin::ACCESS_READWRITE)
+ ],
+ 404 => [],
+ 'href' => 'shareable',
+ ]
+ ];
$this->assertEquals(
$expected,
diff --git a/tests/Sabre/DAV/Xml/Property/ShareAccessTest.php b/tests/Sabre/DAV/Xml/Property/ShareAccessTest.php
new file mode 100644
index 0000000..526329a
--- /dev/null
+++ b/tests/Sabre/DAV/Xml/Property/ShareAccessTest.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Sabre\DAV\Xml\Property;
+
+use Sabre\DAV\Xml\XmlTest;
+use Sabre\DAV\Sharing\Plugin;
+
+class ShareAccessTest extends XmlTest {
+
+ function testSerialize() {
+
+ $data = ['{DAV:}root' => [
+ [
+ 'name' => '{DAV:}share-access',
+ 'value' => new ShareAccess(Plugin::ACCESS_READ),
+ ],
+ [
+ 'name' => '{DAV:}share-access',
+ 'value' => new ShareAccess(Plugin::ACCESS_READWRITE),
+ ],
+ [
+ 'name' => '{DAV:}share-access',
+ 'value' => new ShareAccess(Plugin::ACCESS_NOTSHARED),
+ ],
+ [
+ 'name' => '{DAV:}share-access',
+ 'value' => new ShareAccess(Plugin::ACCESS_NOACCESS),
+ ],
+ [
+ 'name' => '{DAV:}share-access',
+ 'value' => new ShareAccess(Plugin::ACCESS_SHAREDOWNER),
+ ],
+
+ ]];
+
+ $xml = $this->write($data);
+
+ $expected = <<<XML
+<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:share-access><d:read /></d:share-access>
+ <d:share-access><d:read-write /></d:share-access>
+ <d:share-access><d:not-shared /></d:share-access>
+ <d:share-access><d:no-access /></d:share-access>
+ <d:share-access><d:shared-owner /></d:share-access>
+</d:root>
+XML;
+
+ $this->assertXmlStringEqualsXmlString($expected, $xml);
+
+ }
+
+}
diff --git a/tests/Sabre/DAV/Xml/Property/ShareModeTest.php b/tests/Sabre/DAV/Xml/Property/ShareModeTest.php
deleted file mode 100644
index 83d0cc9..0000000
--- a/tests/Sabre/DAV/Xml/Property/ShareModeTest.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Xml\Property;
-
-use Sabre\DAV\Xml\XmlTest;
-
-class ShareModeTest extends XmlTest {
-
- function testSerialize() {
-
- $data = ['{DAV:}root' => [
- [
- 'name' => '{DAV:}share-mode',
- 'value' => new ShareMode(ShareMode::SHARED),
- ],
- [
- 'name' => '{DAV:}share-mode',
- 'value' => new ShareMode(ShareMode::SHAREDOWNER),
- ],
- ]];
-
- $xml = $this->write($data);
-
- $expected = <<<XML
-<?xml version="1.0"?>
-<d:root xmlns:d="DAV:">
- <d:share-mode><d:shared /></d:share-mode>
- <d:share-mode><d:shared-owner /></d:share-mode>
-</d:root>
-XML;
-
- $this->assertXmlStringEqualsXmlString($expected, $xml);
-
- }
-
-}
diff --git a/tests/Sabre/DAV/Xml/Request/ShareResourceTest.php b/tests/Sabre/DAV/Xml/Request/ShareResourceTest.php
index 9e6e9d3..7f97c3f 100644
--- a/tests/Sabre/DAV/Xml/Request/ShareResourceTest.php
+++ b/tests/Sabre/DAV/Xml/Request/ShareResourceTest.php
@@ -3,6 +3,8 @@
namespace Sabre\DAV\Xml\Request;
use Sabre\DAV\Xml\XmlTest;
+use Sabre\DAV\Sharing\Sharee;
+use Sabre\DAV\Sharing\Plugin;
class ShareResourceTest extends XmlTest {
@@ -11,21 +13,28 @@ class ShareResourceTest extends XmlTest {
$xml = <<<XML
<?xml version="1.0" encoding="utf-8" ?>
<D:share-resource xmlns:D="DAV:">
- <D:set-invitee>
- <D:href>mailto:eric at example.com</D:href>
- <D:displayname>Eric York</D:displayname>
- <D:comment>Shared workspace</D:comment>
- <D:read-write />
- </D:set-invitee>
- <D:set-invitee>
- <D:href>mailto:evert at example.com</D:href>
- <D:displayname>Evert Pot</D:displayname>
- <D:comment>Shared workspace</D:comment>
- <D:read />
- </D:set-invitee>
- <D:remove-invitee>
- <D:href>mailto:wilfredo at example.com</D:href>
- </D:remove-invitee>
+ <D:sharee>
+ <D:href>mailto:eric at example.com</D:href>
+ <D:prop>
+ <D:displayname>Eric York</D:displayname>
+ </D:prop>
+ <D:comment>Shared workspace</D:comment>
+ <D:share-access>
+ <D:read-write />
+ </D:share-access>
+ </D:sharee>
+ <D:sharee>
+ <D:href>mailto:eric at example.com</D:href>
+ <D:share-access>
+ <D:read />
+ </D:share-access>
+ </D:sharee>
+ <D:sharee>
+ <D:href>mailto:wilfredo at example.com</D:href>
+ <D:share-access>
+ <D:no-access />
+ </D:share-access>
+ </D:sharee>
</D:share-resource>
XML;
@@ -38,29 +47,26 @@ XML;
$result['value']
);
- $this->assertEquals(
- [
- [
- 'href' => 'mailto:eric at example.com',
- '{DAV:}displayname' => 'Eric York',
- 'comment' => 'Shared workspace',
- 'readOnly' => false,
- ],
- [
- 'href' => 'mailto:evert at example.com',
- '{DAV:}displayname' => 'Evert Pot',
- 'comment' => 'Shared workspace',
- 'readOnly' => true,
- ],
- ],
- $result['value']->set
- );
+ $expected = [
+ new Sharee(),
+ new Sharee(),
+ new Sharee(),
+ ];
+
+ $expected[0]->href = 'mailto:eric at example.com';
+ $expected[0]->properties['{DAV:}displayname'] = 'Eric York';
+ $expected[0]->comment = 'Shared workspace';
+ $expected[0]->access = Plugin::ACCESS_READWRITE;
+
+ $expected[1]->href = 'mailto:eric at example.com';
+ $expected[1]->access = Plugin::ACCESS_READ;
+
+ $expected[2]->href = 'mailto:wilfredo at example.com';
+ $expected[2]->access = Plugin::ACCESS_NOACCESS;
$this->assertEquals(
- [
- 'mailto:wilfredo at example.com',
- ],
- $result['value']->remove
+ $expected,
+ $result['value']->sharees
);
}
--
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