[Pkg-owncloud-commits] [php-sabredav] 28/148: A few more CalDAV properties.

David Prévot taffit at moszumanska.debian.org
Wed Apr 15 01:37:06 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 0bad45a58c45ae7a57f03ebd537cdafc3dd00ba0
Author: Evert Pot <me at evertpot.com>
Date:   Sat Feb 7 00:52:56 2015 -0500

    A few more CalDAV properties.
---
 lib/CalDAV/Property/ScheduleCalendarTransp.php     | 103 ---------------------
 .../Property/SupportedCalendarComponentSet.php     |  89 ------------------
 lib/CalDAV/Property/SupportedCalendarData.php      |  44 ---------
 lib/CalDAV/Property/SupportedCollationSet.php      |  45 ---------
 lib/CalDAV/Schedule/Plugin.php                     |   2 +-
 .../Xml/Property/SupportedCalendarComponentSet.php |   4 +-
 lib/CalDAV/Xml/Property/SupportedCalendarData.php  |  63 +++++--------
 lib/CalDAV/Xml/Property/SupportedCollationSet.php  |  63 ++++---------
 tests/Sabre/CalDAV/Backend/Mock.php                |   6 +-
 tests/Sabre/CalDAV/PluginTest.php                  |  15 ++-
 .../CalDAV/Property/SupportedCalendarDataTest.php  |  46 ---------
 .../CalDAV/Property/SupportedCollationSetTest.php  |  47 ----------
 .../Sabre/CalDAV/Schedule/FreeBusyRequestTest.php  |  30 +++---
 tests/Sabre/CalDAV/ValidateICalTest.php            |  10 +-
 .../Xml/Property/SupportedCalendarDataTest.php     |  36 +++++++
 .../Xml/Property/SupportedCollationSetTest.php     |  37 ++++++++
 16 files changed, 146 insertions(+), 494 deletions(-)

diff --git a/lib/CalDAV/Property/ScheduleCalendarTransp.php b/lib/CalDAV/Property/ScheduleCalendarTransp.php
deleted file mode 100644
index d9e295b..0000000
--- a/lib/CalDAV/Property/ScheduleCalendarTransp.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-use Sabre\DAV;
-use Sabre\CalDAV;
-
-/**
- * schedule-calendar-transp property.
- *
- * This property is a representation of the schedule-calendar-transp property.
- * This property is defined in RFC6638 (caldav scheduling).
- *
- * Its values are either 'transparent' or 'opaque'. If it's transparent, it
- * means that this calendar will not be taken into consideration when a
- * different user queries for free-busy information. If it's 'opaque', it will.
- *
- * @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 ScheduleCalendarTransp extends DAV\Property {
-
-    const TRANSPARENT = 'transparent';
-    const OPAQUE = 'opaque';
-
-    protected $value;
-
-    /**
-     * Creates the property
-     *
-     * @param string $value
-     */
-    function __construct($value) {
-
-        if ($value !== self::TRANSPARENT && $value !== self::OPAQUE) {
-            throw new \InvalidArgumentException('The value must either be specified as "transparent" or "opaque"');
-        }
-        $this->value = $value;
-
-    }
-
-    /**
-     * Returns the current value
-     *
-     * @return string
-     */
-    function getValue() {
-
-        return $this->value;
-
-    }
-
-    /**
-     * 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;
-        switch($this->value) {
-            case self::TRANSPARENT :
-                $xval = $doc->createElement('cal:transparent');
-                break;
-            case self::OPAQUE :
-                $xval = $doc->createElement('cal:opaque');
-                break;
-        }
-
-        $node->appendChild($xval);
-
-    }
-
-    /**
-     * Unserializes the DOMElement back into a Property class.
-     *
-     * @param \DOMElement $node
-     * @param array $propertyMap
-     * @return ScheduleCalendarTransp
-     */
-    static function unserialize(\DOMElement $node, array $propertyMap) {
-
-        $value = null;
-        foreach($node->childNodes as $childNode) {
-            switch(DAV\XMLUtil::toClarkNotation($childNode)) {
-                case '{' . CalDAV\Plugin::NS_CALDAV . '}opaque' :
-                    $value = self::OPAQUE;
-                    break;
-                case '{' . CalDAV\Plugin::NS_CALDAV . '}transparent' :
-                    $value = self::TRANSPARENT;
-                    break;
-            }
-        }
-        if (is_null($value))
-           return null;
-
-        return new self($value);
-
-    }
-}
diff --git a/lib/CalDAV/Property/SupportedCalendarComponentSet.php b/lib/CalDAV/Property/SupportedCalendarComponentSet.php
deleted file mode 100644
index c4151cc..0000000
--- a/lib/CalDAV/Property/SupportedCalendarComponentSet.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-use Sabre\DAV;
-use Sabre\CalDAV;
-
-/**
- * Supported component set property
- *
- * This property is a representation of the supported-calendar_component-set
- * property in the CalDAV namespace. It simply requires an array of components,
- * such as VEVENT, VTODO
- *
- * @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 SupportedCalendarComponentSet extends DAV\Property {
-
-    /**
-     * List of supported components, such as "VEVENT, VTODO"
-     *
-     * @var array
-     */
-    private $components;
-
-    /**
-     * Creates the property
-     *
-     * @param array $components
-     */
-    function __construct(array $components) {
-
-        $this->components = $components;
-
-    }
-
-    /**
-     * Returns the list of supported components
-     *
-     * @return array
-     */
-    function getValue() {
-
-        return $this->components;
-
-    }
-
-    /**
-     * 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;
-        foreach($this->components as $component) {
-
-            $xcomp = $doc->createElement('cal:comp');
-            $xcomp->setAttribute('name',$component);
-            $node->appendChild($xcomp);
-
-        }
-
-    }
-
-    /**
-     * Unserializes the DOMElement back into a Property class.
-     *
-     * @param \DOMElement $node
-     * @param array $propertyMap
-     * @return Property_SupportedCalendarComponentSet
-     */
-    static function unserialize(\DOMElement $node, array $propertyMap) {
-
-        $components = array();
-        foreach($node->childNodes as $childNode) {
-            if (DAV\XMLUtil::toClarkNotation($childNode)==='{' . CalDAV\Plugin::NS_CALDAV . '}comp') {
-                $components[] = $childNode->getAttribute('name');
-            }
-        }
-        return new self($components);
-
-    }
-
-}
diff --git a/lib/CalDAV/Property/SupportedCalendarData.php b/lib/CalDAV/Property/SupportedCalendarData.php
deleted file mode 100644
index 3fbae79..0000000
--- a/lib/CalDAV/Property/SupportedCalendarData.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-use Sabre\DAV;
-use Sabre\CalDAV\Plugin;
-
-/**
- * Supported-calendar-data property
- *
- * This property is a representation of the supported-calendar-data property
- * in the CalDAV namespace. SabreDAV only has support for text/calendar;2.0
- * so the value is currently hardcoded.
- *
- * @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 SupportedCalendarData extends DAV\Property {
-
-    /**
-     * 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[Plugin::NS_CALDAV])?$server->xmlNamespaces[Plugin::NS_CALDAV]:'cal';
-
-        $caldata = $doc->createElement($prefix . ':calendar-data');
-        $caldata->setAttribute('content-type','text/calendar');
-        $caldata->setAttribute('version','2.0');
-        $node->appendChild($caldata);
-
-        $caldata = $doc->createElement($prefix . ':calendar-data');
-        $caldata->setAttribute('content-type','application/calendar+json');
-        $node->appendChild($caldata);
-
-    }
-
-}
diff --git a/lib/CalDAV/Property/SupportedCollationSet.php b/lib/CalDAV/Property/SupportedCollationSet.php
deleted file mode 100644
index ef61ce7..0000000
--- a/lib/CalDAV/Property/SupportedCollationSet.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-use Sabre\DAV;
-
-/**
- * supported-collation-set property
- *
- * This property is a representation of the supported-collation-set property
- * in the CalDAV 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:caldav');
-        if (!$prefix) $prefix = 'cal';
-
-        $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/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index 7ff24a1..3e229b6 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -19,7 +19,7 @@ use
     Sabre\DAVACL,
     Sabre\CalDAV\ICalendar,
     Sabre\CalDAV\ICalendarObject,
-    Sabre\CalDAV\Property\ScheduleCalendarTransp,
+    Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp,
     Sabre\DAV\Exception\NotFound,
     Sabre\DAV\Exception\Forbidden,
     Sabre\DAV\Exception\BadRequest,
diff --git a/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php b/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php
index 726934a..a7652e5 100644
--- a/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php
+++ b/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php
@@ -94,8 +94,8 @@ class SupportedCalendarComponentSet 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();
diff --git a/lib/CalDAV/Xml/Property/SupportedCalendarData.php b/lib/CalDAV/Xml/Property/SupportedCalendarData.php
index 517646d..282110f 100644
--- a/lib/CalDAV/Xml/Property/SupportedCalendarData.php
+++ b/lib/CalDAV/Xml/Property/SupportedCalendarData.php
@@ -2,12 +2,10 @@
 
 namespace Sabre\CalDAV\Xml\Property;
 
-use
-    Sabre\Xml\Element,
-    Sabre\Xml\Reader,
-    Sabre\Xml\Writer,
-    Sabre\DAV\Exception\CannotDeserialize,
-    Sabre\CalDAV\Plugin;
+use Sabre\Xml\XmlSerializable;
+use Sabre\Xml\Reader;
+use Sabre\Xml\Writer;
+use Sabre\CalDAV\Plugin;
 
 /**
  * Supported-calendar-data property
@@ -23,24 +21,28 @@ use
  * @author Evert Pot (http://www.rooftopsolutions.nl/)
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-class SupportedCalendarData implements Element {
+class SupportedCalendarData implements XmlSerializable {
 
     /**
-     * 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) {
 
         $writer->startElement('{' . Plugin::NS_CALDAV . '}calendar-data');
         $writer->writeAttributes([
@@ -48,33 +50,12 @@ class SupportedCalendarData implements Element {
             'version' => '2.0',
         ]);
         $writer->endElement(); // calendar-data
+        $writer->startElement('{' . Plugin::NS_CALDAV . '}calendar-data');
+        $writer->writeAttributes([
+            'content-type' => 'application/calendar+json',
+        ]);
+        $writer->endElement(); // calendar-data
 
     }
 
-    /**
-     * 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/CalDAV/Xml/Property/SupportedCollationSet.php b/lib/CalDAV/Xml/Property/SupportedCollationSet.php
index e7a5be2..990784f 100644
--- a/lib/CalDAV/Xml/Property/SupportedCollationSet.php
+++ b/lib/CalDAV/Xml/Property/SupportedCollationSet.php
@@ -2,12 +2,10 @@
 
 namespace Sabre\CalDAV\Xml\Property;
 
-use
-    Sabre\Xml\Element,
-    Sabre\Xml\Reader,
-    Sabre\Xml\Writer,
-    Sabre\DAV\Exception\CannotDeserialize,
-    Sabre\CalDAV\Plugin;
+use Sabre\Xml\Reader;
+use Sabre\Xml\Writer;
+use Sabre\Xml\XmlSerializable;
+use Sabre\CalDAV\Plugin;
 
 /**
  * supported-collation-set property
@@ -19,27 +17,31 @@ use
  * http://tools.ietf.org/html/rfc4791#section-7.5.1
  *
  * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://www.rooftopsolutions.nl/)
- * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
  */
-class SupportedCollationSet implements Element {
+class SupportedCollationSet implements XmlSerializable {
 
     /**
-     * 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) {
 
         $collations = [
             'i;ascii-casemap',
@@ -53,31 +55,4 @@ class SupportedCollationSet 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/tests/Sabre/CalDAV/Backend/Mock.php b/tests/Sabre/CalDAV/Backend/Mock.php
index 8551c39..ea9384c 100644
--- a/tests/Sabre/CalDAV/Backend/Mock.php
+++ b/tests/Sabre/CalDAV/Backend/Mock.php
@@ -69,12 +69,12 @@ class Mock extends AbstractBackend {
     function createCalendar($principalUri,$calendarUri,array $properties) {
 
         $id = DAV\UUIDUtil::getUUID();
-        $this->calendars[] = array_merge(array(
+        $this->calendars[] = array_merge([
             'id' => $id,
             'principaluri' => $principalUri,
             'uri' => $calendarUri,
-            '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
-        ), $properties);
+            '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT','VTODO']),
+        ], $properties);
 
         return $id;
 
diff --git a/tests/Sabre/CalDAV/PluginTest.php b/tests/Sabre/CalDAV/PluginTest.php
index 415ba31..a840742 100644
--- a/tests/Sabre/CalDAV/PluginTest.php
+++ b/tests/Sabre/CalDAV/PluginTest.php
@@ -5,22 +5,19 @@ use Sabre\DAVACL;
 use Sabre\DAV;
 use Sabre\HTTP;
 
-require_once 'Sabre/HTTP/ResponseMock.php';
-require_once 'Sabre/CalDAV/TestUtil.php';
-
 class PluginTest extends \PHPUnit_Framework_TestCase {
 
     /**
-     * @var Sabre\DAV\Server
+     * @var DAV\Server
      */
     protected $server;
     /**
-     * @var Sabre\CalDAV\Plugin
+     * @var Plugin
      */
     protected $plugin;
     protected $response;
     /**
-     * @var Sabre\CalDAV\Backend\PDO
+     * @var Backend\PDO
      */
     protected $caldavBackend;
 
@@ -35,7 +32,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
                 '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description',
                 '{http://apple.com/ns/ical/}calendar-order' => '1',
                 '{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
-                '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
+                '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT','VTODO']),
             ),
             array(
                 'id' => 2,
@@ -45,7 +42,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
                 '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description',
                 '{http://apple.com/ns/ical/}calendar-order' => '1',
                 '{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
-                '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
+                '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT','VTODO']),
             )
         ), array(
             1 => array(
@@ -422,7 +419,7 @@ END:VCALENDAR';
 
         }
         $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
-        $this->assertTrue($newCalendar[$sccs] instanceof Property\SupportedCalendarComponentSet);
+        $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet);
         $this->assertEquals(array('VEVENT','VTODO'),$newCalendar[$sccs]->getValue());
 
     }
diff --git a/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php b/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php
deleted file mode 100644
index fd2a7a1..0000000
--- a/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class SupportedCalendarDataTest extends \PHPUnit_Framework_TestCase {
-
-    function testSimple() {
-
-        $sccs = new SupportedCalendarData();
-        $this->assertInstanceOf('Sabre\CalDAV\Property\SupportedCalendarData', $sccs);
-
-    }
-
-    /**
-     * @depends testSimple
-     */
-    function testSerialize() {
-
-        $property = new SupportedCalendarData();
-
-        $doc = new \DOMDocument();
-        $root = $doc->createElement('d:root');
-        $root->setAttribute('xmlns:d','DAV:');
-        $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV);
-
-        $doc->appendChild($root);
-        $server = new DAV\Server();
-
-        $property->serialize($server, $root);
-
-        $xml = $doc->saveXML();
-
-        $this->assertEquals(
-'<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">' .
-'<cal:calendar-data content-type="text/calendar" version="2.0"/>' .
-'<cal:calendar-data content-type="application/calendar+json"/>' .
-'</d:root>
-', $xml);
-
-    }
-
-}
diff --git a/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php b/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php
deleted file mode 100644
index be95ed6..0000000
--- a/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class SupportedCollationSetTest extends \PHPUnit_Framework_TestCase {
-
-    function testSimple() {
-
-        $scs = new SupportedCollationSet();
-        $this->assertInstanceOf('Sabre\CalDAV\Property\SupportedCollationSet', $scs);
-
-    }
-
-    /**
-     * @depends testSimple
-     */
-    function testSerialize() {
-
-        $property = new SupportedCollationSet();
-
-        $doc = new \DOMDocument();
-        $root = $doc->createElement('d:root');
-        $root->setAttribute('xmlns:d','DAV:');
-        $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV);
-
-        $doc->appendChild($root);
-        $server = new DAV\Server();
-
-        $property->serialize($server, $root);
-
-        $xml = $doc->saveXML();
-
-        $this->assertEquals(
-'<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">' .
-'<cal:supported-collation>i;ascii-casemap</cal:supported-collation>' .
-'<cal:supported-collation>i;octet</cal:supported-collation>' .
-'<cal:supported-collation>i;unicode-casemap</cal:supported-collation>' .
-'</d:root>
-', $xml);
-
-    }
-
-}
diff --git a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
index 64234c0..d2bb515 100644
--- a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
+++ b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
@@ -7,7 +7,7 @@ use
     Sabre\DAVACL,
     Sabre\HTTP,
     Sabre\CalDAV,
-    Sabre\CalDAV\Property\ScheduleCalendarTransp;
+    Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp;
 
 class FreeBusyRequestTest extends \PHPUnit_Framework_TestCase {
 
@@ -20,22 +20,22 @@ class FreeBusyRequestTest extends \PHPUnit_Framework_TestCase {
 
     function setUp() {
 
-        $calendars = array(
-            array(
+        $calendars = [
+            [
                 'principaluri' => 'principals/user2',
                 'id'           => 1,
                 'uri'          => 'calendar1',
                 '{' . CalDAV\Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR",
-            ),
-            array(
+            ],
+            [
                 'principaluri' => 'principals/user2',
                 'id'           => 2,
                 'uri'          => 'calendar2',
                 '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp(ScheduleCalendarTransp::TRANSPARENT),
-            ),
-        );
-        $calendarobjects = array(
-            1 => array( '1.ics' => array(
+            ],
+        ];
+        $calendarobjects = [
+            1 => [ '1.ics' => [
                 'uri' => '1.ics',
                 'calendardata' => 'BEGIN:VCALENDAR
 BEGIN:VEVENT
@@ -44,8 +44,8 @@ DURATION:PT1H
 END:VEVENT
 END:VCALENDAR',
                 'calendarid' => 1,
-            )),
-            2 => array( '2.ics' => array(
+            ]],
+            2 => [ '2.ics' => [
                 'uri' => '2.ics',
                 'calendardata' => 'BEGIN:VCALENDAR
 BEGIN:VEVENT
@@ -54,17 +54,17 @@ DURATION:PT1H
 END:VEVENT
 END:VCALENDAR',
                 'calendarid' => 2,
-            ))
+            ]]
 
-        );
+        ];
 
         $principalBackend = new DAVACL\PrincipalBackend\Mock();
         $this->caldavBackend = new CalDAV\Backend\MockScheduling($calendars, $calendarobjects);
 
-        $tree = array(
+        $tree = [
             new DAVACL\PrincipalCollection($principalBackend),
             new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend),
-        );
+        ];
 
         $this->request = HTTP\Sapi::createFromServerArray([
             'CONTENT_TYPE' => 'text/calendar',
diff --git a/tests/Sabre/CalDAV/ValidateICalTest.php b/tests/Sabre/CalDAV/ValidateICalTest.php
index 4cebba0..be166d9 100644
--- a/tests/Sabre/CalDAV/ValidateICalTest.php
+++ b/tests/Sabre/CalDAV/ValidateICalTest.php
@@ -26,22 +26,22 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
                 'id' => 'calendar1',
                 'principaluri' => 'principals/admin',
                 'uri' => 'calendar1',
-                '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet( array('VEVENT','VTODO','VJOURNAL') ),
+                '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet( ['VEVENT','VTODO','VJOURNAL'] ),
             ),
             array(
                 'id' => 'calendar2',
                 'principaluri' => 'principals/admin',
                 'uri' => 'calendar2',
-                '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet( array('VTODO','VJOURNAL') ),
+                '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet( ['VTODO','VJOURNAL'] ),
             )
         );
 
-        $this->calBackend = new Backend\Mock($calendars,array());
+        $this->calBackend = new Backend\Mock($calendars, []);
         $principalBackend = new DAVACL\PrincipalBackend\Mock();
 
-        $tree = array(
+        $tree = [
             new CalendarRoot($principalBackend, $this->calBackend),
-        );
+        ];
 
         $this->server = new DAV\Server($tree);
         $this->server->sapi = new HTTP\SapiMock();
diff --git a/tests/Sabre/CalDAV/Xml/Property/SupportedCalendarDataTest.php b/tests/Sabre/CalDAV/Xml/Property/SupportedCalendarDataTest.php
new file mode 100644
index 0000000..442b6a0
--- /dev/null
+++ b/tests/Sabre/CalDAV/Xml/Property/SupportedCalendarDataTest.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Sabre\CalDAV\Xml\Property;
+
+use Sabre\CalDAV;
+use Sabre\DAV;
+
+class SupportedCalendarDataTest extends DAV\Xml\XmlTest {
+
+    function testSimple() {
+
+        $sccs = new SupportedCalendarData();
+        $this->assertInstanceOf('Sabre\CalDAV\Xml\Property\SupportedCalendarData', $sccs);
+
+    }
+
+    /**
+     * @depends testSimple
+     */
+    function testSerialize() {
+
+        $this->namespaceMap[CalDAV\Plugin::NS_CALDAV] = 'cal';
+        $property = new SupportedCalendarData();
+
+        $xml = $this->write(['{DAV:}root' => $property]);
+
+        $this->assertXmlStringEqualsXmlString(
+'<?xml version="1.0"?>
+<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">
+<cal:calendar-data content-type="text/calendar" version="2.0"/>
+<cal:calendar-data content-type="application/calendar+json"/>
+</d:root>', $xml);
+
+    }
+
+}
diff --git a/tests/Sabre/CalDAV/Xml/Property/SupportedCollationSetTest.php b/tests/Sabre/CalDAV/Xml/Property/SupportedCollationSetTest.php
new file mode 100644
index 0000000..e009fb6
--- /dev/null
+++ b/tests/Sabre/CalDAV/Xml/Property/SupportedCollationSetTest.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Sabre\CalDAV\Xml\Property;
+
+use Sabre\CalDAV;
+use Sabre\DAV;
+
+class SupportedCollationSetTest extends DAV\Xml\XmlTest {
+
+    function testSimple() {
+
+        $scs = new SupportedCollationSet();
+        $this->assertInstanceOf('Sabre\CalDAV\Xml\Property\SupportedCollationSet', $scs);
+
+    }
+
+    /**
+     * @depends testSimple
+     */
+    function testSerialize() {
+
+        $property = new SupportedCollationSet();
+
+        $this->namespaceMap[CalDAV\Plugin::NS_CALDAV] = 'cal';
+        $xml = $this->write(['{DAV:}root' => $property]);
+
+        $this->assertXmlStringEqualsXmlString(
+'<?xml version="1.0"?>
+<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">
+<cal:supported-collation>i;ascii-casemap</cal:supported-collation>
+<cal:supported-collation>i;octet</cal:supported-collation>
+<cal:supported-collation>i;unicode-casemap</cal: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