From 7fd96c2275a0e412affca1e72576a2feb2251033 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 6 Feb 2023 18:56:54 +0100 Subject: [PATCH] fix tests Signed-off-by: Robin Appelman --- lib/private/Files/Mount/MountPoint.php | 12 ++++++++++-- tests/lib/Files/ViewTest.php | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 67601f016be7c..7c0282e16b98f 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -200,7 +200,11 @@ public function getStorage() { */ public function getStorageId() { if (!$this->storageId) { - $this->storageId = $this->getStorage()->getId(); + $storage = $this->getStorage(); + if (is_null($storage)) { + return null; + } + $this->storageId = $storage->getId(); if (strlen($this->storageId) > 64) { $this->storageId = md5($this->storageId); } @@ -213,7 +217,11 @@ public function getStorageId() { */ public function getNumericStorageId() { if (is_null($this->numericStorageId)) { - $this->numericStorageId = $this->getStorage()->getStorageCache()->getNumericId(); + $storage = $this->getStorage(); + if (is_null($storage)) { + return null; + } + $this->numericStorageId = $storage->getStorageCache()->getNumericId(); } return $this->numericStorageId; } diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 2189e7c09f431..95d9a8e3051eb 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -1590,6 +1590,9 @@ private function createTestMovableMountPoints($mountPoints) { ->setConstructorArgs([[]]) ->getMock(); $storage->method('getId')->willReturn('non-null-id'); + $storage->method('getStorageCache')->willReturnCallback(function () use ($storage) { + return new \OC\Files\Cache\Storage($storage); + }); $mounts[] = $this->getMockBuilder(TestMoveableMountPoint::class) ->setMethods(['moveMount'])