aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/sharedmount.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-09-29 11:13:01 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-09-29 11:13:06 +0200
commite5f0dded84a544f4ebd983ef8fb6d898df230575 (patch)
tree4923a044815e33a645b219d852a8ea16185fcf7a /apps/files_sharing/tests/sharedmount.php
parent2a4da7fe09825a2b94d63edec8985590ad7226e1 (diff)
downloadnextcloud-server-e5f0dded84a544f4ebd983ef8fb6d898df230575.tar.gz
nextcloud-server-e5f0dded84a544f4ebd983ef8fb6d898df230575.zip
throw a exception if we can't handle the provided path
Diffstat (limited to 'apps/files_sharing/tests/sharedmount.php')
-rw-r--r--apps/files_sharing/tests/sharedmount.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/sharedmount.php b/apps/files_sharing/tests/sharedmount.php
index f8c65734184..ac910944f9f 100644
--- a/apps/files_sharing/tests/sharedmount.php
+++ b/apps/files_sharing/tests/sharedmount.php
@@ -194,4 +194,41 @@ class Test_Files_Sharing_Mount extends Test_Files_Sharing_Base {
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
}
+ /**
+ * @dataProvider dataProviderTestStripUserFilesPath
+ * @param string $path
+ * @param string $expectedResult
+ * @param bool $exception if a exception is expected
+ */
+ function testStripUserFilesPath($path, $expectedResult, $exception) {
+ $testClass = new DummyTestClassSharedMount(null, null);
+ try {
+ $result = $testClass->stripUserFilesPathDummy($path);
+ $this->assertSame($expectedResult, $result);
+ } catch (\Exception $e) {
+ if ($exception) {
+ $this->assertSame(10, $e->getCode());
+ } else {
+ $this->assertTrue(false, "Exception catched, but expected: " . $expectedResult);
+ }
+ }
+ }
+
+ function dataProviderTestStripUserFilesPath() {
+ return array(
+ array('/user/files/foo.txt', '/foo.txt', false),
+ array('/user/files/folder/foo.txt', '/folder/foo.txt', false),
+ array('/data/user/files/foo.txt', null, true),
+ array('/data/user/files/', null, true),
+ array('/files/foo.txt', null, true),
+ array('/foo.txt', null, true),
+ );
+ }
+
+}
+
+class DummyTestClassSharedMount extends \OCA\Files_Sharing\SharedMount {
+ public function stripUserFilesPathDummy($path) {
+ return $this->stripUserFilesPath($path);
+ }
}