summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-02-09 15:01:12 +0100
committerRobin Appelman <icewind@owncloud.com>2016-02-09 15:03:00 +0100
commitacd8c72d3dc25787950de8d1d7b8e735eff7b28f (patch)
tree9debbdc193e953564d7763d295708f41b69c835e /apps
parent359c62d90ec5729541a4b97d0e7c9116abb409e9 (diff)
downloadnextcloud-server-acd8c72d3dc25787950de8d1d7b8e735eff7b28f.tar.gz
nextcloud-server-acd8c72d3dc25787950de8d1d7b8e735eff7b28f.zip
add tests
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/tests/controller/sharecontroller.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php
index 8eb9cb82842..6167b281fce 100644
--- a/apps/files_sharing/tests/controller/sharecontroller.php
+++ b/apps/files_sharing/tests/controller/sharecontroller.php
@@ -365,6 +365,55 @@ class ShareControllerTest extends \Test\TestCase {
$this->assertEquals($expectedResponse, $response);
}
+ /**
+ * @expectedException \OCP\Files\NotFoundException
+ */
+ public function testShowShareInvalid() {
+ $owner = $this->getMock('OCP\IUser');
+ $owner->method('getDisplayName')->willReturn('ownerDisplay');
+ $owner->method('getUID')->willReturn('ownerUID');
+
+ $file = $this->getMock('OCP\Files\File');
+ $file->method('getName')->willReturn('file1.txt');
+ $file->method('getMimetype')->willReturn('text/plain');
+ $file->method('getSize')->willReturn(33);
+ $file->method('isShareable')->willReturn(false);
+ $file->method('isReadable')->willReturn(true);
+
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(42);
+ $share->setPassword('password')
+ ->setShareOwner('ownerUID')
+ ->setNode($file)
+ ->setTarget('/file1.txt');
+
+ $this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
+ $this->session->method('get')->with('public_link_authenticated')->willReturn('42');
+
+ $this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
+
+ $this->config->method('getSystemValue')
+ ->willReturnMap(
+ [
+ ['max_filesize_animated_gifs_public_sharing', 10, 10],
+ ['enable_previews', true, true],
+ ]
+ );
+ $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
+ $shareTmpl['previewEnabled'] = $this->config->getSystemValue('enable_previews', true);
+
+ $this->shareManager
+ ->expects($this->once())
+ ->method('getShareByToken')
+ ->with('token')
+ ->willReturn($share);
+
+ $this->userManager->method('get')->with('ownerUID')->willReturn($owner);
+
+ $this->shareController->showShare('token');
+ }
+
+
public function testDownloadShare() {
$share = $this->getMock('\OCP\Share\IShare');
$share->method('getPassword')->willReturn('password');