Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use INode instead of Node for custom properties
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and rullzer committed Mar 18, 2020
commit 451c8761a710c62bc19b75ceba9de670b95aca9e
11 changes: 6 additions & 5 deletions apps/dav/lib/DAV/CustomPropertiesBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
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;
Expand Down Expand Up @@ -103,7 +104,7 @@ public function __construct(
public function propFind($path, PropFind $propFind) {
try {
$node = $this->tree->getNodeForPath($path);
if (!($node instanceof Node)) {
if (!($node instanceof INode)) {
return;
}
} catch (ServiceUnavailable $e) {
Expand Down Expand Up @@ -168,7 +169,7 @@ public function propFind($path, PropFind $propFind) {
*/
public function propPatch($path, PropPatch $propPatch) {
$node = $this->tree->getNodeForPath($path);
if (!($node instanceof Node)) {
if (!($node instanceof INode)) {
return;
}

Expand Down Expand Up @@ -220,7 +221,7 @@ public function move($source, $destination) {
* 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];
Expand Down Expand Up @@ -259,12 +260,12 @@ private function getProperties(Node $node, array $requestedProperties) {
/**
* 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`' .
Expand Down
15 changes: 14 additions & 1 deletion apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -82,9 +83,21 @@ protected function setUp(): void {

/**
* @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);
Expand Down