[Pkg-owncloud-commits] [php-sabredav] 70/148: Finally got rid of all Sabre\DAV\XMLUtil references.
David Prévot
taffit at moszumanska.debian.org
Wed Apr 15 01:37:17 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit aa751efa1e000e16cecdde7453a00388a838d855
Author: Evert Pot <me at evertpot.com>
Date: Thu Mar 19 00:04:14 2015 -0400
Finally got rid of all Sabre\DAV\XMLUtil references.
---
composer.json | 2 +-
lib/CalDAV/Notifications/Plugin.php | 3 +-
lib/CalDAV/Plugin.php | 31 +++--
lib/CalDAV/Schedule/Plugin.php | 2 +-
lib/CalDAV/SharingPlugin.php | 8 +-
lib/CalDAV/Xml/Request/CalendarMultiGetReport.php | 2 +-
.../Xml/Request/AddressBookMultiGetReport.php | 2 +-
lib/DAV/Browser/Plugin.php | 6 +-
lib/DAV/Client.php | 12 +-
lib/DAV/CorePlugin.php | 36 +++---
lib/DAV/Locks/Plugin.php | 16 ++-
lib/DAV/Server.php | 9 +-
lib/DAV/Sync/Plugin.php | 2 +-
lib/DAV/TemporaryFileFilterPlugin.php | 12 +-
lib/DAV/XMLUtil.php | 130 ---------------------
lib/DAV/Xml/Element/Response.php | 2 +-
lib/DAV/Xml/Property/Href.php | 2 +-
lib/DAV/Xml/Property/LockDiscovery.php | 2 +-
lib/DAV/Xml/Service.php | 51 ++++++++
lib/DAVACL/Plugin.php | 16 +--
tests/Sabre/CalDAV/FreeBusyReportTest.php | 16 +--
tests/Sabre/CalDAV/JCalTransformTest.php | 6 +-
tests/Sabre/CalDAV/Notifications/PluginTest.php | 2 +-
tests/Sabre/DAV/ServerMKCOLTest.php | 2 +-
tests/Sabre/DAV/ServerPropsTest.php | 3 +-
tests/Sabre/DAV/Sync/PluginTest.php | 8 +-
tests/Sabre/DAV/TemporaryFileFilterTest.php | 83 +++----------
tests/Sabre/DAV/XMLUtilTest.php | 30 -----
tests/Sabre/DAV/Xml/Property/HrefTest.php | 2 +-
tests/Sabre/DAV/Xml/XmlTest.php | 4 +-
tests/Sabre/DAVACL/PluginPropertiesTest.php | 2 +-
tests/Sabre/DAVACL/Xml/Property/ACLTest.php | 6 +-
.../DAVACL/Xml/Property/AclRestrictionsTest.php | 2 +-
.../Xml/Property/CurrentUserPrivilegeSetTest.php | 2 +-
tests/Sabre/DAVACL/Xml/Property/PrincipalTest.php | 6 +-
.../Xml/Property/SupportedPrivilegeSetTest.php | 4 +-
36 files changed, 180 insertions(+), 344 deletions(-)
diff --git a/composer.json b/composer.json
index 433d28e..9f0f290 100644
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,7 @@
"php": ">=5.4.1",
"sabre/vobject": ">=3.3.4 <4",
"sabre/event" : "~2.0.0",
- "sabre/xml" : "~0.3.1",
+ "sabre/xml" : "~0.4.0",
"sabre/http" : "~4.0.0-alpha1",
"sabre/uri" : "~1.0",
"ext-dom": "*",
diff --git a/lib/CalDAV/Notifications/Plugin.php b/lib/CalDAV/Notifications/Plugin.php
index 34bd847..de46038 100644
--- a/lib/CalDAV/Notifications/Plugin.php
+++ b/lib/CalDAV/Notifications/Plugin.php
@@ -68,7 +68,7 @@ class Plugin extends ServerPlugin {
$server->on('method:GET', [$this,'httpGet'], 90);
$server->on('propFind', [$this,'propFind']);
- $server->xmlNamespaces[self::NS_CALENDARSERVER] = 'cs';
+ $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs';
$server->resourceTypeMapping['\\Sabre\\CalDAV\\Notifications\\ICollection'] = '{' . self::NS_CALENDARSERVER . '}notification';
array_push($server->protectedProperties,
@@ -138,6 +138,7 @@ class Plugin extends ServerPlugin {
return;
$writer = $this->server->xml->getWriter();
+ $writer->openMemory();
$writer->startDocument('1.0', 'UTF-8');
$writer->startElement('{http://calendarserver.org/ns/}notification');
$node->getNotificationType()->xmlSerializeFull($writer);
diff --git a/lib/CalDAV/Plugin.php b/lib/CalDAV/Plugin.php
index bf721f3..852f507 100644
--- a/lib/CalDAV/Plugin.php
+++ b/lib/CalDAV/Plugin.php
@@ -2,15 +2,17 @@
namespace Sabre\CalDAV;
-use DateTimeZone;
-use Sabre\DAV;
-use Sabre\DAV\Xml\Property\Href;
-use Sabre\DAVACL;
-use Sabre\VObject;
-use Sabre\HTTP;
-use Sabre\Uri;
-use Sabre\HTTP\RequestInterface;
-use Sabre\HTTP\ResponseInterface;
+use
+ DateTimeZone,
+ Sabre\DAV,
+ Sabre\DAV\Exception\BadRequest,
+ Sabre\DAV\Xml\Property\Href,
+ Sabre\DAVACL,
+ Sabre\VObject,
+ Sabre\HTTP,
+ Sabre\Uri,
+ Sabre\HTTP\RequestInterface,
+ Sabre\HTTP\ResponseInterface;
/**
* CalDAV plugin
@@ -258,8 +260,15 @@ class Plugin extends DAV\ServerPlugin {
if ($body) {
- $mkcalendar = $this->server->xml->parse($body);
- $properties = $mkcalendar['value']->getProperties();
+ try {
+ $mkcalendar = $this->server->xml->expect(
+ '{urn:ietf:params:xml:ns:caldav}mkcalendar',
+ $body
+ );
+ } catch (\Sabre\Xml\ParseException $e) {
+ throw new BadRequest($e->getMessage(), null, $e);
+ }
+ $properties = $mkcalendar->getProperties();
}
diff --git a/lib/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index 3e229b6..b8d77be 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -698,7 +698,7 @@ class Plugin extends ServerPlugin {
$dom = new \DOMDocument('1.0','utf-8');
$dom->formatOutput = true;
$scheduleResponse = $dom->createElement('cal:schedule-response');
- foreach($this->server->xmlNamespaces as $namespace=>$prefix) {
+ foreach($this->server->xml->namespaceMap as $namespace=>$prefix) {
$scheduleResponse->setAttribute('xmlns:' . $prefix,$namespace);
diff --git a/lib/CalDAV/SharingPlugin.php b/lib/CalDAV/SharingPlugin.php
index c8a072b..67123e6 100644
--- a/lib/CalDAV/SharingPlugin.php
+++ b/lib/CalDAV/SharingPlugin.php
@@ -263,12 +263,7 @@ class SharingPlugin extends DAV\ServerPlugin {
// re-populated the request body with the existing data.
$request->setBody($requestBody);
- $result = $this->server->xml->parse($requestBody);
-
- $documentType = $result['name'];
- $message = $result['value'];
-
- unset($result);
+ $message = $this->server->xml->parse($requestBody, $request->getUrl(), $documentType);
switch($documentType) {
@@ -334,6 +329,7 @@ class SharingPlugin extends DAV\ServerPlugin {
if ($url) {
$writer = $this->server->xml->getWriter($this->server->getBaseUri());
+ $writer->openMemory();
$writer->startDocument();
$writer->startElement('{' . Plugin::NS_CALENDARSERVER . '}shared-as');
$writer->write(new Href($url));
diff --git a/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php b/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php
index afcb905..0b40fe4 100644
--- a/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php
+++ b/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php
@@ -105,7 +105,7 @@ class CalendarMultiGetReport implements XmlDeserializable {
}
break;
case '{DAV:}href' :
- $newProps['hrefs'][] = Uri\resolve($reader->baseUri, $elem['value']);
+ $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']);
break;
}
diff --git a/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php b/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
index 17ae6f0..a16cccc 100644
--- a/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
+++ b/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
@@ -95,7 +95,7 @@ class AddressBookMultiGetReport implements XmlDeserializable {
}
break;
case '{DAV:}href' :
- $newProps['hrefs'][] = Uri\resolve($reader->baseUri, $elem['value']);
+ $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']);
break;
}
diff --git a/lib/DAV/Browser/Plugin.php b/lib/DAV/Browser/Plugin.php
index 29b2cfb..aa27181 100644
--- a/lib/DAV/Browser/Plugin.php
+++ b/lib/DAV/Browser/Plugin.php
@@ -656,7 +656,7 @@ HTML;
}
}
- list($ns, $localName) = DAV\XMLUtil::parseClarkNotation($name);
+ list($ns, $localName) = \Sabre\Xml\Service::parseClarkNotation($name);
$realName = $name;
if (isset($this->server->xmlNamespaces[$ns])) {
@@ -667,7 +667,7 @@ HTML;
$xmlValueDisplay = function($propName) {
$realPropName = $propName;
- list($ns, $localName) = DAV\XMLUtil::parseClarkNotation($propName);
+ list($ns, $localName) = \Sabre\Xml\Service::parseClarkNotation($propName);
if (isset($this->server->xmlNamespaces[$ns])) {
$propName = $this->server->xmlNamespaces[$ns] . ':' . $localName;
}
@@ -720,7 +720,7 @@ HTML;
echo $this->escapeHTML($value);
break;
case 'xml' :
- $xml = $this->server->xml->write(['{DAV:}root' => $value], $this->server->getBaseUri());
+ $xml = $this->server->xml->write('{DAV:}root', $value, $this->server->getBaseUri());
// removing first and last line, as they contain our root
// element.
$xml = substr($xml, strpos($xml,"\n")+1);
diff --git a/lib/DAV/Client.php b/lib/DAV/Client.php
index 478f0b8..ac31bdc 100644
--- a/lib/DAV/Client.php
+++ b/lib/DAV/Client.php
@@ -181,7 +181,7 @@ class Client extends HTTP\Client {
list(
$namespace,
$elementName
- ) = XMLUtil::parseClarkNotation($property);
+ ) = \Sabre\Xml\Service::parseClarkNotation($property);
if ($namespace === 'DAV:') {
$element = $dom->createElement('d:'.$elementName);
@@ -250,7 +250,7 @@ class Client extends HTTP\Client {
list(
$namespace,
$elementName
- ) = XMLUtil::parseClarkNotation($propName);
+ ) = \Sabre\Xml\Service::parseClarkNotation($propName);
if ($propValue === null) {
@@ -420,15 +420,11 @@ class Client extends HTTP\Client {
*/
function parseMultiStatus($body) {
- $xmlUtil = new XMLUtil();
- $multistatus = $xmlUtil->parse($body)['value'];
+ $xmlUtil = new Xml\Service();
+ $multistatus = $xmlUtil->expect('{DAV:}multistatus', $body);
$result = [];
- if (!$multistatus instanceof Xml\Response\MultiStatus) {
- throw new \InvalidArgumentException('Xml could not be parsed into a {DAV:}multistatus document');
- }
-
foreach($multistatus->getResponses() as $response) {
$result[$response->getHref()] = $response->getResponseProperties();
diff --git a/lib/DAV/CorePlugin.php b/lib/DAV/CorePlugin.php
index 5ca8530..d81c9af 100644
--- a/lib/DAV/CorePlugin.php
+++ b/lib/DAV/CorePlugin.php
@@ -3,8 +3,10 @@
namespace Sabre\DAV;
use
+ Sabre\DAV\Exception\BadRequest,
Sabre\HTTP\RequestInterface,
- Sabre\HTTP\ResponseInterface;
+ Sabre\HTTP\ResponseInterface,
+ Sabre\Xml\ParseException;
/**
* The core plugin provides all the basic features for a WebDAV server.
@@ -318,11 +320,7 @@ class CorePlugin extends ServerPlugin {
$requestBody = $request->getBodyAsString();
if (strlen($requestBody)) {
- $propFindXml = $this->server->xml->parse($requestBody);
- if ($propFindXml['name'] !== '{DAV:}propfind') {
- throw new Exception\UnsupportedMediaType('The root element of this request must be {DAV:}propfind');
- }
- $propFindXml = $propFindXml['value'];
+ $propFindXml = $this->server->xml->expect('{DAV:}propfind', $requestBody);
} else {
$propFindXml = new Xml\Request\PropFind();
$propFindXml->allProp = true;
@@ -375,9 +373,11 @@ class CorePlugin extends ServerPlugin {
$path = $request->getPath();
- $propPatch = $this->server->xml->parse(
- $request->getBodyAsString()
- )['value'];
+ try {
+ $propPatch = $this->server->xml->expect('{DAV:}propertyupdate', $request->getBody());
+ } catch (ParseException $e) {
+ throw new BadRequest($e->getMessage(), null, $e);
+ }
$newProperties = $propPatch->properties;
$result = $this->server->updateProperties($path, $newProperties);
@@ -563,18 +563,12 @@ class CorePlugin extends ServerPlugin {
}
try {
- $mkcol = $this->server->xml->parse($requestBody);
+ $mkcol = $this->server->xml->expect('{DAV:}mkcol', $requestBody);
} catch (\Sabre\Xml\ParseException $e) {
throw new Exception\BadRequest($e->getMessage(), null, $e);
}
- if ($mkcol['name']!=='{DAV:}mkcol') {
-
- // We must throw 415 for unsupported mkcol bodies
- throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must be a {DAV:}mkcol request construct.');
-
- }
- $properties = $mkcol['value']->getProperties();
+ $properties = $mkcol->getProperties();
if (!isset($properties['{DAV:}resourcetype']))
throw new Exception\BadRequest('The mkcol request must include a {DAV:}resourcetype property');
@@ -706,9 +700,13 @@ class CorePlugin extends ServerPlugin {
$path = $request->getPath();
- $result = $this->server->xml->parse($request->getBody());
+ $result = $this->server->xml->parse(
+ $request->getBody(),
+ $request->getUrl(),
+ $rootElementName
+ );
- if ($this->server->emit('report', [$result['name'], $result['value'], $path])) {
+ if ($this->server->emit('report', [$rootElementName, $result, $path])) {
// If emit returned true, it means the report was not supported
throw new Exception\ReportNotSupported();
diff --git a/lib/DAV/Locks/Plugin.php b/lib/DAV/Locks/Plugin.php
index 5ab1283..e538cc3 100644
--- a/lib/DAV/Locks/Plugin.php
+++ b/lib/DAV/Locks/Plugin.php
@@ -404,13 +404,10 @@ class Plugin extends DAV\ServerPlugin {
*/
protected function generateLockResponse(LockInfo $lockInfo) {
- return $this->server->xml->write([
- '{DAV:}prop' => [
- '{DAV:}lockdiscovery' =>
- new DAV\Xml\Property\LockDiscovery([$lockInfo])
- ]
+ return $this->server->xml->write('{DAV:}prop',[
+ '{DAV:}lockdiscovery' =>
+ new DAV\Xml\Property\LockDiscovery([$lockInfo])
]);
-
}
/**
@@ -563,16 +560,17 @@ class Plugin extends DAV\ServerPlugin {
*/
protected function parseLockRequest($body) {
- $result = $this->server->xml->parse(
+ $result = $this->server->xml->expect(
+ '{DAV:}lockinfo',
$body
);
$lockInfo = new LockInfo();
- $lockInfo->owner = $result['value']->owner;
+ $lockInfo->owner = $result->owner;
$lockInfo->token = DAV\UUIDUtil::getUUID();
- $lockInfo->scope = $result['value']->scope;
+ $lockInfo->scope = $result->scope;
return $lockInfo;
diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php
index 237f03c..a9c5fa1 100644
--- a/lib/DAV/Server.php
+++ b/lib/DAV/Server.php
@@ -164,7 +164,7 @@ class Server extends EventEmitter {
/**
* Reference to the XML utility object.
*
- * @var XMLUtil
+ * @var Xml\Service
*/
public $xml;
@@ -219,8 +219,7 @@ class Server extends EventEmitter {
throw new Exception('Invalid argument passed to constructor. Argument must either be an instance of Sabre\\DAV\\Tree, Sabre\\DAV\\INode, an array or null');
}
- $this->xml = new XMLUtil();
- $this->xmlNamespaces =& $this->xml->namespaceMap;
+ $this->xml = new Xml\Service();
$this->sapi = new HTTP\Sapi();
$this->httpResponse = new HTTP\Response();
$this->httpRequest = $this->sapi->getRequest();
@@ -1643,7 +1642,7 @@ class Server extends EventEmitter {
unset($entry[404]);
}
$response = new Xml\Element\Response(
- '/' . ltrim($href,'/'),
+ ltrim($href,'/'),
$entry
);
$xml[] = [
@@ -1652,7 +1651,7 @@ class Server extends EventEmitter {
];
}
- return $this->xml->write(['{DAV:}multistatus' => $xml]);
+ return $this->xml->write('{DAV:}multistatus', $xml, $this->baseUri);
}
diff --git a/lib/DAV/Sync/Plugin.php b/lib/DAV/Sync/Plugin.php
index 9ae20c4..6f4d97f 100644
--- a/lib/DAV/Sync/Plugin.php
+++ b/lib/DAV/Sync/Plugin.php
@@ -195,7 +195,7 @@ class Plugin extends DAV\ServerPlugin {
$this->server->httpResponse->setStatus(207);
$this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8');
$this->server->httpResponse->setBody(
- $this->server->xml->write(['{DAV:}multistatus' => $multiStatus], $this->server->getBaseUri())
+ $this->server->xml->write('{DAV:}multistatus', $multiStatus, $this->server->getBaseUri())
);
}
diff --git a/lib/DAV/TemporaryFileFilterPlugin.php b/lib/DAV/TemporaryFileFilterPlugin.php
index 19fb6b4..6166156 100644
--- a/lib/DAV/TemporaryFileFilterPlugin.php
+++ b/lib/DAV/TemporaryFileFilterPlugin.php
@@ -110,7 +110,7 @@ class TemporaryFileFilterPlugin extends ServerPlugin {
function beforeMethod(RequestInterface $request, ResponseInterface $response) {
if (!$tempLocation = $this->isTempFile($request->getPath()))
- return true;
+ return;
switch($request->getMethod()) {
case 'GET' :
@@ -122,7 +122,7 @@ class TemporaryFileFilterPlugin extends ServerPlugin {
case 'DELETE' :
return $this->httpDelete($request, $response, $tempLocation);
}
- return true;
+ return;
}
@@ -145,7 +145,7 @@ class TemporaryFileFilterPlugin extends ServerPlugin {
file_put_contents($tempPath,$data);
return false;
}
- return true;
+ return;
}
@@ -187,7 +187,7 @@ class TemporaryFileFilterPlugin extends ServerPlugin {
*/
function httpGet(RequestInterface $request, ResponseInterface $hR, $tempLocation) {
- if (!file_exists($tempLocation)) return true;
+ if (!file_exists($tempLocation)) return;
$hR->setHeader('Content-Type','application/octet-stream');
$hR->setHeader('Content-Length',filesize($tempLocation));
@@ -235,7 +235,7 @@ class TemporaryFileFilterPlugin extends ServerPlugin {
*/
function httpDelete(RequestInterface $request, ResponseInterface $hR, $tempLocation) {
- if (!file_exists($tempLocation)) return true;
+ if (!file_exists($tempLocation)) return;
unlink($tempLocation);
$hR->setHeader('X-Sabre-Temp','true');
@@ -258,7 +258,7 @@ class TemporaryFileFilterPlugin extends ServerPlugin {
*/
function httpPropfind(RequestInterface $request, ResponseInterface $hR, $tempLocation) {
- if (!file_exists($tempLocation)) return true;
+ if (!file_exists($tempLocation)) return;
$hR->setHeader('X-Sabre-Temp','true');
$hR->setStatus(207);
diff --git a/lib/DAV/XMLUtil.php b/lib/DAV/XMLUtil.php
deleted file mode 100644
index 5075bfe..0000000
--- a/lib/DAV/XMLUtil.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-
-namespace Sabre\DAV;
-use Sabre\Xml;
-
-/**
- * XML utilities for WebDAV
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class XMLUtil {
-
- /**
- * This is a list of XML elements that we automatically map to PHP classes.
- *
- * For instance, this list may contain an entry `{DAV:}propfind` that would
- * be mapped to Sabre\DAV\Xml\Request\PropFind
- */
- public $elementMap = [
- '{DAV:}multistatus' => 'Sabre\\DAV\\Xml\\Response\\MultiStatus',
- '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response',
- '{DAV:}propstat' => 'Sabre\\Xml\\Element\\KeyValue',
- '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
- '{DAV:}set' => 'Sabre\\Xml\\Element\\KeyValue',
- '{DAV:}remove' => 'Sabre\\Xml\\Element\\KeyValue',
-
- // Requests
- '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind',
- '{DAV:}propertyupdate' => 'Sabre\\DAV\\Xml\\Request\\PropPatch',
- '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol',
-
- // Properties
- '{DAV:}resourcetype' => 'Sabre\\DAV\\Xml\\Property\\ResourceType',
-
- ];
-
- /**
- * This is a default list of namespaces.
- *
- * If you are defining your own custom namespace, add it here to reduce
- * bandwidth and improve legibility of xml bodies.
- *
- * @var array
- */
- public $namespaceMap = [
- 'DAV:' => 'd',
- 'http://sabredav.org/ns' => 's',
- ];
-
- /**
- * Parses an XML file.
- * This method parses an xml file and maps all known properties to their
- * respective objects.
- *
- * @param string|resource|\Sabre\HTTP\MessageInterface $input
- * @return mixed
- */
- function parse($input) {
-
- $reader = new XML\Reader();
- $reader->elementMap = $this->elementMap;
- if ($input instanceof \Sabre\HTTP\MessageInterface) {
- $reader->xml($input->getBodyAsString());
- } else {
- $reader->xml($input);
- }
- return $reader->parse();
-
- }
-
- /**
- * Generates an XML document and returns the output as a string.
- *
- * @param mixed $output
- * @param string $baseUri // Specify the base URI of the document.
- * @return string
- */
- function write($output, $baseUri = null) {
-
- $writer = $this->getWriter($baseUri);
- $writer->startDocument();
- $writer->write($output);
- return $writer->outputMemory();
-
- }
-
- /**
- * Returns a fully configured xml writer, ready to start writing into
- * memory.
- *
- * @parama string $baseUri
- * @return XML\Writer
- */
- function getWriter($baseUri = null) {
-
- $writer = new XML\Writer();
- $writer->baseUri = $baseUri;
- $writer->namespaceMap = $this->namespaceMap;
- $writer->openMemory();
- $writer->setIndent(true);
- return $writer;
-
- }
-
- /**
- * Parses a clark-notation string, and returns the namespace and element
- * name components.
- *
- * If the string was invalid, it will throw an InvalidArgumentException.
- *
- * @param string $str
- * @throws InvalidArgumentException
- * @return array
- */
- static function parseClarkNotation($str) {
-
- if (!preg_match('/^{([^}]*)}(.*)$/',$str,$matches)) {
- throw new \InvalidArgumentException('\'' . $str . '\' is not a valid clark-notation formatted string');
- }
-
- return [
- $matches[1],
- $matches[2]
- ];
-
- }
-
-}
diff --git a/lib/DAV/Xml/Element/Response.php b/lib/DAV/Xml/Element/Response.php
index 5a64afe..3c18309 100644
--- a/lib/DAV/Xml/Element/Response.php
+++ b/lib/DAV/Xml/Element/Response.php
@@ -122,7 +122,7 @@ class Response implements Element {
if ($status = $this->getHTTPStatus()) {
$writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]);
}
- $writer->writeElement('{DAV:}href', $writer->baseUri . $this->getHref());
+ $writer->writeElement('{DAV:}href', $writer->contextUri . $this->getHref());
foreach($this->getResponseProperties() as $status => $properties) {
// Skipping empty lists
diff --git a/lib/DAV/Xml/Property/Href.php b/lib/DAV/Xml/Property/Href.php
index 2ff665b..5d71b58 100644
--- a/lib/DAV/Xml/Property/Href.php
+++ b/lib/DAV/Xml/Property/Href.php
@@ -104,7 +104,7 @@ class Href implements Element {
foreach($this->getHrefs() as $href) {
if ($this->autoPrefix) {
- $href = $writer->baseUri . $href;
+ $href = $writer->contextUri . $href;
}
$writer->writeElement('{DAV:}href', $href);
}
diff --git a/lib/DAV/Xml/Property/LockDiscovery.php b/lib/DAV/Xml/Property/LockDiscovery.php
index 139a723..77c7389 100644
--- a/lib/DAV/Xml/Property/LockDiscovery.php
+++ b/lib/DAV/Xml/Property/LockDiscovery.php
@@ -85,7 +85,7 @@ class LockDiscovery implements XmlSerializable {
if (!self::$hideLockRoot) {
$writer->startElement('{DAV:}lockroot');
- $writer->writeElement('{DAV:}href', $writer->baseUri . $lock->uri);
+ $writer->writeElement('{DAV:}href', $writer->contextUri . $lock->uri);
$writer->endElement(); // {DAV:}lockroot
}
$writer->writeElement('{DAV:}depth', ($lock->depth == DAV\Server::DEPTH_INFINITY?'infinity':$lock->depth));
diff --git a/lib/DAV/Xml/Service.php b/lib/DAV/Xml/Service.php
new file mode 100644
index 0000000..a24c713
--- /dev/null
+++ b/lib/DAV/Xml/Service.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Sabre\DAV\Xml;
+
+/**
+ * XML service for WebDAV
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Service extends \Sabre\Xml\Service {
+
+ /**
+ * This is a list of XML elements that we automatically map to PHP classes.
+ *
+ * For instance, this list may contain an entry `{DAV:}propfind` that would
+ * be mapped to Sabre\DAV\Xml\Request\PropFind
+ */
+ public $elementMap = [
+ '{DAV:}multistatus' => 'Sabre\\DAV\\Xml\\Response\\MultiStatus',
+ '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response',
+ '{DAV:}propstat' => 'Sabre\\Xml\\Element\\KeyValue',
+ '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
+ '{DAV:}set' => 'Sabre\\Xml\\Element\\KeyValue',
+ '{DAV:}remove' => 'Sabre\\Xml\\Element\\KeyValue',
+
+ // Requests
+ '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind',
+ '{DAV:}propertyupdate' => 'Sabre\\DAV\\Xml\\Request\\PropPatch',
+ '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol',
+
+ // Properties
+ '{DAV:}resourcetype' => 'Sabre\\DAV\\Xml\\Property\\ResourceType',
+
+ ];
+
+ /**
+ * This is a default list of namespaces.
+ *
+ * If you are defining your own custom namespace, add it here to reduce
+ * bandwidth and improve legibility of xml bodies.
+ *
+ * @var array
+ */
+ public $namespaceMap = [
+ 'DAV:' => 'd',
+ 'http://sabredav.org/ns' => 's',
+ ];
+
+}
diff --git a/lib/DAVACL/Plugin.php b/lib/DAVACL/Plugin.php
index e761675..aa358aa 100644
--- a/lib/DAVACL/Plugin.php
+++ b/lib/DAVACL/Plugin.php
@@ -1023,8 +1023,8 @@ class Plugin extends DAV\ServerPlugin {
throw new DAV\Exception\BadRequest('XML body expected in ACL request');
}
- $acl = $this->server->xml->parse($body);
- $newAcl = $acl['value']->getPrivileges();
+ $acl = $this->server->xml->expect('{DAV:}acl', $body);
+ $newAcl = $acl->getPrivileges();
// Normalizing urls
foreach($newAcl as $k=>$newAce) {
@@ -1117,11 +1117,10 @@ class Plugin extends DAV\ServerPlugin {
$result = $this->expandProperties($requestUri, $report->properties, $depth);
- $xml = $this->server->xml->write([
- '{DAV:}multistatus' => new DAV\Xml\Response\MultiStatus(
- $result
- )
- ]);
+ $xml = $this->server->xml->write(
+ '{DAV:}multistatus',
+ new DAV\Xml\Response\MultiStatus($result)
+ );
$this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8');
$this->server->httpResponse->setStatus(207);
$this->server->httpResponse->setBody($xml);
@@ -1200,6 +1199,9 @@ class Plugin extends DAV\ServerPlugin {
}
$writer = $this->server->xml->getWriter();
+ $writer->openMemory();
+ $writer->startDocument();
+
$writer->startElement('{DAV:}principal-search-property-set');
foreach($this->principalSearchPropertySet as $propertyName=>$description) {
diff --git a/tests/Sabre/CalDAV/FreeBusyReportTest.php b/tests/Sabre/CalDAV/FreeBusyReportTest.php
index 2da2288..84f05f3 100644
--- a/tests/Sabre/CalDAV/FreeBusyReportTest.php
+++ b/tests/Sabre/CalDAV/FreeBusyReportTest.php
@@ -104,8 +104,8 @@ ics;
</c:free-busy-query>
XML;
- $report = $this->server->xml->parse($reportXML);
- $this->plugin->report($report['name'], $report['value']);
+ $report = $this->server->xml->parse($reportXML, null, $rootElem);
+ $this->plugin->report($rootElem, $report);
$this->assertEquals(200, $this->server->httpResponse->status);
$this->assertEquals('text/calendar', $this->server->httpResponse->getHeader('Content-Type'));
@@ -126,8 +126,8 @@ XML;
</c:free-busy-query>
XML;
- $report = $this->server->xml->parse($reportXML);
- $this->plugin->report($report['name'], $report['value']);
+ $report = $this->server->xml->parse($reportXML, null, $rootElem);
+ $this->plugin->report($rootElem, $report);
}
@@ -148,8 +148,8 @@ XML;
</c:free-busy-query>
XML;
- $report = $this->server->xml->parse($reportXML);
- $this->plugin->report($report['name'], $report['value']);
+ $report = $this->server->xml->parse($reportXML, null, $rootElem);
+ $this->plugin->report($rootElem, $report);
}
@@ -169,8 +169,8 @@ XML;
</c:free-busy-query>
XML;
- $report = $this->server->xml->parse($reportXML);
- $this->plugin->report($report['name'], $report['value']);
+ $report = $this->server->xml->parse($reportXML, null, $rootElem);
+ $this->plugin->report($rootElem, $report);
}
}
diff --git a/tests/Sabre/CalDAV/JCalTransformTest.php b/tests/Sabre/CalDAV/JCalTransformTest.php
index e7a1457..7bc4725 100644
--- a/tests/Sabre/CalDAV/JCalTransformTest.php
+++ b/tests/Sabre/CalDAV/JCalTransformTest.php
@@ -79,7 +79,7 @@ XML;
$multiStatus = $this->server->xml->parse(
$response->getBodyAsString()
- )['value'];
+ );
$responses = $multiStatus->getResponses();
$this->assertEquals(1, count($responses));
@@ -132,7 +132,7 @@ XML;
$multiStatus = $this->server->xml->parse(
$response->getBodyAsString()
- )['value'];
+ );
$responses = $multiStatus->getResponses();
@@ -185,7 +185,7 @@ XML;
$multiStatus = $this->server->xml->parse(
$response->getBodyAsString()
- )['value'];
+ );
$responses = $multiStatus->getResponses();
diff --git a/tests/Sabre/CalDAV/Notifications/PluginTest.php b/tests/Sabre/CalDAV/Notifications/PluginTest.php
index 2d52713..0652ddd 100644
--- a/tests/Sabre/CalDAV/Notifications/PluginTest.php
+++ b/tests/Sabre/CalDAV/Notifications/PluginTest.php
@@ -143,7 +143,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
</cs:notification>
';
- $this->assertEquals($expected, $httpResponse->body);
+ $this->assertXmlStringEqualsXmlString($expected, $httpResponse->getBodyAsString());
}
diff --git a/tests/Sabre/DAV/ServerMKCOLTest.php b/tests/Sabre/DAV/ServerMKCOLTest.php
index 9580f97..39e577c 100644
--- a/tests/Sabre/DAV/ServerMKCOLTest.php
+++ b/tests/Sabre/DAV/ServerMKCOLTest.php
@@ -99,7 +99,7 @@ class ServerMKCOLTest extends AbstractServer {
'Content-Type' => ['application/xml; charset=utf-8'],
),$this->response->getHeaders());
- $this->assertEquals(415, $this->response->status);
+ $this->assertEquals(400, $this->response->getStatus());
}
diff --git a/tests/Sabre/DAV/ServerPropsTest.php b/tests/Sabre/DAV/ServerPropsTest.php
index 50e60e7..4f41b37 100644
--- a/tests/Sabre/DAV/ServerPropsTest.php
+++ b/tests/Sabre/DAV/ServerPropsTest.php
@@ -189,12 +189,11 @@ class ServerPropsTest extends AbstractServer {
</d:propertyupdate>';
$result = $this->server->xml->parse($body);
- $result = $result['value']->properties;
$this->assertEquals([
'{http://sabredav.org/NS/test}someprop' => 'somevalue',
'{http://sabredav.org/NS/test}someprop2' => null,
'{http://sabredav.org/NS/test}someprop3' => null,
- ], $result);
+ ], $result->properties);
}
diff --git a/tests/Sabre/DAV/Sync/PluginTest.php b/tests/Sabre/DAV/Sync/PluginTest.php
index 8f1af80..1bb2a89 100644
--- a/tests/Sabre/DAV/Sync/PluginTest.php
+++ b/tests/Sabre/DAV/Sync/PluginTest.php
@@ -88,7 +88,7 @@ BLA;
$this->assertEquals(207, $response->status, 'Full response body:' . $response->body);
- $multiStatus = $this->server->xml->parse($response->getBodyAsString())['value'];
+ $multiStatus = $this->server->xml->parse($response->getBodyAsString());
// Checking the sync-token
$this->assertEquals(
@@ -151,7 +151,7 @@ BLA;
$this->assertEquals(207, $response->status, 'Full response body:' . $response->body);
- $multiStatus = $this->server->xml->parse($response->getBodyAsString())['value'];
+ $multiStatus = $this->server->xml->parse($response->getBodyAsString());
// Checking the sync-token
$this->assertEquals(
@@ -213,7 +213,7 @@ BLA;
$multiStatus = $this->server->xml->parse(
$response->getBodyAsString()
- )['value'];
+ );
// Checking the sync-token
$this->assertEquals(
@@ -264,7 +264,7 @@ BLA;
$multiStatus = $this->server->xml->parse(
$response->getBodyAsString()
- )['value'];
+ );
// Checking the sync-token
$this->assertEquals(
diff --git a/tests/Sabre/DAV/TemporaryFileFilterTest.php b/tests/Sabre/DAV/TemporaryFileFilterTest.php
index 29300d7..7122f4a 100644
--- a/tests/Sabre/DAV/TemporaryFileFilterTest.php
+++ b/tests/Sabre/DAV/TemporaryFileFilterTest.php
@@ -16,13 +16,8 @@ class TemporaryFileFilterTest extends AbstractServer {
function testPutNormal() {
- $serverVars = array(
- 'REQUEST_URI' => '/testput.txt',
- 'REQUEST_METHOD' => 'PUT',
- );
+ $request = new HTTP\Request('PUT', '/testput.txt', [], 'Testing new file');
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody('Testing new file');
$this->server->httpRequest = ($request);
$this->server->exec();
@@ -37,13 +32,8 @@ class TemporaryFileFilterTest extends AbstractServer {
function testPutTemp() {
// mimicking an OS/X resource fork
- $serverVars = array(
- 'REQUEST_URI' => '/._testput.txt',
- 'REQUEST_METHOD' => 'PUT',
- );
+ $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file');
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody('Testing new file');
$this->server->httpRequest = ($request);
$this->server->exec();
@@ -60,14 +50,8 @@ class TemporaryFileFilterTest extends AbstractServer {
function testPutTempIfNoneMatch() {
// mimicking an OS/X resource fork
- $serverVars = array(
- 'REQUEST_URI' => '/._testput.txt',
- 'REQUEST_METHOD' => 'PUT',
- 'HTTP_IF_NONE_MATCH' => '*',
- );
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody('Testing new file');
+ $request = new HTTP\Request('PUT', '/._testput.txt', ['If-None-Match' => '*'], 'Testing new file');
+
$this->server->httpRequest = ($request);
$this->server->exec();
@@ -93,13 +77,7 @@ class TemporaryFileFilterTest extends AbstractServer {
function testPutGet() {
// mimicking an OS/X resource fork
- $serverVars = array(
- 'REQUEST_URI' => '/._testput.txt',
- 'REQUEST_METHOD' => 'PUT',
- );
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody('Testing new file');
+ $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file');
$this->server->httpRequest = ($request);
$this->server->exec();
@@ -109,13 +87,9 @@ class TemporaryFileFilterTest extends AbstractServer {
'X-Sabre-Temp' => ['true'],
),$this->response->getHeaders());
- $serverVars = array(
- 'REQUEST_URI' => '/._testput.txt',
- 'REQUEST_METHOD' => 'GET',
- );
+ $request = new HTTP\Request('GET', '/._testput.txt');
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals(200, $this->response->status);
@@ -137,13 +111,7 @@ class TemporaryFileFilterTest extends AbstractServer {
$this->server->addPlugin($locksPlugin);
// mimicking an OS/X resource fork
- $serverVars = array(
- 'REQUEST_URI' => '/._testlock.txt',
- 'REQUEST_METHOD' => 'LOCK',
- );
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
-
+ $request = new HTTP\Request('LOCK', '/._testput.txt');
$request->setBody('<?xml version="1.0"?>
<D:lockinfo xmlns:D="DAV:">
<D:lockscope><D:exclusive/></D:lockscope>
@@ -168,14 +136,9 @@ class TemporaryFileFilterTest extends AbstractServer {
function testPutDelete() {
// mimicking an OS/X resource fork
- $serverVars = array(
- 'REQUEST_URI' => '/._testput.txt',
- 'REQUEST_METHOD' => 'PUT',
- );
+ $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file');
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody('Testing new file');
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals('', $this->response->body);
@@ -184,13 +147,8 @@ class TemporaryFileFilterTest extends AbstractServer {
'X-Sabre-Temp' => ['true'],
),$this->response->getHeaders());
- $serverVars = array(
- 'REQUEST_URI' => '/._testput.txt',
- 'REQUEST_METHOD' => 'DELETE',
- );
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $this->server->httpRequest = ($request);
+ $request = new HTTP\Request('DELETE', '/._testput.txt');
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n". $this->response->body);
@@ -205,14 +163,8 @@ class TemporaryFileFilterTest extends AbstractServer {
function testPutPropfind() {
// mimicking an OS/X resource fork
- $serverVars = array(
- 'REQUEST_URI' => '/._testput.txt',
- 'REQUEST_METHOD' => 'PUT',
- );
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody('Testing new file');
- $this->server->httpRequest = ($request);
+ $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file');
+ $this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals('', $this->response->body);
@@ -221,13 +173,8 @@ class TemporaryFileFilterTest extends AbstractServer {
'X-Sabre-Temp' => ['true'],
),$this->response->getHeaders());
- $serverVars = array(
- 'REQUEST_URI' => '/._testput.txt',
- 'REQUEST_METHOD' => 'PROPFIND',
- );
+ $request = new HTTP\Request('PROPFIND', '/._testput.txt');
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody('');
$this->server->httpRequest = ($request);
$this->server->exec();
diff --git a/tests/Sabre/DAV/XMLUtilTest.php b/tests/Sabre/DAV/XMLUtilTest.php
deleted file mode 100644
index 95c6a4a..0000000
--- a/tests/Sabre/DAV/XMLUtilTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-namespace Sabre\DAV;
-
-class XMLUtilTest extends \PHPUnit_Framework_TestCase {
-
- function testParseClarkNotation() {
-
- $this->assertEquals(array(
- 'DAV:',
- 'foo',
- ), XMLUtil::parseClarkNotation('{DAV:}foo'));
-
- $this->assertEquals(array(
- 'http://example.org/ns/bla',
- 'bar-soap',
- ), XMLUtil::parseClarkNotation('{http://example.org/ns/bla}bar-soap'));
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- function testParseClarkNotationFail() {
-
- XMLUtil::parseClarkNotation('}foo');
-
- }
-
-}
-
diff --git a/tests/Sabre/DAV/Xml/Property/HrefTest.php b/tests/Sabre/DAV/Xml/Property/HrefTest.php
index 6a000c7..ef96f6d 100644
--- a/tests/Sabre/DAV/Xml/Property/HrefTest.php
+++ b/tests/Sabre/DAV/Xml/Property/HrefTest.php
@@ -19,7 +19,7 @@ class HrefTest extends XmlTest {
$href = new Href('path');
$this->assertEquals('path',$href->getHref());
- $this->baseUri = '/bla/';
+ $this->contextUri = '/bla/';
$xml = $this->write(['{DAV:}anything' => $href]);
diff --git a/tests/Sabre/DAV/Xml/XmlTest.php b/tests/Sabre/DAV/Xml/XmlTest.php
index bdd396c..33246f2 100644
--- a/tests/Sabre/DAV/Xml/XmlTest.php
+++ b/tests/Sabre/DAV/Xml/XmlTest.php
@@ -8,12 +8,12 @@ use Sabre\Xml\Reader;
abstract class XmlTest extends \PHPUnit_Framework_TestCase {
protected $namespaceMap = ['DAV:' => 'd'];
- protected $baseUri = '/';
+ protected $contextUri = '/';
function write($input) {
$writer = new Writer();
- $writer->baseUri = $this->baseUri;
+ $writer->contextUri = $this->contextUri;
$writer->namespaceMap = $this->namespaceMap;
$writer->openMemory();
$writer->setIndent(true);
diff --git a/tests/Sabre/DAVACL/PluginPropertiesTest.php b/tests/Sabre/DAVACL/PluginPropertiesTest.php
index aa367de..b3d6a17 100644
--- a/tests/Sabre/DAVACL/PluginPropertiesTest.php
+++ b/tests/Sabre/DAVACL/PluginPropertiesTest.php
@@ -95,7 +95,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$server = new DAV\Server();
$prop = $result[200]['{DAV:}supported-privilege-set'];
- $result = $server->xml->write(['{DAV:}root' => $prop]);
+ $result = $server->xml->write('{DAV:}root', $prop);
$xpaths = [
'/d:root' => 1,
diff --git a/tests/Sabre/DAVACL/Xml/Property/ACLTest.php b/tests/Sabre/DAVACL/Xml/Property/ACLTest.php
index d942fc3..559114f 100644
--- a/tests/Sabre/DAVACL/Xml/Property/ACLTest.php
+++ b/tests/Sabre/DAVACL/Xml/Property/ACLTest.php
@@ -17,7 +17,7 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
function testSerializeEmpty() {
$acl = new Acl(array());
- $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $acl]);
+ $xml = (new DAV\Server())->xml->write('{DAV:}root', $acl);
$expected = '<?xml version="1.0"?>
<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" />';
@@ -43,7 +43,7 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
];
$acl = new Acl($privileges);
- $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $acl], '/');
+ $xml = (new DAV\Server())->xml->write('{DAV:}root', $acl, '/');
$expected = '<?xml version="1.0"?>
<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
@@ -96,7 +96,7 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
);
$acl = new Acl($privileges);
- $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $acl], '/');
+ $xml = (new DAV\Server())->xml->write('{DAV:}root', $acl, '/');
$expected = '<?xml version="1.0"?>
<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
diff --git a/tests/Sabre/DAVACL/Xml/Property/AclRestrictionsTest.php b/tests/Sabre/DAVACL/Xml/Property/AclRestrictionsTest.php
index 4399b88..6d8b83a 100644
--- a/tests/Sabre/DAVACL/Xml/Property/AclRestrictionsTest.php
+++ b/tests/Sabre/DAVACL/Xml/Property/AclRestrictionsTest.php
@@ -17,7 +17,7 @@ class AclRestrictionsTest extends \PHPUnit_Framework_TestCase {
function testSerialize() {
$prop = new AclRestrictions();
- $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $prop]);
+ $xml = (new DAV\Server())->xml->write('{DAV:}root', $prop);
$expected = '<?xml version="1.0"?>
<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><d:grant-only/><d:no-invert/></d:root>';
diff --git a/tests/Sabre/DAVACL/Xml/Property/CurrentUserPrivilegeSetTest.php b/tests/Sabre/DAVACL/Xml/Property/CurrentUserPrivilegeSetTest.php
index 835014c..dd299ec 100644
--- a/tests/Sabre/DAVACL/Xml/Property/CurrentUserPrivilegeSetTest.php
+++ b/tests/Sabre/DAVACL/Xml/Property/CurrentUserPrivilegeSetTest.php
@@ -17,7 +17,7 @@ class CurrentUserPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
'{DAV:}write',
];
$prop = new CurrentUserPrivilegeSet($privileges);
- $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $prop]);
+ $xml = (new DAV\Server())->xml->write('{DAV:}root', $prop);
$expected = <<<XML
<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
diff --git a/tests/Sabre/DAVACL/Xml/Property/PrincipalTest.php b/tests/Sabre/DAVACL/Xml/Property/PrincipalTest.php
index 400d7de..189d7f4 100644
--- a/tests/Sabre/DAVACL/Xml/Property/PrincipalTest.php
+++ b/tests/Sabre/DAVACL/Xml/Property/PrincipalTest.php
@@ -41,7 +41,7 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
$prin = new Principal(Principal::UNAUTHENTICATED);
- $xml = (new DAV\Server())->xml->write(['{DAV:}principal' => $prin]);
+ $xml = (new DAV\Server())->xml->write('{DAV:}principal', $prin);
$this->assertXmlStringEqualsXmlString('
<d:principal xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
@@ -57,7 +57,7 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
function testSerializeAuthenticated() {
$prin = new Principal(Principal::AUTHENTICATED);
- $xml = (new DAV\Server())->xml->write(['{DAV:}principal' => $prin]);
+ $xml = (new DAV\Server())->xml->write('{DAV:}principal', $prin);
$this->assertXmlStringEqualsXmlString('
<d:principal xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
@@ -73,7 +73,7 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
function testSerializeHref() {
$prin = new Principal(Principal::HREF,'principals/admin');
- $xml = (new DAV\Server())->xml->write(['{DAV:}principal' => $prin], '/');
+ $xml = (new DAV\Server())->xml->write('{DAV:}principal', $prin, '/');
$this->assertXmlStringEqualsXmlString('
<d:principal xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
diff --git a/tests/Sabre/DAVACL/Xml/Property/SupportedPrivilegeSetTest.php b/tests/Sabre/DAVACL/Xml/Property/SupportedPrivilegeSetTest.php
index 946c2fc..acacda5 100644
--- a/tests/Sabre/DAVACL/Xml/Property/SupportedPrivilegeSetTest.php
+++ b/tests/Sabre/DAVACL/Xml/Property/SupportedPrivilegeSetTest.php
@@ -26,7 +26,7 @@ class SupportedPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
'privilege' => '{DAV:}all',
]);
- $xml = (new DAV\Server())->xml->write(['{DAV:}supported-privilege-set' => $prop]);
+ $xml = (new DAV\Server())->xml->write('{DAV:}supported-privilege-set', $prop);
$this->assertXmlStringEqualsXmlString('
<d:supported-privilege-set xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
@@ -58,7 +58,7 @@ class SupportedPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
],
]);
- $xml = (new DAV\Server())->xml->write(['{DAV:}supported-privilege-set' => $prop]);
+ $xml = (new DAV\Server())->xml->write('{DAV:}supported-privilege-set', $prop);
$this->assertXmlStringEqualsXmlString('
<d:supported-privilege-set xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list