[Pkg-owncloud-commits] [php-sabredav] 30/148: Removed old href, ihref properties.
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 e07aa7c294f112b54cbbab9f09f148b470616ff9
Author: Evert Pot <me at evertpot.com>
Date: Sun Feb 8 18:18:52 2015 -0500
Removed old href, ihref properties.
---
lib/CalDAV/Notifications/Plugin.php | 2 +-
lib/CalDAV/Subscriptions/Plugin.php | 3 -
lib/CalDAV/Subscriptions/Subscription.php | 2 +-
lib/DAV/Property/Href.php | 101 -----------------
lib/DAV/Property/IHref.php | 25 -----
tests/Sabre/CalDAV/Notifications/PluginTest.php | 2 +-
.../PluginPropertiesWithSharedCalendarTest.php | 2 +-
tests/Sabre/CalDAV/Subscriptions/PluginTest.php | 6 +-
.../CalDAV/Subscriptions/SubscriptionTest.php | 2 +-
tests/Sabre/DAV/Property/HrefTest.php | 119 ---------------------
tests/Sabre/DAV/XMLUtilTest.php | 22 ----
tests/Sabre/DAV/Xml/Property/HrefTest.php | 91 ++++++++++++++++
tests/Sabre/DAV/Xml/XmlTest.php | 3 +-
13 files changed, 101 insertions(+), 279 deletions(-)
diff --git a/lib/CalDAV/Notifications/Plugin.php b/lib/CalDAV/Notifications/Plugin.php
index 67a5cdb..34bd847 100644
--- a/lib/CalDAV/Notifications/Plugin.php
+++ b/lib/CalDAV/Notifications/Plugin.php
@@ -97,7 +97,7 @@ class Plugin extends ServerPlugin {
$propFind->handle('{' . self::NS_CALENDARSERVER . '}notification-URL', function() use ($principalUrl, $caldavPlugin) {
$notificationPath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl) . '/notifications/';
- return new DAV\Property\Href($notificationPath);
+ return new DAV\Xml\Property\Href($notificationPath);
});
diff --git a/lib/CalDAV/Subscriptions/Plugin.php b/lib/CalDAV/Subscriptions/Plugin.php
index a2ab78f..e71c026 100644
--- a/lib/CalDAV/Subscriptions/Plugin.php
+++ b/lib/CalDAV/Subscriptions/Plugin.php
@@ -36,9 +36,6 @@ class Plugin extends ServerPlugin {
$server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] =
'{http://calendarserver.org/ns/}subscribed';
- $server->propertyMap['{http://calendarserver.org/ns/}source'] =
- 'Sabre\\DAV\\Property\\Href';
-
$server->xml->elementMap['{http://calendarserver.org/ns/}source'] =
'Sabre\\DAV\\Xml\\Property\\Href';
diff --git a/lib/CalDAV/Subscriptions/Subscription.php b/lib/CalDAV/Subscriptions/Subscription.php
index c0b82f6..d94f4a2 100644
--- a/lib/CalDAV/Subscriptions/Subscription.php
+++ b/lib/CalDAV/Subscriptions/Subscription.php
@@ -4,7 +4,7 @@ namespace Sabre\CalDAV\Subscriptions;
use
Sabre\DAV\Collection,
- Sabre\DAV\Property\Href,
+ Sabre\DAV\Xml\Property\Href,
Sabre\DAV\PropPatch,
Sabre\DAV\Exception\MethodNotAllowed,
Sabre\DAVACL\IACL,
diff --git a/lib/DAV/Property/Href.php b/lib/DAV/Property/Href.php
deleted file mode 100644
index 5d04734..0000000
--- a/lib/DAV/Property/Href.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Property;
-
-use Sabre\DAV;
-use Sabre\HTTP\URLUtil;
-
-/**
- * Href property
- *
- * The href property represents a url within a {DAV:}href element.
- * This is used by many WebDAV extensions, but not really within the WebDAV core spec
- *
- * @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 Href extends DAV\Property implements IHref {
-
- /**
- * href
- *
- * @var string
- */
- private $href;
-
- /**
- * Automatically prefix the url with the server base directory
- *
- * @var bool
- */
- private $autoPrefix = true;
-
- /**
- * __construct
- *
- * @param string $href
- * @param bool $autoPrefix
- */
- function __construct($href, $autoPrefix = true) {
-
- $this->href = $href;
- $this->autoPrefix = $autoPrefix;
-
- }
-
- /**
- * Returns the uri
- *
- * @return string
- */
- function getHref() {
-
- return $this->href;
-
- }
-
- /**
- * Serializes this property.
- *
- * It will additionally prepend the href property with the server's base uri.
- *
- * @param DAV\Server $server
- * @param \DOMElement $dom
- * @return void
- */
- function serialize(DAV\Server $server, \DOMElement $dom) {
-
- $prefix = $server->xmlNamespaces['DAV:'];
- $elem = $dom->ownerDocument->createElement($prefix . ':href');
-
- if ($this->autoPrefix) {
- $value = $server->getBaseUri() . URLUtil::encodePath($this->href);
- } else {
- $value = $this->href;
- }
- $elem->appendChild($dom->ownerDocument->createTextNode($value));
-
- $dom->appendChild($elem);
-
- }
-
- /**
- * Unserializes this property from a DOM Element
- *
- * This method returns an instance of this class.
- * It will only decode {DAV:}href values. For non-compatible elements null will be returned.
- *
- * @param \DOMElement $dom
- * @param array $propertyMap
- * @return DAV\Property\Href
- */
- static function unserialize(\DOMElement $dom, array $propertyMap) {
-
- if ($dom->firstChild && DAV\XMLUtil::toClarkNotation($dom->firstChild)==='{DAV:}href') {
- return new self($dom->firstChild->textContent,false);
- }
-
- }
-
-}
diff --git a/lib/DAV/Property/IHref.php b/lib/DAV/Property/IHref.php
deleted file mode 100644
index 00a7c98..0000000
--- a/lib/DAV/Property/IHref.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Property;
-
-/**
- * IHref interface
- *
- * Any property implementing this interface can expose a related url.
- * This is used by certain subsystems to aquire more information about for example
- * the owner of a file
- *
- * @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 IHref {
-
- /**
- * getHref
- *
- * @return string
- */
- function getHref();
-
-}
diff --git a/tests/Sabre/CalDAV/Notifications/PluginTest.php b/tests/Sabre/CalDAV/Notifications/PluginTest.php
index f240955..2d52713 100644
--- a/tests/Sabre/CalDAV/Notifications/PluginTest.php
+++ b/tests/Sabre/CalDAV/Notifications/PluginTest.php
@@ -86,7 +86,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
$this->assertArrayHasKey('{'.Plugin::NS_CALENDARSERVER .'}notification-URL',$props[0][200]);
$prop = $props[0][200]['{'.Plugin::NS_CALENDARSERVER .'}notification-URL'];
- $this->assertTrue($prop instanceof DAV\Property\Href);
+ $this->assertTrue($prop instanceof DAV\Xml\Property\Href);
$this->assertEquals('calendars/user1/notifications/', $prop->getHref());
}
diff --git a/tests/Sabre/CalDAV/Schedule/PluginPropertiesWithSharedCalendarTest.php b/tests/Sabre/CalDAV/Schedule/PluginPropertiesWithSharedCalendarTest.php
index 6cdb65c..b20d817 100644
--- a/tests/Sabre/CalDAV/Schedule/PluginPropertiesWithSharedCalendarTest.php
+++ b/tests/Sabre/CalDAV/Schedule/PluginPropertiesWithSharedCalendarTest.php
@@ -19,7 +19,7 @@ class PluginPropertiesWithSharedCalendarTest extends \Sabre\DAVServerTest {
'principals/user1',
'shared',
[
- '{http://calendarserver.org/ns/}shared-url' => new DAV\Property\Href('calendars/user2/default/'),
+ '{http://calendarserver.org/ns/}shared-url' => new DAV\Xml\Property\Href('calendars/user2/default/'),
'{http://sabredav.org/ns}read-only' => false,
'{http://sabredav.org/ns}owner-principal' => 'principals/user2',
]
diff --git a/tests/Sabre/CalDAV/Subscriptions/PluginTest.php b/tests/Sabre/CalDAV/Subscriptions/PluginTest.php
index 2e11d9a..4f82cb5 100644
--- a/tests/Sabre/CalDAV/Subscriptions/PluginTest.php
+++ b/tests/Sabre/CalDAV/Subscriptions/PluginTest.php
@@ -18,8 +18,8 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
$server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription']
);
$this->assertEquals(
- 'Sabre\\DAV\\Property\\Href',
- $server->propertyMap['{http://calendarserver.org/ns/}source']
+ 'Sabre\\DAV\\Xml\\Property\\Href',
+ $server->xml->elementMap['{http://calendarserver.org/ns/}source']
);
$this->assertEquals(
@@ -29,7 +29,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
}
- public function testPropFind() {
+ function testPropFind() {
$propName = '{http://calendarserver.org/ns/}subscribed-strip-alarms';
$propFind = new PropFind('foo', [$propName]);
diff --git a/tests/Sabre/CalDAV/Subscriptions/SubscriptionTest.php b/tests/Sabre/CalDAV/Subscriptions/SubscriptionTest.php
index 2cbd912..832b3cf 100644
--- a/tests/Sabre/CalDAV/Subscriptions/SubscriptionTest.php
+++ b/tests/Sabre/CalDAV/Subscriptions/SubscriptionTest.php
@@ -2,7 +2,7 @@
namespace Sabre\CalDAV\Subscriptions;
-use Sabre\DAV\Property\Href;
+use Sabre\DAV\Xml\Property\Href;
use Sabre\DAV\PropPatch;
class SubscriptionTest extends \PHPUnit_Framework_TestCase {
diff --git a/tests/Sabre/DAV/Property/HrefTest.php b/tests/Sabre/DAV/Property/HrefTest.php
deleted file mode 100644
index 46886cd..0000000
--- a/tests/Sabre/DAV/Property/HrefTest.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Property;
-
-use Sabre\DAV;
-
-class HrefTest extends \PHPUnit_Framework_TestCase {
-
- function testConstruct() {
-
- $href = new Href('path');
- $this->assertEquals('path',$href->getHref());
-
- }
-
- function testSerialize() {
-
- $href = new Href('path');
- $this->assertEquals('path',$href->getHref());
-
- $doc = new \DOMDocument();
- $root = $doc->createElement('d:anything');
- $root->setAttribute('xmlns:d','DAV:');
-
- $doc->appendChild($root);
- $server = new DAV\Server();
- $server->setBaseUri('/bla/');
-
- $href->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<d:anything xmlns:d="DAV:"><d:href>/bla/path</d:href></d:anything>
-', $xml);
-
- }
-
- function testSerializeNoPrefix() {
-
- $href = new Href('path',false);
- $this->assertEquals('path',$href->getHref());
-
- $doc = new \DOMDocument();
- $root = $doc->createElement('d:anything');
- $root->setAttribute('xmlns:d','DAV:');
-
- $doc->appendChild($root);
- $server = new DAV\Server();
- $server->setBaseUri('/bla/');
-
- $href->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<d:anything xmlns:d="DAV:"><d:href>path</d:href></d:anything>
-', $xml);
-
- }
-
- function testUnserialize() {
-
- $xml = '<?xml version="1.0"?>
-<d:anything xmlns:d="urn:DAV"><d:href>/bla/path</d:href></d:anything>
-';
-
- $dom = new \DOMDocument();
- $dom->loadXML($xml);
-
- $href = Href::unserialize($dom->firstChild, array());
- $this->assertEquals('/bla/path',$href->getHref());
-
- }
-
- function testUnserializeIncompatible() {
-
- $xml = '<?xml version="1.0"?>
-<d:anything xmlns:d="urn:DAV"><d:href2>/bla/path</d:href2></d:anything>
-';
-
- $dom = new \DOMDocument();
- $dom->loadXML($xml);
-
- $href = Href::unserialize($dom->firstChild, array());
- $this->assertNull($href);
-
- }
-
- /**
- * This method tests if hrefs containing & are correctly encoded.
- */
- function testSerializeEntity() {
-
- $href = new Href('http://example.org/?a&b', false);
- $this->assertEquals('http://example.org/?a&b',$href->getHref());
-
- $doc = new \DOMDocument();
- $root = $doc->createElement('d:anything');
- $root->setAttribute('xmlns:d','DAV:');
-
- $doc->appendChild($root);
- $server = new DAV\Server();
- $server->setBaseUri('/bla/');
-
- $href->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<d:anything xmlns:d="DAV:"><d:href>http://example.org/?a&b</d:href></d:anything>
-', $xml);
-
- }
-
-}
diff --git a/tests/Sabre/DAV/XMLUtilTest.php b/tests/Sabre/DAV/XMLUtilTest.php
index 1d2bfd1..3a80fb0 100644
--- a/tests/Sabre/DAV/XMLUtilTest.php
+++ b/tests/Sabre/DAV/XMLUtilTest.php
@@ -236,28 +236,6 @@ class XMLUtilTest extends \PHPUnit_Framework_TestCase {
}
- function testParsePropertiesMapHref() {
-
- $xml='<?xml version="1.0"?>
-<root xmlns="DAV:">
- <prop>
- <displayname>Calendars</displayname>
- </prop>
- <prop>
- <someprop><href>http://sabredav.org/</href></someprop>
- </prop>
-</root>';
-
- $dom = XMLUtil::loadDOMDocument($xml);
- $properties = XMLUtil::parseProperties($dom->firstChild,array('{DAV:}someprop'=>'Sabre\\DAV\\Property\\Href'));
-
- $this->assertEquals(array(
- '{DAV:}displayname' => 'Calendars',
- '{DAV:}someprop' => new Property\Href('http://sabredav.org/',false),
- ), $properties);
-
- }
-
function testParseClarkNotation() {
$this->assertEquals(array(
diff --git a/tests/Sabre/DAV/Xml/Property/HrefTest.php b/tests/Sabre/DAV/Xml/Property/HrefTest.php
new file mode 100644
index 0000000..6a000c7
--- /dev/null
+++ b/tests/Sabre/DAV/Xml/Property/HrefTest.php
@@ -0,0 +1,91 @@
+<?php
+
+namespace Sabre\DAV\Xml\Property;
+
+use Sabre\DAV;
+use Sabre\DAV\Xml\XmlTest;
+
+class HrefTest extends XmlTest {
+
+ function testConstruct() {
+
+ $href = new Href('path');
+ $this->assertEquals('path',$href->getHref());
+
+ }
+
+ function testSerialize() {
+
+ $href = new Href('path');
+ $this->assertEquals('path',$href->getHref());
+
+ $this->baseUri = '/bla/';
+
+ $xml = $this->write(['{DAV:}anything' => $href]);
+
+ $this->assertXmlStringEqualsXmlString(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>/bla/path</d:href></d:anything>
+', $xml);
+
+ }
+
+ function testSerializeNoPrefix() {
+
+ $href = new Href('path',false);
+ $this->assertEquals('path',$href->getHref());
+
+ $xml = $this->write(['{DAV:}anything' => $href]);
+
+ $this->assertXmlStringEqualsXmlString(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>path</d:href></d:anything>
+', $xml);
+
+ }
+
+ function testUnserialize() {
+
+ $xml = '<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>/bla/path</d:href></d:anything>
+';
+
+ $result = $this->parse($xml, ['{DAV:}anything' => 'Sabre\\DAV\\Xml\\Property\\Href']);
+
+ $href = $result['value'];
+
+ $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $href);
+
+ $this->assertEquals('/bla/path',$href->getHref());
+
+ }
+
+ function testUnserializeIncompatible() {
+
+ $xml = '<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href2>/bla/path</d:href2></d:anything>
+';
+ $result = $this->parse($xml, ['{DAV:}anything' => 'Sabre\\DAV\\Xml\\Property\\Href']);
+ $href = $result['value'];
+ $this->assertNull($href);
+
+ }
+
+ /**
+ * This method tests if hrefs containing & are correctly encoded.
+ */
+ function testSerializeEntity() {
+
+ $href = new Href('http://example.org/?a&b', false);
+ $this->assertEquals('http://example.org/?a&b',$href->getHref());
+
+ $xml = $this->write(['{DAV:}anything' => $href]);
+
+ $this->assertXmlStringEqualsXmlString(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>http://example.org/?a&b</d:href></d:anything>
+', $xml);
+
+ }
+
+}
diff --git a/tests/Sabre/DAV/Xml/XmlTest.php b/tests/Sabre/DAV/Xml/XmlTest.php
index e2aea0b..bdd396c 100644
--- a/tests/Sabre/DAV/Xml/XmlTest.php
+++ b/tests/Sabre/DAV/Xml/XmlTest.php
@@ -8,11 +8,12 @@ use Sabre\Xml\Reader;
abstract class XmlTest extends \PHPUnit_Framework_TestCase {
protected $namespaceMap = ['DAV:' => 'd'];
+ protected $baseUri = '/';
function write($input) {
$writer = new Writer();
- $writer->baseUri = '/';
+ $writer->baseUri = $this->baseUri;
$writer->namespaceMap = $this->namespaceMap;
$writer->openMemory();
$writer->setIndent(true);
--
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