[Pkg-owncloud-commits] [php-sabredav] 32/148: Moved carddav properties over. Deleted all old property classes!
David Prévot
taffit at moszumanska.debian.org
Wed Apr 15 01:37:07 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 12385643e18a801a3a57b31c6bdb709247543901
Author: Evert Pot <me at evertpot.com>
Date: Sun Feb 8 19:02:09 2015 -0500
Moved carddav properties over. Deleted all old property classes!
---
lib/CardDAV/Plugin.php | 4 +-
lib/CardDAV/Property/SupportedAddressData.php | 73 --------------------
lib/CardDAV/Property/SupportedCollationSet.php | 45 ------------
lib/CardDAV/Xml/Filter/ParamFilter.php | 51 ++++----------
lib/CardDAV/Xml/Filter/PropFilter.php | 52 ++++----------
lib/CardDAV/Xml/Property/SupportedAddressData.php | 79 ++++++++--------------
lib/CardDAV/Xml/Property/SupportedCollationSet.php | 47 +++++++++++++
lib/DAV/Property.php | 32 ---------
lib/DAV/PropertyInterface.php | 39 -----------
tests/Sabre/CardDAV/PluginTest.php | 4 +-
.../CardDAV/Property/SupportedAddressDataTest.php | 46 -------------
.../CardDAV/Property/SupportedCollationSetTest.php | 46 -------------
.../Xml/Property/SupportedAddressDataTest.php | 38 +++++++++++
.../Xml/Property/SupportedCollationSetTest.php | 38 +++++++++++
14 files changed, 181 insertions(+), 413 deletions(-)
diff --git a/lib/CardDAV/Plugin.php b/lib/CardDAV/Plugin.php
index 4ec0214..2f956a1 100644
--- a/lib/CardDAV/Plugin.php
+++ b/lib/CardDAV/Plugin.php
@@ -147,10 +147,10 @@ class Plugin extends DAV\ServerPlugin {
$propFind->handle($ns . 'max-resource-size', $this->maxResourceSize);
$propFind->handle($ns . 'supported-address-data', function() {
- return new Property\SupportedAddressData();
+ return new Xml\Property\SupportedAddressData();
});
$propFind->handle($ns . 'supported-collation-set', function() {
- return new Property\SupportedCollationSet();
+ return new Xml\Property\SupportedCollationSet();
});
}
diff --git a/lib/CardDAV/Property/SupportedAddressData.php b/lib/CardDAV/Property/SupportedAddressData.php
deleted file mode 100644
index 41aa36f..0000000
--- a/lib/CardDAV/Property/SupportedAddressData.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-
-namespace Sabre\CardDAV\Property;
-
-use Sabre\DAV;
-use Sabre\CardDAV;
-
-/**
- * Supported-address-data property
- *
- * This property is a representation of the supported-address-data property
- * in the CardDAV namespace.
- *
- * @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 SupportedAddressData extends DAV\Property {
-
- /**
- * supported versions
- *
- * @var array
- */
- protected $supportedData = [];
-
- /**
- * Creates the property
- *
- * @param array|null $supportedData
- */
- function __construct(array $supportedData = null) {
-
- if (is_null($supportedData)) {
- $supportedData = [
- ['contentType' => 'text/vcard', 'version' => '3.0'],
- ['contentType' => 'text/vcard', 'version' => '4.0'],
- ['contentType' => 'application/vcard+json', 'version' => '4.0'],
- ];
- }
-
- $this->supportedData = $supportedData;
-
- }
-
- /**
- * Serializes the property in a DOMDocument
- *
- * @param DAV\Server $server
- * @param \DOMElement $node
- * @return void
- */
- function serialize(DAV\Server $server,\DOMElement $node) {
-
- $doc = $node->ownerDocument;
-
- $prefix =
- isset($server->xmlNamespaces[CardDAV\Plugin::NS_CARDDAV]) ?
- $server->xmlNamespaces[CardDAV\Plugin::NS_CARDDAV] :
- 'card';
-
- foreach($this->supportedData as $supported) {
-
- $caldata = $doc->createElementNS(CardDAV\Plugin::NS_CARDDAV, $prefix . ':address-data-type');
- $caldata->setAttribute('content-type',$supported['contentType']);
- $caldata->setAttribute('version',$supported['version']);
- $node->appendChild($caldata);
-
- }
-
- }
-
-}
diff --git a/lib/CardDAV/Property/SupportedCollationSet.php b/lib/CardDAV/Property/SupportedCollationSet.php
deleted file mode 100644
index 2c95b9a..0000000
--- a/lib/CardDAV/Property/SupportedCollationSet.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-namespace Sabre\CardDAV\Property;
-use Sabre\DAV;
-
-/**
- * supported-collation-set property
- *
- * This property is a representation of the supported-collation-set property
- * in the CardDAV namespace.
- *
- * @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 SupportedCollationSet extends DAV\Property {
-
- /**
- * Serializes the property in a DOM document
- *
- * @param DAV\Server $server
- * @param \DOMElement $node
- * @return void
- */
- function serialize(DAV\Server $server,\DOMElement $node) {
-
- $doc = $node->ownerDocument;
-
- $prefix = $node->lookupPrefix('urn:ietf:params:xml:ns:carddav');
- if (!$prefix) $prefix = 'card';
-
- $node->appendChild(
- $doc->createElement($prefix . ':supported-collation','i;ascii-casemap')
- );
- $node->appendChild(
- $doc->createElement($prefix . ':supported-collation','i;octet')
- );
- $node->appendChild(
- $doc->createElement($prefix . ':supported-collation','i;unicode-casemap')
- );
-
-
- }
-
-}
diff --git a/lib/CardDAV/Xml/Filter/ParamFilter.php b/lib/CardDAV/Xml/Filter/ParamFilter.php
index 91ccc66..44fba48 100644
--- a/lib/CardDAV/Xml/Filter/ParamFilter.php
+++ b/lib/CardDAV/Xml/Filter/ParamFilter.php
@@ -1,15 +1,11 @@
<?php
-namespace Sabre\CardDAV\XML\Filter;
-
-use
- Sabre\XML\Element,
- Sabre\XML\Reader,
- Sabre\XML\Writer,
- Sabre\DAV\Exception\CannotSerialize,
- Sabre\DAV\Exception\BadRequest,
- Sabre\CardDAV\Plugin;
+namespace Sabre\CardDAV\Xml\Filter;
+use Sabre\Xml\Element;
+use Sabre\Xml\Reader;
+use Sabre\DAV\Exception\BadRequest;
+use Sabre\CardDAV\Plugin;
/**
* ParamFilter parser.
@@ -21,32 +17,11 @@ use
*
* The result will be spit out as an array.
*
- * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved.
- * @author Evert Pot (http://www.rooftopsolutions.nl/)
- * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ * @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 ParamFilter implements Element {
-
- /**
- * The serialize method is called during xml writing.
- *
- * It should use the $writer argument to encode this object into XML.
- *
- * Important note: it is not needed to create the parent element. The
- * parent element is already created, and we only have to worry about
- * attributes, child elements and text (if any).
- *
- * Important note 2: If you are writing any new elements, you are also
- * responsible for closing them.
- *
- * @param Writer $writer
- * @return void
- */
- public function serializeXml(Writer $writer) {
-
- throw new CannotSerialize('This element cannot be serialized.');
-
- }
+abstract class ParamFilter implements Element {
/**
* The deserialize method is called during xml parsing.
@@ -57,8 +32,8 @@ class ParamFilter implements Element {
* Often you want to return an instance of the current class, but you are
* free to return other data as well.
*
- * Important note 2: You are responsible for advancing the reader to the
- * next element. Not doing anything will result in a never-ending loop.
+ * 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();
@@ -69,7 +44,7 @@ class ParamFilter implements Element {
* @param Reader $reader
* @return mixed
*/
- static public function deserializeXml(Reader $reader) {
+ static function xmlDeserialize(Reader $reader) {
$result = [
'name' => null,
@@ -96,7 +71,7 @@ class ParamFilter implements Element {
case '{' . Plugin::NS_CARDDAV . '}text-match' :
$matchType = isset($elem['attributes']['match-type'])?$elem['attributes']['match-type']:'contains';
- if (!in_array($matchType, array('contains', 'equals', 'starts-with', 'ends-with'))) {
+ if (!in_array($matchType, ['contains', 'equals', 'starts-with', 'ends-with'])) {
throw new BadRequest('Unknown match-type: ' . $matchType);
}
$result['text-match'] = [
diff --git a/lib/CardDAV/Xml/Filter/PropFilter.php b/lib/CardDAV/Xml/Filter/PropFilter.php
index a7cbf8e..c94884d 100644
--- a/lib/CardDAV/Xml/Filter/PropFilter.php
+++ b/lib/CardDAV/Xml/Filter/PropFilter.php
@@ -1,14 +1,11 @@
<?php
-namespace Sabre\CardDAV\XML\Filter;
+namespace Sabre\CardDAV\Xml\Filter;
-use
- Sabre\XML\Element,
- Sabre\XML\Reader,
- Sabre\XML\Writer,
- Sabre\DAV\Exception\CannotSerialize,
- Sabre\DAV\Exception\BadRequest,
- Sabre\CardDAV\Plugin;
+use Sabre\Xml\Element;
+use Sabre\Xml\Reader;
+use Sabre\DAV\Exception\BadRequest;
+use Sabre\CardDAV\Plugin;
/**
@@ -20,33 +17,12 @@ use
* http://tools.ietf.org/html/rfc6352#section-10.5.1
*
* The result will be spit out as an array.
- *
- * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved.
- * @author Evert Pot (http://www.rooftopsolutions.nl/)
- * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ *
+ * @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 PropFilter implements Element {
-
- /**
- * The serialize method is called during xml writing.
- *
- * It should use the $writer argument to encode this object into XML.
- *
- * Important note: it is not needed to create the parent element. The
- * parent element is already created, and we only have to worry about
- * attributes, child elements and text (if any).
- *
- * Important note 2: If you are writing any new elements, you are also
- * responsible for closing them.
- *
- * @param Writer $writer
- * @return void
- */
- public function serializeXml(Writer $writer) {
-
- throw new CannotSerialize('This element cannot be serialized.');
-
- }
+abstract class PropFilter implements Element {
/**
* The deserialize method is called during xml parsing.
@@ -57,8 +33,8 @@ class PropFilter implements Element {
* Often you want to return an instance of the current class, but you are
* free to return other data as well.
*
- * Important note 2: You are responsible for advancing the reader to the
- * next element. Not doing anything will result in a never-ending loop.
+ * 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();
@@ -69,7 +45,7 @@ class PropFilter implements Element {
* @param Reader $reader
* @return mixed
*/
- static public function deserializeXml(Reader $reader) {
+ static function deserializeXml(Reader $reader) {
$result = [
'name' => null,
@@ -101,7 +77,7 @@ class PropFilter implements Element {
case '{' . Plugin::NS_CARDDAV . '}text-match' :
$matchType = isset($elem['attributes']['match-type'])?$elem['attributes']['match-type']:'contains';
- if (!in_array($matchType, array('contains', 'equals', 'starts-with', 'ends-with'))) {
+ if (!in_array($matchType, ['contains', 'equals', 'starts-with', 'ends-with'])) {
throw new BadRequest('Unknown match-type: ' . $matchType);
}
$result['text-matches'][] = [
diff --git a/lib/CardDAV/Xml/Property/SupportedAddressData.php b/lib/CardDAV/Xml/Property/SupportedAddressData.php
index 88caa51..1333c71 100644
--- a/lib/CardDAV/Xml/Property/SupportedAddressData.php
+++ b/lib/CardDAV/Xml/Property/SupportedAddressData.php
@@ -1,13 +1,10 @@
<?php
-namespace Sabre\CardDAV\XML\Property;
+namespace Sabre\CardDAV\Xml\Property;
-use
- Sabre\XML\Element,
- Sabre\XML\Reader,
- Sabre\XML\Writer,
- Sabre\DAV\Exception\CannotDeserialize,
- Sabre\CardDAV\Plugin;
+use Sabre\Xml\Writer;
+use Sabre\Xml\XmlSerializable;
+use Sabre\CardDAV\Plugin;
/**
* Supported-address-data property
@@ -19,31 +16,32 @@ use
*
* http://tools.ietf.org/html/rfc6352#section-6.2.2
*
- * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved.
- * @author Evert Pot (http://www.rooftopsolutions.nl/)
- * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ * @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 SupportedAddressData implements Element {
+class SupportedAddressData implements XmlSerializable {
/**
* supported versions
*
* @var array
*/
- protected $supportedData = array();
+ protected $supportedData = [];
/**
* Creates the property
*
* @param array|null $supportedData
*/
- public function __construct(array $supportedData = null) {
+ function __construct(array $supportedData = null) {
if (is_null($supportedData)) {
- $supportedData = array(
- array('contentType' => 'text/vcard', 'version' => '3.0'),
- // array('contentType' => 'text/vcard', 'version' => '4.0'),
- );
+ $supportedData = [
+ ['contentType' => 'text/vcard', 'version' => '3.0'],
+ ['contentType' => 'text/vcard', 'version' => '4.0'],
+ ['contentType' => 'application/vcard+json', 'version' => '4.0'],
+ ];
}
$this->supportedData = $supportedData;
@@ -51,21 +49,25 @@ class SupportedAddressData implements Element {
}
/**
- * The serialize method is called during xml writing.
+ * The xmlSerialize metod is called during xml writing.
*
- * It should use the $writer argument to encode this object into XML.
+ * Use the $writer argument to write its own xml serialization.
*
- * Important note: it is not needed to create the parent element. The
- * parent element is already created, and we only have to worry about
- * attributes, child elements and text (if any).
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializble should only ever write what's considered
+ * its 'inner xml'.
*
- * Important note 2: If you are writing any new elements, you are also
- * responsible for closing them.
+ * 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
*/
- public function serializeXml(Writer $writer) {
+ function xmlSerialize(Writer $writer) {
foreach($this->supportedData as $supported) {
$writer->startElement('{' . Plugin::NS_CARDDAV . '}address-data-type');
@@ -78,31 +80,4 @@ class SupportedAddressData implements Element {
}
- /**
- * 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.
- *
- * Important note 2: 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 public function deserializeXml(Reader $reader) {
-
- throw new CannotDeserialize('This element does not have a deserializer');
-
- }
-
}
diff --git a/lib/CardDAV/Xml/Property/SupportedCollationSet.php b/lib/CardDAV/Xml/Property/SupportedCollationSet.php
new file mode 100644
index 0000000..1f6016c
--- /dev/null
+++ b/lib/CardDAV/Xml/Property/SupportedCollationSet.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Sabre\CardDAV\Xml\Property;
+
+use Sabre\Xml\Writer;
+use Sabre\Xml\XmlSerializable;
+
+/**
+ * supported-collation-set property
+ *
+ * This property is a representation of the supported-collation-set property
+ * in the CardDAV namespace.
+ *
+ * @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 SupportedCollationSet implements XmlSerializable {
+
+ /**
+ * The xmlSerialize metod 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) {
+
+ foreach(['i;ascii-casemap', 'i;octet', 'i;unicode-casemap'] as $coll) {
+ $writer->writeElement('{urn:ietf:params:xml:ns:carddav}supported-collation', $coll);
+ }
+
+ }
+
+}
diff --git a/lib/DAV/Property.php b/lib/DAV/Property.php
deleted file mode 100644
index b6d21af..0000000
--- a/lib/DAV/Property.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-namespace Sabre\DAV;
-
-/**
- * Abstract property class
- *
- * Extend this class to create custom complex properties
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-abstract class Property implements PropertyInterface {
-
- /**
- * Unserializes the property.
- *
- * This static method should return a an instance of this object.
- *
- * @param \DOMElement $prop
- * @param array $propertyMap
- * @return DAV\IProperty
- */
- static function unserialize(\DOMElement $prop, array $propertyMap) {
-
- throw new Exception('Unserialize has not been implemented for this class');
-
- }
-
-}
-
diff --git a/lib/DAV/PropertyInterface.php b/lib/DAV/PropertyInterface.php
deleted file mode 100644
index 6de1664..0000000
--- a/lib/DAV/PropertyInterface.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-namespace Sabre\DAV;
-
-/**
- * PropertyInterface
- *
- * Implement this interface to create new complex properties
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-interface PropertyInterface {
-
- /**
- * Serializes this property into an XML document.
- *
- * @param Server $server
- * @param \DOMElement $prop
- * @return void
- */
- function serialize(Server $server, \DOMElement $prop);
-
- /**
- * This method unserializes the property FROM an xml document.
- *
- * This method (often) must return an instance of itself. It acts therefore
- * a bit like a constructor. It is also valid to return a different object
- * or type.
- *
- * @param \DOMElement $prop
- * @param array $propertyMap
- * @return mixed
- */
- static function unserialize(\DOMElement $prop, array $propertyMap);
-
-}
-
diff --git a/tests/Sabre/CardDAV/PluginTest.php b/tests/Sabre/CardDAV/PluginTest.php
index 8928bb9..0ef5a3a 100644
--- a/tests/Sabre/CardDAV/PluginTest.php
+++ b/tests/Sabre/CardDAV/PluginTest.php
@@ -151,11 +151,11 @@ class PluginTest extends AbstractPluginTest {
$this->plugin->propFindEarly($propFind, $node);
$this->assertInstanceOf(
- 'Sabre\\CardDAV\\Property\\SupportedAddressData',
+ 'Sabre\\CardDAV\\Xml\\Property\\SupportedAddressData',
$propFind->get($ns . 'supported-address-data')
);
$this->assertInstanceOf(
- 'Sabre\\CardDAV\\Property\\SupportedCollationSet',
+ 'Sabre\\CardDAV\\Xml\\Property\\SupportedCollationSet',
$propFind->get($ns . 'supported-collation-set')
);
diff --git a/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php b/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php
deleted file mode 100644
index 416f865..0000000
--- a/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-namespace Sabre\CardDAV\Property;
-
-use Sabre\CardDAV;
-use Sabre\DAV;
-
-class SupportedAddressDataDataTest extends \PHPUnit_Framework_TestCase {
-
- function testSimple() {
-
- $property = new SupportedAddressData();
- $this->assertInstanceOf('Sabre\CardDAV\Property\SupportedAddressData', $property);
-
- }
-
- /**
- * @depends testSimple
- */
- function testSerialize() {
-
- $property = new SupportedAddressData();
-
- $doc = new \DOMDocument();
- $root = $doc->createElementNS(CardDAV\Plugin::NS_CARDDAV, 'card:root');
- $root->setAttribute('xmlns:d','DAV:');
-
- $doc->appendChild($root);
- $server = new DAV\Server();
-
- $property->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<card:root xmlns:card="' . CardDAV\Plugin::NS_CARDDAV . '" xmlns:d="DAV:">' .
-'<card:address-data-type content-type="text/vcard" version="3.0"/>' .
-'<card:address-data-type content-type="text/vcard" version="4.0"/>' .
-'<card:address-data-type content-type="application/vcard+json" version="4.0"/>' .
-'</card:root>
-', $xml);
-
- }
-
-}
diff --git a/tests/Sabre/CardDAV/Property/SupportedCollationSetTest.php b/tests/Sabre/CardDAV/Property/SupportedCollationSetTest.php
deleted file mode 100644
index 7cc92ce..0000000
--- a/tests/Sabre/CardDAV/Property/SupportedCollationSetTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-namespace Sabre\CardDAV\Property;
-
-use Sabre\CardDAV;
-use Sabre\DAV;
-
-class SupportedCollationSetTest extends \PHPUnit_Framework_TestCase {
-
- function testSimple() {
-
- $property = new SupportedCollationSet();
- $this->assertInstanceOf('Sabre\CardDAV\Property\SupportedCollationSet', $property);
-
- }
-
- /**
- * @depends testSimple
- */
- function testSerialize() {
-
- $property = new SupportedCollationSet();
-
- $doc = new \DOMDocument();
- $root = $doc->createElementNS(CardDAV\Plugin::NS_CARDDAV, 'card:root');
- $root->setAttribute('xmlns:d','DAV:');
-
- $doc->appendChild($root);
- $server = new DAV\Server();
-
- $property->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<card:root xmlns:card="' . CardDAV\Plugin::NS_CARDDAV . '" xmlns:d="DAV:">' .
-'<card:supported-collation>i;ascii-casemap</card:supported-collation>' .
-'<card:supported-collation>i;octet</card:supported-collation>' .
-'<card:supported-collation>i;unicode-casemap</card:supported-collation>' .
-'</card:root>
-', $xml);
-
- }
-
-}
diff --git a/tests/Sabre/CardDAV/Xml/Property/SupportedAddressDataTest.php b/tests/Sabre/CardDAV/Xml/Property/SupportedAddressDataTest.php
new file mode 100644
index 0000000..02fbf4c
--- /dev/null
+++ b/tests/Sabre/CardDAV/Xml/Property/SupportedAddressDataTest.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Sabre\CardDAV\Xml\Property;
+
+use Sabre\CardDAV;
+use Sabre\DAV;
+
+class SupportedAddressDataDataTest extends DAV\Xml\XmlTest {
+
+ function testSimple() {
+
+ $property = new SupportedAddressData();
+ $this->assertInstanceOf('Sabre\CardDAV\Xml\Property\SupportedAddressData', $property);
+
+ }
+
+ /**
+ * @depends testSimple
+ */
+ function testSerialize() {
+
+ $property = new SupportedAddressData();
+
+ $this->namespaceMap[CardDAV\Plugin::NS_CARDDAV] = 'card';
+ $xml = $this->write(['{DAV:}root' => $property]);
+
+ $this->assertXmlStringEqualsXmlString(
+'<?xml version="1.0"?>
+<d:root xmlns:card="' . CardDAV\Plugin::NS_CARDDAV . '" xmlns:d="DAV:">' .
+'<card:address-data-type content-type="text/vcard" version="3.0"/>' .
+'<card:address-data-type content-type="text/vcard" version="4.0"/>' .
+'<card:address-data-type content-type="application/vcard+json" version="4.0"/>' .
+'</d:root>
+', $xml);
+
+ }
+
+}
diff --git a/tests/Sabre/CardDAV/Xml/Property/SupportedCollationSetTest.php b/tests/Sabre/CardDAV/Xml/Property/SupportedCollationSetTest.php
new file mode 100644
index 0000000..e06aff1
--- /dev/null
+++ b/tests/Sabre/CardDAV/Xml/Property/SupportedCollationSetTest.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Sabre\CardDAV\Xml\Property;
+
+use Sabre\CardDAV;
+use Sabre\DAV;
+
+class SupportedCollationSetTest extends DAV\Xml\XmlTest {
+
+ function testSimple() {
+
+ $property = new SupportedCollationSet();
+ $this->assertInstanceOf('Sabre\CardDAV\Xml\Property\SupportedCollationSet', $property);
+
+ }
+
+ /**
+ * @depends testSimple
+ */
+ function testSerialize() {
+
+ $property = new SupportedCollationSet();
+
+ $this->namespaceMap[CardDAV\Plugin::NS_CARDDAV] = 'card';
+ $xml = $this->write(['{DAV:}root' => $property]);
+
+ $this->assertXmlStringEqualsXmlString(
+'<?xml version="1.0"?>
+<d:root xmlns:card="' . CardDAV\Plugin::NS_CARDDAV . '" xmlns:d="DAV:">' .
+'<card:supported-collation>i;ascii-casemap</card:supported-collation>' .
+'<card:supported-collation>i;octet</card:supported-collation>' .
+'<card:supported-collation>i;unicode-casemap</card:supported-collation>' .
+'</d:root>
+', $xml);
+
+ }
+
+}
--
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