From 451c8761a710c62bc19b75ceba9de670b95aca9e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 3 Feb 2020 13:23:40 +0100 Subject: [PATCH] use INode instead of Node for custom properties Signed-off-by: Robin Appelman --- apps/dav/lib/DAV/CustomPropertiesBackend.php | 11 ++++++----- .../unit/DAV/CustomPropertiesBackendTest.php | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/apps/dav/lib/DAV/CustomPropertiesBackend.php b/apps/dav/lib/DAV/CustomPropertiesBackend.php index 5a0128e52c..5e0842200b 100644 --- a/apps/dav/lib/DAV/CustomPropertiesBackend.php +++ b/apps/dav/lib/DAV/CustomPropertiesBackend.php @@ -32,6 +32,7 @@ use OCP\IDBConnection; use OCP\IUser; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\Exception\ServiceUnavailable; +use Sabre\DAV\INode; use Sabre\DAV\PropertyStorage\Backend\BackendInterface; use Sabre\DAV\PropFind; use Sabre\DAV\PropPatch; @@ -103,7 +104,7 @@ class CustomPropertiesBackend implements BackendInterface { public function propFind($path, PropFind $propFind) { try { $node = $this->tree->getNodeForPath($path); - if (!($node instanceof Node)) { + if (!($node instanceof INode)) { return; } } catch (ServiceUnavailable $e) { @@ -168,7 +169,7 @@ class CustomPropertiesBackend implements BackendInterface { */ public function propPatch($path, PropPatch $propPatch) { $node = $this->tree->getNodeForPath($path); - if (!($node instanceof Node)) { + if (!($node instanceof INode)) { return; } @@ -220,7 +221,7 @@ class CustomPropertiesBackend implements BackendInterface { * http://www.example.org/namespace#author If the array is empty, all * properties should be returned */ - private function getProperties(Node $node, array $requestedProperties) { + private function getProperties(INode $node, array $requestedProperties) { $path = $node->getPath(); if (isset($this->cache[$path])) { return $this->cache[$path]; @@ -259,12 +260,12 @@ class CustomPropertiesBackend implements BackendInterface { /** * Update properties * - * @param Node $node node for which to update properties + * @param INode $node node for which to update properties * @param array $properties array of properties to update * * @return bool */ - private function updateProperties($node, $properties) { + private function updateProperties(INode $node, array $properties) { $path = $node->getPath(); $deleteStatement = 'DELETE FROM `*PREFIX*properties`' . diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php index 3250361ed1..9f0fbdc3a0 100644 --- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php @@ -29,6 +29,7 @@ use OCA\DAV\DAV\CustomPropertiesBackend; use OCP\IDBConnection; use OCP\IUser; use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\INode; use Sabre\DAV\PropFind; use Sabre\DAV\PropPatch; use Sabre\DAV\Tree; @@ -82,9 +83,21 @@ class CustomPropertiesBackendTest extends TestCase { /** * @param string $path - * @return Node|\PHPUnit\Framework\MockObject\MockObject + * @return INode|\PHPUnit\Framework\MockObject\MockObject */ private function addNode($path) { + $node = $this->createMock(INode::class); + $node->method('getPath') + ->willReturn($path); + $this->nodes[$path] = $node; + return $node; + } + + /** + * @param string $path + * @return Node|\PHPUnit\Framework\MockObject\MockObject + */ + private function addCalendar($path) { $node = $this->createMock(Node::class); $node->method('getPath') ->willReturn($path);