summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2017-01-25 12:22:09 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-03-20 01:43:24 -0600
commita4ce4403926fd314a68ec6cd099cfecc54b5ddfc (patch)
treea918de5e42e296314b180630463190d0273787f5 /apps/files_sharing/tests
parent528a903a7b23ea628e6ec2fc9a221821297c0bec (diff)
downloadnextcloud-server-a4ce4403926fd314a68ec6cd099cfecc54b5ddfc.tar.gz
nextcloud-server-a4ce4403926fd314a68ec6cd099cfecc54b5ddfc.zip
Ignore NoUserException for shares from ghosts
Add unit tests for FailedStorage init from SharedStorage Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/SharedStorageTest.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php
index eaa138b0f70..ad6243c46b1 100644
--- a/apps/files_sharing/tests/SharedStorageTest.php
+++ b/apps/files_sharing/tests/SharedStorageTest.php
@@ -28,6 +28,11 @@
namespace OCA\Files_Sharing\Tests;
+use OCA\Files_Sharing\SharedStorage;
+use OCP\Share\IShare;
+use OC\Files\View;
+use OCP\Files\NotFoundException;
+
/**
* Class SharedStorageTest
*
@@ -559,4 +564,37 @@ class SharedStorageTest extends TestCase {
$this->shareManager->deleteShare($share);
}
+
+ public function testInitWithNonExistingUser() {
+ $share = $this->createMock(IShare::class);
+ $share->method('getShareOwner')->willReturn('unexist');
+ $ownerView = $this->createMock(View::class);
+ $storage = new SharedStorage([
+ 'ownerView' => $ownerView,
+ 'superShare' => $share,
+ 'groupedShares' => [$share],
+ 'user' => 'user1',
+ ]);
+
+ // trigger init
+ $this->assertInstanceOf(\OC\Files\Cache\FailedCache::class, $storage->getCache());
+ $this->assertInstanceOf(\OC\Files\Storage\FailedStorage::class, $storage->getSourceStorage());
+ }
+
+ public function testInitWithNotFoundSource() {
+ $share = $this->createMock(IShare::class);
+ $share->method('getShareOwner')->willReturn(self::TEST_FILES_SHARING_API_USER1);
+ $ownerView = $this->createMock(View::class);
+ $ownerView->method('getPath')->will($this->throwException(new NotFoundException()));
+ $storage = new SharedStorage([
+ 'ownerView' => $ownerView,
+ 'superShare' => $share,
+ 'groupedShares' => [$share],
+ 'user' => 'user1',
+ ]);
+
+ // trigger init
+ $this->assertInstanceOf(\OC\Files\Cache\FailedCache::class, $storage->getCache());
+ $this->assertInstanceOf(\OC\Files\Storage\FailedStorage::class, $storage->getSourceStorage());
+ }
}