aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/ApiTest.php102
-rw-r--r--apps/files_sharing/tests/CacheTest.php209
-rw-r--r--apps/files_sharing/tests/CapabilitiesTest.php4
-rw-r--r--apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php1
-rw-r--r--apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php1
-rw-r--r--apps/files_sharing/tests/Controller/ExternalShareControllerTest.php1
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php161
-rw-r--r--apps/files_sharing/tests/Controller/ShareControllerTest.php292
-rw-r--r--apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php12
-rw-r--r--apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php5
-rw-r--r--apps/files_sharing/tests/EncryptedSizePropagationTest.php1
-rw-r--r--apps/files_sharing/tests/EtagPropagationTest.php3
-rw-r--r--apps/files_sharing/tests/ExpireSharesJobTest.php6
-rw-r--r--apps/files_sharing/tests/External/CacheTest.php16
-rw-r--r--apps/files_sharing/tests/External/ManagerTest.php4
-rw-r--r--apps/files_sharing/tests/ExternalStorageTest.php38
-rw-r--r--apps/files_sharing/tests/HelperTest.php2
-rw-r--r--apps/files_sharing/tests/LockingTest.php1
-rw-r--r--apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php3
-rw-r--r--apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php1
-rw-r--r--apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php25
-rw-r--r--apps/files_sharing/tests/Migration/SetPasswordColumnTest.php4
-rw-r--r--apps/files_sharing/tests/MountProviderTest.php85
-rw-r--r--apps/files_sharing/tests/PermissionsTest.php5
-rw-r--r--apps/files_sharing/tests/ShareTest.php21
-rw-r--r--apps/files_sharing/tests/SharedMountTest.php36
-rw-r--r--apps/files_sharing/tests/SharedStorageTest.php9
-rw-r--r--apps/files_sharing/tests/TestCase.php26
-rw-r--r--apps/files_sharing/tests/UnshareChildrenTest.php5
-rw-r--r--apps/files_sharing/tests/UpdaterTest.php6
-rw-r--r--apps/files_sharing/tests/WatcherTest.php17
31 files changed, 642 insertions, 460 deletions
diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php
index cbec30f375e..9e7d8e5c693 100644
--- a/apps/files_sharing/tests/ApiTest.php
+++ b/apps/files_sharing/tests/ApiTest.php
@@ -4,9 +4,11 @@
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Calviño Sánchez <danxuliu@gmail.com>
* @author Jan-Christoph Borchardt <hey@jancborchardt.net>
* @author Joas Schilling <coding@schilljs.com>
+ * @author Julius Härtl <jus@bitgrid.net>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Robin McCorkell <robin@mccorkell.me.uk>
@@ -52,9 +54,8 @@ use OCP\Share\IShare;
* TODO: convert to real intergration tests
*/
class ApiTest extends TestCase {
-
- const TEST_FOLDER_NAME = '/folder_share_api_test';
- const APP_NAME = 'files_sharing';
+ public const TEST_FOLDER_NAME = '/folder_share_api_test';
+ public const APP_NAME = 'files_sharing';
private static $tempStorage;
@@ -90,7 +91,7 @@ class ApiTest extends TestCase {
}
protected function tearDown(): void {
- if($this->view instanceof \OC\Files\View) {
+ if ($this->view instanceof \OC\Files\View) {
$this->view->unlink($this->filename);
$this->view->deleteAll($this->folder);
}
@@ -107,9 +108,9 @@ class ApiTest extends TestCase {
private function createOCS($userId) {
$l = $this->getMockBuilder(IL10N::class)->getMock();
$l->method('t')
- ->will($this->returnCallback(function($text, $parameters = []) {
+ ->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters);
- }));
+ });
$config = $this->createMock(IConfig::class);
$appManager = $this->createMock(IAppManager::class);
$serverContainer = $this->createMock(IServerContainer::class);
@@ -130,7 +131,7 @@ class ApiTest extends TestCase {
);
}
- function testCreateShareUserFile() {
+ public function testCreateShareUserFile() {
$this->setUp(); // for some reasons phpunit refuses to do this for us only for this test
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
@@ -148,7 +149,7 @@ class ApiTest extends TestCase {
$ocs->cleanup();
}
- function testCreateShareUserFolder() {
+ public function testCreateShareUserFolder() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
@@ -162,11 +163,10 @@ class ApiTest extends TestCase {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$ocs->deleteShare($data['id']);
$ocs->cleanup();
-
}
- function testCreateShareGroupFile() {
+ public function testCreateShareGroupFile() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
@@ -182,7 +182,7 @@ class ApiTest extends TestCase {
$ocs->cleanup();
}
- function testCreateShareGroupFolder() {
+ public function testCreateShareGroupFolder() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
@@ -196,7 +196,6 @@ class ApiTest extends TestCase {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$ocs->deleteShare($data['id']);
$ocs->cleanup();
-
}
public function testCreateShareLink() {
@@ -205,7 +204,9 @@ class ApiTest extends TestCase {
$ocs->cleanup();
$data = $result->getData();
- $this->assertEquals(1, $data['permissions']);
+ $this->assertEquals(\OCP\Constants::PERMISSION_READ |
+ \OCP\Constants::PERMISSION_SHARE,
+ $data['permissions']);
$this->assertEmpty($data['expiration']);
$this->assertTrue(is_string($data['token']));
@@ -230,7 +231,8 @@ class ApiTest extends TestCase {
\OCP\Constants::PERMISSION_READ |
\OCP\Constants::PERMISSION_CREATE |
\OCP\Constants::PERMISSION_UPDATE |
- \OCP\Constants::PERMISSION_DELETE,
+ \OCP\Constants::PERMISSION_DELETE |
+ \OCP\Constants::PERMISSION_SHARE,
$data['permissions']
);
$this->assertEmpty($data['expiration']);
@@ -247,8 +249,7 @@ class ApiTest extends TestCase {
$ocs->cleanup();
}
- function testEnforceLinkPassword() {
-
+ public function testEnforceLinkPassword() {
$password = md5(time());
$config = \OC::$server->getConfig();
$config->setAppValue('core', 'shareapi_enforce_links_password', 'yes');
@@ -258,7 +259,6 @@ class ApiTest extends TestCase {
$ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
$this->fail();
} catch (OCSForbiddenException $e) {
-
}
$ocs->cleanup();
@@ -267,7 +267,6 @@ class ApiTest extends TestCase {
$ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '');
$this->fail();
} catch (OCSForbiddenException $e) {
-
}
$ocs->cleanup();
@@ -289,7 +288,6 @@ class ApiTest extends TestCase {
$ocs->updateShare($data['id']);
$this->fail();
} catch (OCSBadRequestException $e) {
-
}
$ocs->cleanup();
@@ -304,8 +302,8 @@ class ApiTest extends TestCase {
/**
* @medium
- */
- function testSharePermissions() {
+ */
+ public function testSharePermissions() {
// sharing file to a user should work if shareapi_exclude_groups is set
// to no
\OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no');
@@ -356,7 +354,7 @@ class ApiTest extends TestCase {
/**
* @medium
*/
- function testGetAllShares() {
+ public function testGetAllShares() {
$node = $this->userFolder->get($this->filename);
$share = $this->shareManager->newShare();
@@ -377,7 +375,7 @@ class ApiTest extends TestCase {
$this->shareManager->deleteShare($share);
}
- function testGetAllSharesWithMe() {
+ public function testGetAllSharesWithMe() {
$node1 = $this->userFolder->get($this->filename);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -413,7 +411,7 @@ class ApiTest extends TestCase {
/**
* @medium
*/
- function testPublicLinkUrl() {
+ public function testPublicLinkUrl() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
$ocs->cleanup();
@@ -462,7 +460,7 @@ class ApiTest extends TestCase {
* @depends testCreateShareUserFile
* @depends testCreateShareLink
*/
- function testGetShareFromSource() {
+ public function testGetShareFromSource() {
$node = $this->userFolder->get($this->filename);
$share = $this->shareManager->newShare();
$share->setNode($node)
@@ -495,7 +493,7 @@ class ApiTest extends TestCase {
* @depends testCreateShareUserFile
* @depends testCreateShareLink
*/
- function testGetShareFromSourceWithReshares() {
+ public function testGetShareFromSourceWithReshares() {
$node = $this->userFolder->get($this->filename);
$share1 = $this->shareManager->newShare();
$share1->setNode($node)
@@ -536,7 +534,7 @@ class ApiTest extends TestCase {
* @medium
* @depends testCreateShareUserFile
*/
- function testGetShareFromId() {
+ public function testGetShareFromId() {
$node = $this->userFolder->get($this->filename);
$share1 = $this->shareManager->newShare();
$share1->setNode($node)
@@ -560,7 +558,7 @@ class ApiTest extends TestCase {
/**
* @medium
*/
- function testGetShareFromFolder() {
+ public function testGetShareFromFolder() {
$node1 = $this->userFolder->get($this->filename);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -590,7 +588,7 @@ class ApiTest extends TestCase {
$this->shareManager->deleteShare($share2);
}
- function testGetShareFromFolderWithFile() {
+ public function testGetShareFromFolderWithFile() {
$node1 = $this->userFolder->get($this->filename);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -616,7 +614,7 @@ class ApiTest extends TestCase {
* share a folder, than reshare a file within the shared folder and check if we construct the correct path
* @medium
*/
- function testGetShareFromFolderReshares() {
+ public function testGetShareFromFolderReshares() {
$node1 = $this->userFolder->get($this->folder);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -648,12 +646,12 @@ class ApiTest extends TestCase {
$share3->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share3);
- $testValues=array(
- array('query' => $this->folder,
- 'expectedResult' => $this->folder . $this->filename),
- array('query' => $this->folder . $this->subfolder,
- 'expectedResult' => $this->folder . $this->subfolder . $this->filename),
- );
+ $testValues=[
+ ['query' => $this->folder,
+ 'expectedResult' => $this->folder . $this->filename],
+ ['query' => $this->folder . $this->subfolder,
+ 'expectedResult' => $this->folder . $this->subfolder . $this->filename],
+ ];
foreach ($testValues as $value) {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2);
@@ -676,7 +674,7 @@ class ApiTest extends TestCase {
* reshare a sub folder and check if we get the correct path
* @medium
*/
- function testGetShareFromSubFolderReShares() {
+ public function testGetShareFromSubFolderReShares() {
$node1 = $this->userFolder->get($this->folder . $this->subfolder);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -718,7 +716,7 @@ class ApiTest extends TestCase {
* test re-re-share of folder if the path gets constructed correctly
* @medium
*/
- function XtestGetShareFromFolderReReShares() {
+ public function XtestGetShareFromFolderReReShares() {
$node1 = $this->userFolder->get($this->folder . $this->subfolder);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -795,7 +793,7 @@ class ApiTest extends TestCase {
* test multiple shared folder if the path gets constructed correctly
* @medium
*/
- function testGetShareMultipleSharedFolder() {
+ public function testGetShareMultipleSharedFolder() {
$this->setUp();
$node1 = $this->userFolder->get($this->folder . $this->subfolder);
$share1 = $this->shareManager->newShare();
@@ -860,7 +858,7 @@ class ApiTest extends TestCase {
* test re-re-share of folder if the path gets constructed correctly
* @medium
*/
- function testGetShareFromFileReReShares() {
+ public function testGetShareFromFileReReShares() {
$node1 = $this->userFolder->get($this->folder . $this->subfolder);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -915,7 +913,7 @@ class ApiTest extends TestCase {
/**
* @medium
*/
- function testGetShareFromUnknownId() {
+ public function testGetShareFromUnknownId() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER3);
try {
$ocs->getShare(0);
@@ -931,8 +929,7 @@ class ApiTest extends TestCase {
* @depends testCreateShareUserFile
* @depends testCreateShareLink
*/
- function testUpdateShare() {
-
+ public function testUpdateShare() {
$password = md5(time());
$node1 = $this->userFolder->get($this->filename);
@@ -983,7 +980,7 @@ class ApiTest extends TestCase {
/**
* @medium
*/
- function testUpdateShareUpload() {
+ public function testUpdateShareUpload() {
$node1 = $this->userFolder->get($this->folder);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -1002,7 +999,8 @@ class ApiTest extends TestCase {
\OCP\Constants::PERMISSION_READ |
\OCP\Constants::PERMISSION_CREATE |
\OCP\Constants::PERMISSION_UPDATE |
- \OCP\Constants::PERMISSION_DELETE,
+ \OCP\Constants::PERMISSION_DELETE |
+ \OCP\Constants::PERMISSION_SHARE,
$share1->getPermissions()
);
@@ -1013,7 +1011,7 @@ class ApiTest extends TestCase {
/**
* @medium
*/
- function testUpdateShareExpireDate() {
+ public function testUpdateShareExpireDate() {
$node1 = $this->userFolder->get($this->folder);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -1053,7 +1051,6 @@ class ApiTest extends TestCase {
$ocs->updateShare($share1->getId());
$this->fail();
} catch (OCSBadRequestException $e) {
-
}
$ocs->cleanup();
@@ -1068,7 +1065,6 @@ class ApiTest extends TestCase {
$ocs->updateShare($share1->getId());
$this->fail();
} catch (OCSBadRequestException $e) {
-
}
$ocs->cleanup();
@@ -1087,7 +1083,7 @@ class ApiTest extends TestCase {
* @medium
* @depends testCreateShareUserFile
*/
- function testDeleteShare() {
+ public function testDeleteShare() {
$node1 = $this->userFolder->get($this->filename);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -1119,7 +1115,7 @@ class ApiTest extends TestCase {
/**
* test unshare of a reshared file
*/
- function testDeleteReshare() {
+ public function testDeleteReshare() {
$node1 = $this->userFolder->get($this->folder);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
@@ -1214,7 +1210,7 @@ class ApiTest extends TestCase {
*/
public static function initTestMountPointsHook($data) {
if ($data['user'] === self::TEST_FILES_SHARING_API_USER1) {
- \OC\Files\Filesystem::mount(self::$tempStorage, array(), '/' . self::TEST_FILES_SHARING_API_USER1 . '/files' . self::TEST_FOLDER_NAME);
+ \OC\Files\Filesystem::mount(self::$tempStorage, [], '/' . self::TEST_FILES_SHARING_API_USER1 . '/files' . self::TEST_FOLDER_NAME);
}
}
@@ -1222,7 +1218,7 @@ class ApiTest extends TestCase {
* Tests mounting a folder that is an external storage mount point.
*/
public function testShareStorageMountPoint() {
- $tempStorage = new \OC\Files\Storage\Temporary(array());
+ $tempStorage = new \OC\Files\Storage\Temporary([]);
$tempStorage->file_put_contents('test.txt', 'abcdef');
$tempStorage->getScanner()->scan('');
@@ -1371,7 +1367,7 @@ class ApiTest extends TestCase {
try {
$ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
$this->fail();
- } catch(OCSException $e) {
+ } catch (OCSException $e) {
$this->assertEquals(404, $e->getCode());
$this->assertEquals('Expiration date is in the past', $e->getMessage());
}
diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php
index 1c05e70f080..09fc9f6f5a7 100644
--- a/apps/files_sharing/tests/CacheTest.php
+++ b/apps/files_sharing/tests/CacheTest.php
@@ -3,12 +3,12 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Stefan Weil <sw@weilnetz.de>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Vincent Petry <pvince81@owncloud.com>
*
@@ -129,7 +129,7 @@ class CacheTest extends TestCase {
}
protected function tearDown(): void {
- if($this->sharedCache) {
+ if ($this->sharedCache) {
$this->sharedCache->clear();
}
@@ -147,71 +147,71 @@ class CacheTest extends TestCase {
parent::tearDown();
}
- function searchDataProvider() {
- return array(
- array('%another%',
- array(
- array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
- array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
- )
- ),
- array('%Another%',
- array(
- array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
- array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
- )
- ),
- array('%dir%',
- array(
- array('name' => 'emptydir', 'path' => 'emptydir'),
- array('name' => 'subdir', 'path' => 'subdir'),
- array('name' => 'shareddir', 'path' => ''),
- )
- ),
- array('%Dir%',
- array(
- array('name' => 'emptydir', 'path' => 'emptydir'),
- array('name' => 'subdir', 'path' => 'subdir'),
- array('name' => 'shareddir', 'path' => ''),
- )
- ),
- array('%txt%',
- array(
- array('name' => 'bar.txt', 'path' => 'bar.txt'),
- array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
- array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
- )
- ),
- array('%Txt%',
- array(
- array('name' => 'bar.txt', 'path' => 'bar.txt'),
- array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
- array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
- )
- ),
- array('%',
- array(
- array('name' => 'bar.txt', 'path' => 'bar.txt'),
- array('name' => 'emptydir', 'path' => 'emptydir'),
- array('name' => 'subdir', 'path' => 'subdir'),
- array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'),
- array('name' => 'another.txt', 'path' => 'subdir/another.txt'),
- array('name' => 'not a text file.xml', 'path' => 'subdir/not a text file.xml'),
- array('name' => 'shareddir', 'path' => ''),
- )
- ),
- array('%nonexistent%',
- array(
- )
- ),
- );
+ public function searchDataProvider() {
+ return [
+ ['%another%',
+ [
+ ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
+ ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
+ ]
+ ],
+ ['%Another%',
+ [
+ ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
+ ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
+ ]
+ ],
+ ['%dir%',
+ [
+ ['name' => 'emptydir', 'path' => 'emptydir'],
+ ['name' => 'subdir', 'path' => 'subdir'],
+ ['name' => 'shareddir', 'path' => ''],
+ ]
+ ],
+ ['%Dir%',
+ [
+ ['name' => 'emptydir', 'path' => 'emptydir'],
+ ['name' => 'subdir', 'path' => 'subdir'],
+ ['name' => 'shareddir', 'path' => ''],
+ ]
+ ],
+ ['%txt%',
+ [
+ ['name' => 'bar.txt', 'path' => 'bar.txt'],
+ ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
+ ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
+ ]
+ ],
+ ['%Txt%',
+ [
+ ['name' => 'bar.txt', 'path' => 'bar.txt'],
+ ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
+ ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
+ ]
+ ],
+ ['%',
+ [
+ ['name' => 'bar.txt', 'path' => 'bar.txt'],
+ ['name' => 'emptydir', 'path' => 'emptydir'],
+ ['name' => 'subdir', 'path' => 'subdir'],
+ ['name' => 'another too.txt', 'path' => 'subdir/another too.txt'],
+ ['name' => 'another.txt', 'path' => 'subdir/another.txt'],
+ ['name' => 'not a text file.xml', 'path' => 'subdir/not a text file.xml'],
+ ['name' => 'shareddir', 'path' => ''],
+ ]
+ ],
+ ['%nonexistent%',
+ [
+ ]
+ ],
+ ];
}
/**
* we cannot use a dataProvider because that would cause the stray hook detection to remove the hooks
* that were added in setUpBeforeClass.
*/
- function testSearch() {
+ public function testSearch() {
foreach ($this->searchDataProvider() as $data) {
list($pattern, $expectedFiles) = $data;
@@ -219,94 +219,93 @@ class CacheTest extends TestCase {
$this->verifyFiles($expectedFiles, $results);
}
-
}
/**
* Test searching by mime type
*/
- function testSearchByMime() {
+ public function testSearchByMime() {
$results = $this->sharedStorage->getCache()->searchByMime('text');
- $check = array(
- array(
- 'name' => 'bar.txt',
- 'path' => 'bar.txt'
- ),
- array(
- 'name' => 'another too.txt',
- 'path' => 'subdir/another too.txt'
- ),
- array(
- 'name' => 'another.txt',
- 'path' => 'subdir/another.txt'
- ),
- );
+ $check = [
+ [
+ 'name' => 'bar.txt',
+ 'path' => 'bar.txt'
+ ],
+ [
+ 'name' => 'another too.txt',
+ 'path' => 'subdir/another too.txt'
+ ],
+ [
+ 'name' => 'another.txt',
+ 'path' => 'subdir/another.txt'
+ ],
+ ];
$this->verifyFiles($check, $results);
}
- function testGetFolderContentsInRoot() {
+ public function testGetFolderContentsInRoot() {
$results = $this->user2View->getDirectoryContent('/');
// we should get the shared items "shareddir" and "shared single file.txt"
// additional root will always contain the example file "welcome.txt",
// so this will be part of the result
$this->verifyFiles(
- array(
- array(
+ [
+ [
'name' => 'welcome.txt',
'path' => 'files/welcome.txt',
'mimetype' => 'text/plain',
- ),
- array(
+ ],
+ [
'name' => 'shareddir',
'path' => 'files/shareddir',
'mimetype' => 'httpd/unix-directory',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One',
- ),
- array(
+ ],
+ [
'name' => 'shared single file.txt',
'path' => 'files/shared single file.txt',
'mimetype' => 'text/plain',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One',
- ),
- ),
+ ],
+ ],
$results
);
}
- function testGetFolderContentsInSubdir() {
+ public function testGetFolderContentsInSubdir() {
$results = $this->user2View->getDirectoryContent('/shareddir');
$this->verifyFiles(
- array(
- array(
+ [
+ [
'name' => 'bar.txt',
'path' => 'bar.txt',
'mimetype' => 'text/plain',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One',
- ),
- array(
+ ],
+ [
'name' => 'emptydir',
'path' => 'emptydir',
'mimetype' => 'httpd/unix-directory',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One',
- ),
- array(
+ ],
+ [
'name' => 'subdir',
'path' => 'subdir',
'mimetype' => 'httpd/unix-directory',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One',
- ),
- ),
+ ],
+ ],
$results
);
}
- function testGetFolderContentsWhenSubSubdirShared() {
+ public function testGetFolderContentsWhenSubSubdirShared() {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
@@ -327,29 +326,29 @@ class CacheTest extends TestCase {
$results = $thirdView->getDirectoryContent('/subdir');
$this->verifyFiles(
- array(
- array(
+ [
+ [
'name' => 'another too.txt',
'path' => 'another too.txt',
'mimetype' => 'text/plain',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One',
- ),
- array(
+ ],
+ [
'name' => 'another.txt',
'path' => 'another.txt',
'mimetype' => 'text/plain',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One',
- ),
- array(
+ ],
+ [
'name' => 'not a text file.xml',
'path' => 'not a text file.xml',
'mimetype' => 'application/xml',
'uid_owner' => self::TEST_FILES_SHARING_API_USER1,
'displayname_owner' => 'User One',
- ),
- ),
+ ],
+ ],
$results
);
@@ -376,7 +375,7 @@ class CacheTest extends TestCase {
}
}
}
- $this->assertEquals(array(), $results);
+ $this->assertEquals([], $results);
}
/**
diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php
index 880921553f3..a49074cb60e 100644
--- a/apps/files_sharing/tests/CapabilitiesTest.php
+++ b/apps/files_sharing/tests/CapabilitiesTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
@@ -58,7 +59,7 @@ class CapabilitiesTest extends \Test\TestCase {
*/
private function getResults(array $map) {
$config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock();
- $config->method('getAppValue')->will($this->returnValueMap($map));
+ $config->method('getAppValue')->willReturnMap($map);
$cap = new Capabilities($config);
$result = $this->getFilesSharingPart($cap->getCapabilities());
return $result;
@@ -284,5 +285,4 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertArrayHasKey('federation', $result);
$this->assertFalse($result['federation']['outgoing']);
}
-
}
diff --git a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php
index fe12fb034c0..1efd99706c2 100644
--- a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php
+++ b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php
@@ -24,7 +24,6 @@
namespace OCA\Files_Sharing\Tests\Collaboration;
-
use OCA\Files_Sharing\Collaboration\ShareRecipientSorter;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
index 9be1141f35f..dd03ffc6668 100644
--- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
+++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
@@ -191,6 +191,5 @@ class CleanupRemoteStoragesTest extends TestCase {
$this->assertFalse($this->doesStorageExist($this->storages[3]['numeric_id']));
$this->assertTrue($this->doesStorageExist($this->storages[4]['numeric_id']));
$this->assertFalse($this->doesStorageExist($this->storages[5]['numeric_id']));
-
}
}
diff --git a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
index 9d8ee9a9d42..d6a4ee8d4f3 100644
--- a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
@@ -162,6 +162,7 @@ class ExternalShareControllerTest extends \Test\TestCase {
return [
['nextcloud.com?query'],
['nextcloud.com/#anchor'],
+ ['nextcloud.com/;tomcat'],
];
}
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 0c2606b360c..577f574f8ed 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Calviño Sánchez <danxuliu@gmail.com>
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@@ -122,9 +123,9 @@ class ShareAPIControllerTest extends TestCase {
$this->l = $this->createMock(IL10N::class);
$this->l->method('t')
- ->will($this->returnCallback(function($text, $parameters = []) {
+ ->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters);
- }));
+ });
$this->config = $this->createMock(IConfig::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->serverContainer = $this->createMock(IServerContainer::class);
@@ -179,13 +180,13 @@ class ShareAPIControllerTest extends TestCase {
$this->shareManager
->expects($this->exactly(5))
->method('getShareById')
- ->will($this->returnCallback(function($id) {
+ ->willReturnCallback(function ($id) {
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42') {
throw new \OCP\Share\Exceptions\ShareNotFound();
} else {
throw new \Exception();
}
- }));
+ });
$this->shareManager->method('outgoingServer2ServerSharesAllowed')->willReturn(true);
@@ -732,7 +733,7 @@ class ShareAPIControllerTest extends TestCase {
$userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$userFolder
->method('getRelativePath')
- ->will($this->returnArgument(0));
+ ->willReturnArgument(0);
$userFolder->method('getById')
->with($share->getNodeId())
@@ -761,14 +762,14 @@ class ShareAPIControllerTest extends TestCase {
$group = $this->getMockBuilder('OCP\IGroup')->getMock();
$group->method('getGID')->willReturn('groupId');
- $this->userManager->method('get')->will($this->returnValueMap([
+ $this->userManager->method('get')->willReturnMap([
['userId', $user],
['initiatorId', $initiator],
['ownerId', $owner],
- ]));
- $this->groupManager->method('get')->will($this->returnValueMap([
+ ]);
+ $this->groupManager->method('get')->willReturnMap([
['group', $group],
- ]));
+ ]);
$d = $ocs->getShare($share->getId())->getData()[0];
@@ -1339,14 +1340,14 @@ class ShareAPIControllerTest extends TestCase {
->getMock();
$ocs->method('formatShare')
- ->will($this->returnCallback(
- function($share) {
+ ->willReturnCallback(
+ function ($share) {
return [
'id' => $share->getId(),
'share_type' => $share->getShareType()
];
}
- ));
+ );
$userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$userFolder->method('get')
@@ -1359,14 +1360,14 @@ class ShareAPIControllerTest extends TestCase {
$this->shareManager
->method('getSharesBy')
- ->will($this->returnCallback(
- function($user, $shareType, $node) use ($shares) {
+ ->willReturnCallback(
+ function ($user, $shareType, $node) use ($shares) {
if (!isset($shares[$node->getName()]) || !isset($shares[$node->getName()][$shareType])) {
return [];
}
return $shares[$node->getName()][$shareType];
}
- ));
+ );
$this->shareManager
->method('outgoingServer2ServerSharesAllowed')
@@ -1378,11 +1379,11 @@ class ShareAPIControllerTest extends TestCase {
$this->groupManager
->method('isInGroup')
- ->will($this->returnCallback(
- function($user, $group) {
+ ->willReturnCallback(
+ function ($user, $group) {
return $group === 'currentUserGroup';
}
- ));
+ );
$result = $ocs->getShares(
$getSharesParameters['sharedWithMe'] ?? 'false',
@@ -1448,11 +1449,11 @@ class ShareAPIControllerTest extends TestCase {
$group2 = $this->getMockBuilder('OCP\IGroup')->getMock();
$group2->method('inGroup')->with($user)->willReturn(false);
- $this->groupManager->method('get')->will($this->returnValueMap([
+ $this->groupManager->method('get')->willReturnMap([
['group', $group],
['group2', $group2],
['groupnull', null],
- ]));
+ ]);
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->createMock(IShare::class);
@@ -1525,7 +1526,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn(true);
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
- ->setMethods(array('canAccessShare'))
+ ->setMethods(['canAccessShare'])
->getMock();
$helper->method('canAccessShare')
->with($share, $this->currentUser)
@@ -1716,7 +1717,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getSharedWith() === 'validUser' &&
$share->getSharedBy() === 'currentUser';
}))
- ->will($this->returnArgument(0));
+ ->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser');
@@ -1732,7 +1733,7 @@ class ShareAPIControllerTest extends TestCase {
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
- $this->shareManager->method('createShare')->will($this->returnArgument(0));
+ $this->shareManager->method('createShare')->willReturnArgument(0);
$this->shareManager->method('allowGroupSharing')->willReturn(true);
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
@@ -1783,12 +1784,12 @@ class ShareAPIControllerTest extends TestCase {
$this->request
->method('getParam')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['path', null, 'valid-path'],
['permissions', null, \OCP\Constants::PERMISSION_ALL],
['shareType', '-1', \OCP\Share::SHARE_TYPE_GROUP],
['shareWith', null, 'validGroup'],
- ]));
+ ]);
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
$this->rootFolder->expects($this->once())
@@ -1825,7 +1826,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getSharedWith() === 'validGroup' &&
$share->getSharedBy() === 'currentUser';
}))
- ->will($this->returnArgument(0));
+ ->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'validGroup');
@@ -1875,10 +1876,10 @@ class ShareAPIControllerTest extends TestCase {
$this->request
->method('getParam')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['path', null, 'valid-path'],
['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
- ]));
+ ]);
$path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->createMock(Storage::class);
@@ -1886,7 +1887,7 @@ class ShareAPIControllerTest extends TestCase {
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
$path->method('getStorage')->willReturn($storage);
- $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
@@ -1905,7 +1906,7 @@ class ShareAPIControllerTest extends TestCase {
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
$path->method('getStorage')->willReturn($storage);
- $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
@@ -1925,7 +1926,7 @@ class ShareAPIControllerTest extends TestCase {
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
$path->method('getStorage')->willReturn($storage);
- $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
@@ -1944,7 +1945,7 @@ class ShareAPIControllerTest extends TestCase {
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
$path->method('getStorage')->willReturn($storage);
- $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
@@ -1960,7 +1961,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getPassword() === null &&
$share->getExpirationDate() === null;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true', '', null, '');
@@ -1978,7 +1979,7 @@ class ShareAPIControllerTest extends TestCase {
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
$path->method('getStorage')->willReturn($storage);
- $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
@@ -1994,7 +1995,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getPassword() === 'password' &&
$share->getExpirationDate() === null;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', null, '');
@@ -2012,7 +2013,7 @@ class ShareAPIControllerTest extends TestCase {
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
$path->method('getStorage')->willReturn($storage);
- $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
@@ -2031,7 +2032,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getSendPasswordByTalk() === true &&
$share->getExpirationDate() === null;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', 'true', '');
@@ -2054,7 +2055,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn(false);
$path->method('getStorage')->willReturn($storage);
$path->method('getPath')->willReturn('valid-path');
- $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
@@ -2073,13 +2074,13 @@ class ShareAPIControllerTest extends TestCase {
$this->request
->method('getParam')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['path', null, 'valid-path'],
['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
['publicUpload', null, 'false'],
['expireDate', '', '2000-01-01'],
['password', '', ''],
- ]));
+ ]);
$path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->createMock(Storage::class);
@@ -2087,7 +2088,7 @@ class ShareAPIControllerTest extends TestCase {
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
$path->method('getStorage')->willReturn($storage);
- $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
@@ -2106,7 +2107,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getPassword() === null &&
$share->getExpirationDate() == $date;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, '2000-01-01');
@@ -2128,7 +2129,7 @@ class ShareAPIControllerTest extends TestCase {
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
$path->method('getStorage')->willReturn($storage);
- $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
@@ -2170,7 +2171,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn(true);
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
- ->setMethods(array('createShare'))
+ ->setMethods(['createShare'])
->getMock();
$helper->method('createShare')
->with(
@@ -2180,7 +2181,7 @@ class ShareAPIControllerTest extends TestCase {
~\OCP\Constants::PERMISSION_DELETE &
~\OCP\Constants::PERMISSION_CREATE,
''
- )->will($this->returnCallback(
+ )->willReturnCallback(
function ($share) {
$share->setSharedWith('recipientRoom');
$share->setPermissions(
@@ -2189,7 +2190,7 @@ class ShareAPIControllerTest extends TestCase {
~\OCP\Constants::PERMISSION_CREATE
);
}
- ));
+ );
$this->serverContainer->method('query')
->with('\OCA\Talk\Share\Helper\ShareAPIController')
@@ -2207,7 +2208,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getSharedWith() === 'recipientRoom' &&
$share->getSharedBy() === 'currentUser';
}))
- ->will($this->returnArgument(0));
+ ->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom');
@@ -2293,7 +2294,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn(true);
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
- ->setMethods(array('createShare'))
+ ->setMethods(['createShare'])
->getMock();
$helper->method('createShare')
->with(
@@ -2303,11 +2304,11 @@ class ShareAPIControllerTest extends TestCase {
~\OCP\Constants::PERMISSION_DELETE &
~\OCP\Constants::PERMISSION_CREATE,
''
- )->will($this->returnCallback(
+ )->willReturnCallback(
function ($share) {
throw new OCSNotFoundException("Exception thrown by the helper");
}
- ));
+ );
$this->serverContainer->method('query')
->with('\OCA\Talk\Share\Helper\ShareAPIController')
@@ -2370,7 +2371,7 @@ class ShareAPIControllerTest extends TestCase {
->with($this->callback(function (\OCP\Share\IShare $share) {
return $share->getPermissions() === \OCP\Constants::PERMISSION_READ;
}))
- ->will($this->returnArgument(0));
+ ->willReturnArgument(0);
$ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser');
}
@@ -2479,7 +2480,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === '' &&
$share->getHideDownload() === false;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$this->shareManager->method('getSharedWith')
->willReturn([]);
@@ -2534,7 +2535,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === 'label' &&
$share->getHideDownload() === true;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$this->shareManager->method('getSharedWith')
->willReturn([]);
@@ -2588,7 +2589,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getPassword() === 'password' &&
$share->getExpirationDate() === null;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$userFolder = $this->createMock(Folder::class);
$this->rootFolder->method('getUserFolder')
@@ -2729,7 +2730,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === 'label' &&
$share->getHideDownload() === true;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, null, 'newpassword', null, null, null, null, null, null);
@@ -2776,7 +2777,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === 'label' &&
$share->getHideDownload() === true;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, null, null, 'true', null, null, null, null, null);
@@ -2860,7 +2861,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === 'label' &&
$share->getHideDownload() === true;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$expected = new DataResponse([]);
$result = $ocs->updateShare(42, null, null, 'false', null, null, null, null, null);
@@ -2910,7 +2911,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === 'label' &&
$share->getHideDownload() === true;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$userFolder = $this->createMock(Folder::class);
$this->rootFolder->method('getUserFolder')
@@ -2979,7 +2980,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === 'label' &&
$share->getHideDownload() === true;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$userFolder = $this->createMock(Folder::class);
$this->rootFolder->method('getUserFolder')
@@ -3038,7 +3039,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === 'label' &&
$share->getHideDownload() === true;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$this->shareManager->method('getSharedWith')
->willReturn([]);
@@ -3100,7 +3101,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === 'label' &&
$share->getHideDownload() === true;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$this->shareManager->method('getSharedWith')->willReturn([]);
@@ -3161,7 +3162,7 @@ class ShareAPIControllerTest extends TestCase {
$share->getLabel() === 'label' &&
$share->getHideDownload() === true;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$userFolder = $this->createMock(Folder::class);
$this->rootFolder->method('getUserFolder')
@@ -3207,7 +3208,7 @@ class ShareAPIControllerTest extends TestCase {
$this->callback(function (\OCP\Share\IShare $share) {
return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL;
})
- )->will($this->returnArgument(0));
+ )->willReturnArgument(0);
$this->shareManager->method('getSharedWith')->willReturn([]);
@@ -3264,19 +3265,19 @@ class ShareAPIControllerTest extends TestCase {
$this->request
->method('getParam')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['permissions', null, '31'],
- ]));
+ ]);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->shareManager->expects($this->any())
->method('getSharedWith')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['currentUser', \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0, []],
['currentUser', \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]],
['currentUser', \OCP\Share::SHARE_TYPE_ROOM, $share->getNode(), -1, 0, []]
- ]));
+ ]);
$userFolder = $this->createMock(Folder::class);
$this->rootFolder->method('getUserFolder')
@@ -3339,10 +3340,10 @@ class ShareAPIControllerTest extends TestCase {
$this->shareManager->expects($this->any())
->method('getSharedWith')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['currentUser', \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0, []],
['currentUser', \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]]
- ]));
+ ]);
$this->shareManager->expects($this->once())
->method('updateShare')
@@ -4079,13 +4080,13 @@ class ShareAPIControllerTest extends TestCase {
* @param $exception
*/
public function testFormatShare(array $expects, \OCP\Share\IShare $share, array $users, $exception) {
- $this->userManager->method('get')->will($this->returnValueMap($users));
+ $this->userManager->method('get')->willReturnMap($users);
$recipientGroup = $this->createMock('\OCP\IGroup');
$recipientGroup->method('getDisplayName')->willReturn('recipientGroupDisplayName');
- $this->groupManager->method('get')->will($this->returnValueMap([
- ['recipientGroup', $recipientGroup],
- ]));
+ $this->groupManager->method('get')->willReturnMap([
+ ['recipientGroup', $recipientGroup],
+ ]);
$this->urlGenerator->method('linkToRouteAbsolute')
->with('files_sharing.sharecontroller.showShare', ['token' => 'myToken'])
@@ -4094,7 +4095,7 @@ class ShareAPIControllerTest extends TestCase {
$this->rootFolder->method('getUserFolder')
->with($this->currentUser)
- ->will($this->returnSelf());
+ ->willReturnSelf();
if (!$exception) {
$this->rootFolder->method('getById')
@@ -4103,14 +4104,14 @@ class ShareAPIControllerTest extends TestCase {
$this->rootFolder->method('getRelativePath')
->with($share->getNode()->getPath())
- ->will($this->returnArgument(0));
+ ->willReturnArgument(0);
}
$cm = $this->createMock(\OCP\Contacts\IManager::class);
$this->overwriteService(\OCP\Contacts\IManager::class, $cm);
$cm->method('search')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['user@server.com', ['CLOUD'], [],
[
[
@@ -4131,7 +4132,7 @@ class ShareAPIControllerTest extends TestCase {
],
],
],
- ]));
+ ]);
try {
$result = $this->invokePrivate($this->ocs, 'formatShare', [$share]);
@@ -4271,7 +4272,7 @@ class ShareAPIControllerTest extends TestCase {
public function testFormatRoomShare(array $expects, \OCP\Share\IShare $share, bool $helperAvailable, array $formatShareByHelper) {
$this->rootFolder->method('getUserFolder')
->with($this->currentUser)
- ->will($this->returnSelf());
+ ->willReturnSelf();
$this->rootFolder->method('getById')
->with($share->getNodeId())
@@ -4279,7 +4280,7 @@ class ShareAPIControllerTest extends TestCase {
$this->rootFolder->method('getRelativePath')
->with($share->getNode()->getPath())
- ->will($this->returnArgument(0));
+ ->willReturnArgument(0);
if (!$helperAvailable) {
$this->appManager->method('isEnabledForUser')
@@ -4291,7 +4292,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn(true);
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
- ->setMethods(array('formatShare'))
+ ->setMethods(['formatShare'])
->getMock();
$helper->method('formatShare')
->with($share)
diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php
index fbce22b403f..2f1df959afb 100644
--- a/apps/files_sharing/tests/Controller/ShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php
@@ -4,6 +4,7 @@
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Calviño Sánchez <danxuliu@gmail.com>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
@@ -38,6 +39,9 @@ use OC\Files\Filesystem;
use OC\Files\Node\Folder;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\Controller\ShareController;
+use OCP\Accounts\IAccount;
+use OCP\Accounts\IAccountManager;
+use OCP\Accounts\IAccountProperty;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\Template\ExternalShareMenuAction;
use OCP\AppFramework\Http\Template\LinkMenuAction;
@@ -61,6 +65,10 @@ use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IShare;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use OCP\Activity\IManager;
+use OCP\Files\IRootFolder;
+use OCP\Defaults;
+use OC\Share20\Manager;
/**
* @group DB
@@ -78,21 +86,23 @@ class ShareControllerTest extends \Test\TestCase {
private $appName = 'files_sharing';
/** @var ShareController */
private $shareController;
- /** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var IURLGenerator|MockObject */
private $urlGenerator;
- /** @var ISession | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var ISession|MockObject */
private $session;
- /** @var \OCP\IPreview | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OCP\IPreview|MockObject */
private $previewManager;
- /** @var \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OCP\IConfig|MockObject */
private $config;
- /** @var \OC\Share20\Manager | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OC\Share20\Manager|MockObject */
private $shareManager;
- /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var IUserManager|MockObject */
private $userManager;
- /** @var FederatedShareProvider | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var FederatedShareProvider|MockObject */
private $federatedShareProvider;
- /** @var EventDispatcherInterface | \PHPUnit_Framework_MockObject_MockObject */
+ /** @var IAccountManager|MockObject */
+ private $accountManager;
+ /** @var EventDispatcherInterface|MockObject */
private $eventDispatcher;
/** @var IL10N */
private $l10n;
@@ -101,37 +111,38 @@ class ShareControllerTest extends \Test\TestCase {
parent::setUp();
$this->appName = 'files_sharing';
- $this->shareManager = $this->getMockBuilder('\OC\Share20\Manager')->disableOriginalConstructor()->getMock();
- $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock();
- $this->session = $this->getMockBuilder(ISession::class)->getMock();
- $this->previewManager = $this->getMockBuilder(IPreview::class)->getMock();
- $this->config = $this->getMockBuilder(IConfig::class)->getMock();
- $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock();
- $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider')
- ->disableOriginalConstructor()->getMock();
+ $this->shareManager = $this->createMock(Manager::class);
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
+ $this->session = $this->createMock(ISession::class);
+ $this->previewManager = $this->createMock(IPreview::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->userManager = $this->createMock(IUserManager::class);
+ $this->federatedShareProvider = $this->createMock(FederatedShareProvider::class);
$this->federatedShareProvider->expects($this->any())
->method('isOutgoingServer2serverShareEnabled')->willReturn(true);
$this->federatedShareProvider->expects($this->any())
->method('isIncomingServer2serverShareEnabled')->willReturn(true);
- $this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+ $this->accountManager = $this->createMock(IAccountManager::class);
+ $this->eventDispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->l10n = $this->createMock(IL10N::class);
$this->shareController = new \OCA\Files_Sharing\Controller\ShareController(
$this->appName,
- $this->getMockBuilder(IRequest::class)->getMock(),
+ $this->createMock(IRequest::class),
$this->config,
$this->urlGenerator,
$this->userManager,
- $this->getMockBuilder(ILogger::class)->getMock(),
- $this->getMockBuilder('\OCP\Activity\IManager')->getMock(),
+ $this->createMock(ILogger::class),
+ $this->createMock(IManager::class),
$this->shareManager,
$this->session,
$this->previewManager,
- $this->getMockBuilder('\OCP\Files\IRootFolder')->getMock(),
+ $this->createMock(IRootFolder::class),
$this->federatedShareProvider,
+ $this->accountManager,
$this->eventDispatcher,
$this->l10n,
- $this->getMockBuilder('\OCP\Defaults')->getMock()
+ $this->createMock(Defaults::class)
);
@@ -151,7 +162,9 @@ class ShareControllerTest extends \Test\TestCase {
\OC_User::setUserId('');
Filesystem::tearDown();
$user = \OC::$server->getUserManager()->get($this->user);
- if ($user !== null) { $user->delete(); }
+ if ($user !== null) {
+ $user->delete();
+ }
\OC_User::setIncognitoMode(false);
\OC::$server->getSession()->set('public_link_authenticated', '');
@@ -197,7 +210,6 @@ class ShareControllerTest extends \Test\TestCase {
public function testShowShare() {
-
$note = 'personal note';
$this->shareController->setToken('token');
@@ -219,6 +231,18 @@ class ShareControllerTest extends \Test\TestCase {
$file->method('isReadable')->willReturn(true);
$file->method('isShareable')->willReturn(true);
+ $accountName = $this->createMock(IAccountProperty::class);
+ $accountName->method('getScope')
+ ->willReturn(IAccountManager::VISIBILITY_PUBLIC);
+ $account = $this->createMock(IAccount::class);
+ $account->method('getProperty')
+ ->with(IAccountManager::PROPERTY_DISPLAYNAME)
+ ->willReturn($accountName);
+ $this->accountManager->expects($this->once())
+ ->method('getAccount')
+ ->with($owner)
+ ->willReturn($account);
+
$share = \OC::$server->getShareManager()->newShare();
$share->setId(42);
$share->setPassword('password')
@@ -261,7 +285,7 @@ class ShareControllerTest extends \Test\TestCase {
->with('core', 'shareapi_public_link_disclaimertext', null)
->willReturn('My disclaimer text');
- $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) {
+ $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) {
if ($uid === 'ownerUID') {
return $owner;
}
@@ -275,20 +299,19 @@ class ShareControllerTest extends \Test\TestCase {
->method('dispatch')
->with(
'OCA\Files_Sharing::loadAdditionalScripts',
- $this->callback(function($event) use ($share) {
+ $this->callback(function ($event) use ($share) {
return $event->getArgument('share') === $share;
})
);
$this->l10n->expects($this->any())
->method('t')
- ->will($this->returnCallback(function($text, $parameters) {
+ ->willReturnCallback(function ($text, $parameters) {
return vsprintf($text, $parameters);
- }));
+ });
$response = $this->shareController->showShare();
- $sharedTmplParams = array(
- 'displayName' => 'ownerDisplay',
+ $sharedTmplParams = [
'owner' => 'ownerUID',
'filename' => 'file1.txt',
'directory_path' => '/file1.txt',
@@ -315,19 +338,166 @@ class ShareControllerTest extends \Test\TestCase {
'note' => $note,
'hideDownload' => false,
'showgridview' => false
- );
+ ];
+
+ $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
+ $csp->addAllowedFrameDomain('\'self\'');
+ $expectedResponse = new PublicTemplateResponse($this->appName, 'public', $sharedTmplParams);
+ $expectedResponse->setContentSecurityPolicy($csp);
+ $expectedResponse->setHeaderTitle($sharedTmplParams['filename']);
+ $expectedResponse->setHeaderDetails('shared by ' . $sharedTmplParams['shareOwner']);
+ $expectedResponse->setHeaderActions([
+ new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $sharedTmplParams['downloadURL'], 0),
+ new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $sharedTmplParams['downloadURL'], 10, $sharedTmplParams['fileSize']),
+ new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $sharedTmplParams['previewURL']),
+ new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $sharedTmplParams['owner'], $sharedTmplParams['shareOwner'], $sharedTmplParams['filename']),
+ ]);
+
+ $this->assertEquals($expectedResponse, $response);
+ }
+
+ public function testShowShareWithPrivateName() {
+ $note = 'personal note';
+
+ $this->shareController->setToken('token');
+
+ $owner = $this->createMock(IUser::class);
+ $owner->method('getDisplayName')->willReturn('ownerDisplay');
+ $owner->method('getUID')->willReturn('ownerUID');
+ $owner->method('isEnabled')->willReturn(true);
+
+ $initiator = $this->createMock(IUser::class);
+ $initiator->method('getDisplayName')->willReturn('initiatorDisplay');
+ $initiator->method('getUID')->willReturn('initiatorUID');
+ $initiator->method('isEnabled')->willReturn(true);
+
+ $file = $this->createMock(File::class);
+ $file->method('getName')->willReturn('file1.txt');
+ $file->method('getMimetype')->willReturn('text/plain');
+ $file->method('getSize')->willReturn(33);
+ $file->method('isReadable')->willReturn(true);
+ $file->method('isShareable')->willReturn(true);
+
+ $accountName = $this->createMock(IAccountProperty::class);
+ $accountName->method('getScope')
+ ->willReturn(IAccountManager::VISIBILITY_PRIVATE);
+ $account = $this->createMock(IAccount::class);
+ $account->method('getProperty')
+ ->with(IAccountManager::PROPERTY_DISPLAYNAME)
+ ->willReturn($accountName);
+ $this->accountManager->expects($this->once())
+ ->method('getAccount')
+ ->with($owner)
+ ->willReturn($account);
+
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(42);
+ $share->setPassword('password')
+ ->setShareOwner('ownerUID')
+ ->setSharedBy('initiatorUID')
+ ->setNode($file)
+ ->setNote($note)
+ ->setTarget('/file1.txt');
+
+ $this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
+ $this->session->method('get')->with('public_link_authenticated')->willReturn('42');
+
+ $this->urlGenerator->expects($this->at(0))
+ ->method('linkToRouteAbsolute')
+ ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token'])
+ ->willReturn('downloadURL');
+
+ $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],
+ ['preview_max_x', 1024, 1024],
+ ['preview_max_y', 1024, 1024],
+ ]
+ );
+ $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->config
+ ->expects($this->once())
+ ->method('getAppValue')
+ ->with('core', 'shareapi_public_link_disclaimertext', null)
+ ->willReturn('My disclaimer text');
+
+ $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) {
+ if ($uid === 'ownerUID') {
+ return $owner;
+ }
+ if ($uid === 'initiatorUID') {
+ return $initiator;
+ }
+ return null;
+ });
+
+ $this->eventDispatcher->expects($this->once())
+ ->method('dispatch')
+ ->with(
+ 'OCA\Files_Sharing::loadAdditionalScripts',
+ $this->callback(function ($event) use ($share) {
+ return $event->getArgument('share') === $share;
+ })
+ );
+
+ $this->l10n->expects($this->any())
+ ->method('t')
+ ->will($this->returnCallback(function ($text, $parameters) {
+ return vsprintf($text, $parameters);
+ }));
+
+ $response = $this->shareController->showShare();
+ $sharedTmplParams = [
+ 'owner' => '',
+ 'filename' => 'file1.txt',
+ 'directory_path' => '/file1.txt',
+ 'mimetype' => 'text/plain',
+ 'dirToken' => 'token',
+ 'sharingToken' => 'token',
+ 'server2serversharing' => true,
+ 'protected' => 'true',
+ 'dir' => '',
+ 'downloadURL' => 'downloadURL',
+ 'fileSize' => '33 B',
+ 'nonHumanFileSize' => 33,
+ 'maxSizeAnimateGif' => 10,
+ 'previewSupported' => true,
+ 'previewEnabled' => true,
+ 'previewMaxX' => 1024,
+ 'previewMaxY' => 1024,
+ 'hideFileList' => false,
+ 'shareOwner' => '',
+ 'disclaimer' => 'My disclaimer text',
+ 'shareUrl' => null,
+ 'previewImage' => null,
+ 'previewURL' => 'downloadURL',
+ 'note' => $note,
+ 'hideDownload' => false,
+ 'showgridview' => false
+ ];
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new PublicTemplateResponse($this->appName, 'public', $sharedTmplParams);
$expectedResponse->setContentSecurityPolicy($csp);
$expectedResponse->setHeaderTitle($sharedTmplParams['filename']);
- $expectedResponse->setHeaderDetails('shared by ' . $sharedTmplParams['displayName']);
+ $expectedResponse->setHeaderDetails('');
$expectedResponse->setHeaderActions([
new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $sharedTmplParams['downloadURL'], 0),
new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $sharedTmplParams['downloadURL'], 10, $sharedTmplParams['fileSize']),
new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $sharedTmplParams['previewURL']),
- new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $sharedTmplParams['owner'], $sharedTmplParams['displayName'], $sharedTmplParams['filename']),
+ new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $sharedTmplParams['owner'], $sharedTmplParams['shareOwner'], $sharedTmplParams['filename']),
]);
$this->assertEquals($expectedResponse, $response);
@@ -355,6 +525,18 @@ class ShareControllerTest extends \Test\TestCase {
$file->method('isReadable')->willReturn(true);
$file->method('isShareable')->willReturn(true);
+ $accountName = $this->createMock(IAccountProperty::class);
+ $accountName->method('getScope')
+ ->willReturn(IAccountManager::VISIBILITY_PUBLIC);
+ $account = $this->createMock(IAccount::class);
+ $account->method('getProperty')
+ ->with(IAccountManager::PROPERTY_DISPLAYNAME)
+ ->willReturn($accountName);
+ $this->accountManager->expects($this->once())
+ ->method('getAccount')
+ ->with($owner)
+ ->willReturn($account);
+
$share = \OC::$server->getShareManager()->newShare();
$share->setId(42);
$share->setPassword('password')
@@ -401,7 +583,7 @@ class ShareControllerTest extends \Test\TestCase {
->with('core', 'shareapi_public_link_disclaimertext', null)
->willReturn('My disclaimer text');
- $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) {
+ $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) {
if ($uid === 'ownerUID') {
return $owner;
}
@@ -415,20 +597,19 @@ class ShareControllerTest extends \Test\TestCase {
->method('dispatch')
->with(
'OCA\Files_Sharing::loadAdditionalScripts',
- $this->callback(function($event) use ($share) {
+ $this->callback(function ($event) use ($share) {
return $event->getArgument('share') === $share;
})
);
$this->l10n->expects($this->any())
->method('t')
- ->will($this->returnCallback(function($text, $parameters) {
+ ->willReturnCallback(function ($text, $parameters) {
return vsprintf($text, $parameters);
- }));
+ });
$response = $this->shareController->showShare();
- $sharedTmplParams = array(
- 'displayName' => 'ownerDisplay',
+ $sharedTmplParams = [
'owner' => 'ownerUID',
'filename' => 'file1.txt',
'directory_path' => '/file1.txt',
@@ -455,14 +636,14 @@ class ShareControllerTest extends \Test\TestCase {
'note' => $note,
'hideDownload' => true,
'showgridview' => false
- );
+ ];
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new PublicTemplateResponse($this->appName, 'public', $sharedTmplParams);
$expectedResponse->setContentSecurityPolicy($csp);
$expectedResponse->setHeaderTitle($sharedTmplParams['filename']);
- $expectedResponse->setHeaderDetails('shared by ' . $sharedTmplParams['displayName']);
+ $expectedResponse->setHeaderDetails('shared by ' . $sharedTmplParams['shareOwner']);
$expectedResponse->setHeaderActions([]);
$this->assertEquals($expectedResponse, $response);
@@ -505,6 +686,18 @@ class ShareControllerTest extends \Test\TestCase {
$folder->method('get')->with('')->willReturn($folder);
$folder->method('getSize')->willReturn(1337);
+ $accountName = $this->createMock(IAccountProperty::class);
+ $accountName->method('getScope')
+ ->willReturn(IAccountManager::VISIBILITY_PUBLIC);
+ $account = $this->createMock(IAccount::class);
+ $account->method('getProperty')
+ ->with(IAccountManager::PROPERTY_DISPLAYNAME)
+ ->willReturn($accountName);
+ $this->accountManager->expects($this->once())
+ ->method('getAccount')
+ ->with($owner)
+ ->willReturn($account);
+
$share = \OC::$server->getShareManager()->newShare();
$share->setId(42);
$share->setPermissions(Constants::PERMISSION_CREATE)
@@ -519,7 +712,7 @@ class ShareControllerTest extends \Test\TestCase {
->with('token')
->willReturn($share);
- $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) {
+ $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) {
if ($uid === 'ownerUID') {
return $owner;
}
@@ -531,9 +724,9 @@ class ShareControllerTest extends \Test\TestCase {
$this->l10n->expects($this->any())
->method('t')
- ->will($this->returnCallback(function($text, $parameters) {
+ ->willReturnCallback(function ($text, $parameters) {
return vsprintf($text, $parameters);
- }));
+ });
$response = $this->shareController->showShare();
// skip the "folder" param for tests
@@ -541,8 +734,7 @@ class ShareControllerTest extends \Test\TestCase {
unset($responseParams['folder']);
$response->setParams($responseParams);
- $sharedTmplParams = array(
- 'displayName' => 'ownerDisplay',
+ $sharedTmplParams = [
'owner' => 'ownerUID',
'filename' => '/fileDrop',
'directory_path' => '/fileDrop',
@@ -569,14 +761,14 @@ class ShareControllerTest extends \Test\TestCase {
'note' => '',
'hideDownload' => false,
'showgridview' => false
- );
+ ];
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new PublicTemplateResponse($this->appName, 'public', $sharedTmplParams);
$expectedResponse->setContentSecurityPolicy($csp);
$expectedResponse->setHeaderTitle($sharedTmplParams['filename']);
- $expectedResponse->setHeaderDetails('shared by ' . $sharedTmplParams['displayName']);
+ $expectedResponse->setHeaderDetails('shared by ' . $sharedTmplParams['shareOwner']);
self::assertEquals($expectedResponse, $response);
}
@@ -677,7 +869,7 @@ class ShareControllerTest extends \Test\TestCase {
->with('token')
->willReturn($share);
- $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) {
+ $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) {
if ($uid === 'ownerUID') {
return $owner;
}
@@ -718,7 +910,7 @@ class ShareControllerTest extends \Test\TestCase {
->with('token')
->willReturn($share);
- $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) {
+ $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) {
if ($uid === 'ownerUID') {
return $owner;
}
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
index 1fb14ad9b8f..7beb4058c4f 100644
--- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
@@ -6,6 +6,7 @@
* @author Bjoern Schiessle <bjoern@schiessle.org>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
+ * @author Julius Härtl <jus@bitgrid.net>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
@@ -237,12 +238,10 @@ class ShareesAPIControllerTest extends TestCase {
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject $config */
$config = $this->createMock(IConfig::class);
- $config->expects($this->exactly(3))
+ $config->expects($this->exactly(1))
->method('getAppValue')
->with($this->anything(), $this->anything(), $this->anything())
->willReturnMap([
- ['core', 'shareapi_only_share_with_group_members', 'no', $apiSetting],
- ['core', 'shareapi_allow_share_dialog_user_enumeration', 'yes', $enumSetting],
['files_sharing', 'lookupServerEnabled', 'yes', 'yes'],
]);
@@ -293,18 +292,15 @@ class ShareesAPIControllerTest extends TestCase {
$this->shareManager->expects($this->any())
->method('shareProviderExists')
- ->will($this->returnCallback(function($shareType) use ($emailSharingEnabled) {
+ ->willReturnCallback(function ($shareType) use ($emailSharingEnabled) {
if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
return $emailSharingEnabled;
} else {
return false;
}
- }));
+ });
$this->assertInstanceOf(Http\DataResponse::class, $sharees->search($search, $itemType, $page, $perPage, $shareType));
-
- $this->assertSame($shareWithGroupOnly, $this->invokePrivate($sharees, 'shareWithGroupOnly'));
- $this->assertSame($shareeEnumeration, $this->invokePrivate($sharees, 'shareeEnumeration'));
}
public function dataSearchInvalid() {
diff --git a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php
index 0ed98f27cd3..f081c947f53 100644
--- a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php
+++ b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php
@@ -2,6 +2,7 @@
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
@@ -100,11 +101,11 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
$userManager = \OC::$server->getUserManager();
$user1 = $userManager->get($this->user1);
- if($user1) {
+ if ($user1) {
$user1->delete();
}
$user2 = $userManager->get($this->user2);
- if($user2) {
+ if ($user2) {
$user2->delete();
}
diff --git a/apps/files_sharing/tests/EncryptedSizePropagationTest.php b/apps/files_sharing/tests/EncryptedSizePropagationTest.php
index 23f552260d6..9a8ff29d70a 100644
--- a/apps/files_sharing/tests/EncryptedSizePropagationTest.php
+++ b/apps/files_sharing/tests/EncryptedSizePropagationTest.php
@@ -42,5 +42,4 @@ class EncryptedSizePropagationTest extends SizePropagationTest {
$this->loginWithEncryption($name);
return new View('/' . $name . '/files');
}
-
}
diff --git a/apps/files_sharing/tests/EtagPropagationTest.php b/apps/files_sharing/tests/EtagPropagationTest.php
index bcab1a92bb8..081b720f820 100644
--- a/apps/files_sharing/tests/EtagPropagationTest.php
+++ b/apps/files_sharing/tests/EtagPropagationTest.php
@@ -2,6 +2,7 @@
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@statuscode.ch>
@@ -456,7 +457,7 @@ class EtagPropagationTest extends PropagationTestCase {
$shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node);
/** @var \OCP\Share\IShare[] $shares */
- $shares = array_filter($shares, function(\OCP\Share\IShare $share) {
+ $shares = array_filter($shares, function (\OCP\Share\IShare $share) {
return $share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2;
});
$this->assertCount(1, $shares);
diff --git a/apps/files_sharing/tests/ExpireSharesJobTest.php b/apps/files_sharing/tests/ExpireSharesJobTest.php
index 4fe1ccc7719..1854ce4990c 100644
--- a/apps/files_sharing/tests/ExpireSharesJobTest.php
+++ b/apps/files_sharing/tests/ExpireSharesJobTest.php
@@ -2,6 +2,7 @@
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
@@ -78,11 +79,11 @@ class ExpireSharesJobTest extends \Test\TestCase {
$userManager = \OC::$server->getUserManager();
$user1 = $userManager->get($this->user1);
- if($user1) {
+ if ($user1) {
$user1->delete();
}
$user2 = $userManager->get($this->user2);
- if($user2) {
+ if ($user2) {
$user2->delete();
}
@@ -213,5 +214,4 @@ class ExpireSharesJobTest extends \Test\TestCase {
$shares = $this->getShares();
$this->assertCount(1, $shares);
}
-
}
diff --git a/apps/files_sharing/tests/External/CacheTest.php b/apps/files_sharing/tests/External/CacheTest.php
index 946faae3d08..be8911961df 100644
--- a/apps/files_sharing/tests/External/CacheTest.php
+++ b/apps/files_sharing/tests/External/CacheTest.php
@@ -2,6 +2,7 @@
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
@@ -69,18 +70,18 @@ class CacheTest extends TestCase {
$this->storage
->expects($this->any())
->method('getId')
- ->will($this->returnValue('dummystorage::'));
+ ->willReturn('dummystorage::');
$this->cache = new \OCA\Files_Sharing\External\Cache(
$this->storage,
$this->cloudIdManager->getCloudId($this->remoteUser, 'http://example.com/owncloud')
);
$this->cache->put(
'test.txt',
- array(
+ [
'mimetype' => 'text/plain',
'size' => 5,
'mtime' => 123,
- )
+ ]
);
}
@@ -107,19 +108,19 @@ class CacheTest extends TestCase {
public function testGetFolderPopulatesOwner() {
$dirId = $this->cache->put(
'subdir',
- array(
+ [
'mimetype' => 'httpd/unix-directory',
'size' => 5,
'mtime' => 123,
- )
+ ]
);
$this->cache->put(
'subdir/contents.txt',
- array(
+ [
'mimetype' => 'text/plain',
'size' => 5,
'mtime' => 123,
- )
+ ]
);
$results = $this->cache->getFolderContentsById($dirId);
@@ -129,5 +130,4 @@ class CacheTest extends TestCase {
$results[0]['displayname_owner']
);
}
-
}
diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php
index 5065c88afc7..5807c3e9fd5 100644
--- a/apps/files_sharing/tests/External/ManagerTest.php
+++ b/apps/files_sharing/tests/External/ManagerTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
@@ -110,7 +111,7 @@ class ManagerTest extends TestCase {
]
)->setMethods(['tryOCMEndPoint'])->getMock();
- $this->testMountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function() {
+ $this->testMountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function () {
return $this->manager;
}, new CloudIdManager());
}
@@ -123,7 +124,6 @@ class ManagerTest extends TestCase {
}
public function testAddShare() {
-
$shareData1 = [
'remote' => 'http://localhost',
'token' => 'token1',
diff --git a/apps/files_sharing/tests/ExternalStorageTest.php b/apps/files_sharing/tests/ExternalStorageTest.php
index b4e84846ed4..b8c1db6c9da 100644
--- a/apps/files_sharing/tests/ExternalStorageTest.php
+++ b/apps/files_sharing/tests/ExternalStorageTest.php
@@ -2,6 +2,7 @@
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
@@ -26,6 +27,7 @@
*/
namespace OCA\Files_Sharing\Tests;
+
use OC\Federation\CloudId;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
@@ -37,39 +39,38 @@ use OCP\Http\Client\IResponse;
* @group DB
*/
class ExternalStorageTest extends \Test\TestCase {
-
- function optionsProvider() {
- return array(
- array(
+ public function optionsProvider() {
+ return [
+ [
'http://remoteserver:8080/owncloud',
'http://remoteserver:8080/owncloud/public.php/webdav/',
- ),
+ ],
// extra slash
- array(
+ [
'http://remoteserver:8080/owncloud/',
'http://remoteserver:8080/owncloud/public.php/webdav/',
- ),
+ ],
// extra path
- array(
+ [
'http://remoteserver:8080/myservices/owncloud/',
'http://remoteserver:8080/myservices/owncloud/public.php/webdav/',
- ),
+ ],
// root path
- array(
+ [
'http://remoteserver:8080/',
'http://remoteserver:8080/public.php/webdav/',
- ),
+ ],
// without port
- array(
+ [
'http://remoteserver/oc.test',
'http://remoteserver/oc.test/public.php/webdav/',
- ),
+ ],
// https
- array(
+ [
'https://remoteserver/',
'https://remoteserver/public.php/webdav/',
- ),
- );
+ ],
+ ];
}
private function getTestStorage($uri) {
@@ -91,7 +92,7 @@ class ExternalStorageTest extends \Test\TestCase {
->willReturn($client);
return new TestSharingExternalStorage(
- array(
+ [
'cloudId' => new CloudId('testOwner@' . $uri, 'testOwner', $uri),
'remote' => $uri,
'owner' => 'testOwner',
@@ -101,7 +102,7 @@ class ExternalStorageTest extends \Test\TestCase {
'manager' => null,
'certificateManager' => $certificateManager,
'HttpClientService' => $httpClientService,
- )
+ ]
);
}
@@ -123,7 +124,6 @@ class ExternalStorageTest extends \Test\TestCase {
* Dummy subclass to make it possible to access private members
*/
class TestSharingExternalStorage extends \OCA\Files_Sharing\External\Storage {
-
public function getBaseUri() {
return $this->createBaseUri();
}
diff --git a/apps/files_sharing/tests/HelperTest.php b/apps/files_sharing/tests/HelperTest.php
index 4a27ca4afec..a4311f908b3 100644
--- a/apps/files_sharing/tests/HelperTest.php
+++ b/apps/files_sharing/tests/HelperTest.php
@@ -47,7 +47,5 @@ class HelperTest extends TestCase {
// cleanup
\OC::$server->getConfig()->deleteSystemValue('share_folder');
-
}
-
}
diff --git a/apps/files_sharing/tests/LockingTest.php b/apps/files_sharing/tests/LockingTest.php
index bb50cc5bd38..c6a799f64a6 100644
--- a/apps/files_sharing/tests/LockingTest.php
+++ b/apps/files_sharing/tests/LockingTest.php
@@ -104,7 +104,6 @@ class LockingTest extends TestCase {
}
public function testChangeLock() {
-
Filesystem::initMountPoints($this->recipientUid);
$recipientView = new View('/' . $this->recipientUid . '/files');
$recipientView->lockFile('bar.txt', ILockingProvider::LOCK_SHARED);
diff --git a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php
index 927cdd8a053..e7457b4096b 100644
--- a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php
@@ -2,6 +2,7 @@
/**
*
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
@@ -51,7 +52,7 @@ class OCSShareAPIMiddlewareTest extends \Test\TestCase {
$this->shareManager = $this->createMock(IManager::class);
$this->l = $this->createMock(IL10N::class);
- $this->l->method('t')->will($this->returnArgument(0));
+ $this->l->method('t')->willReturnArgument(0);
$this->middleware = new OCSShareAPIMiddleware($this->shareManager, $this->l);
}
diff --git a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
index 08d8e6e1486..c290183d046 100644
--- a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
@@ -154,5 +154,4 @@ class ShareInfoMiddlewareTest extends TestCase {
}
class ShareInfoMiddlewareTestController extends Controller {
-
}
diff --git a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
index 54db20c239e..2c33f5617b7 100644
--- a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
@@ -25,6 +26,7 @@
*/
namespace OCA\Files_Sharing\Middleware;
+
use OCA\Files_Sharing\Controller\ExternalSharesController;
use OCA\Files_Sharing\Controller\ShareController;
use OCA\Files_Sharing\Exceptions\S2SException;
@@ -83,7 +85,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
->expects($this->once())
->method('isEnabledForUser')
->with('files_sharing')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->assertTrue(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled'));
}
@@ -93,20 +95,18 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
->expects($this->once())
->method('isEnabledForUser')
->with('files_sharing')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->assertFalse(self::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled'));
}
public function externalSharesChecksDataProvider() {
-
$data = [];
foreach ([false, true] as $annIn) {
foreach ([false, true] as $annOut) {
foreach ([false, true] as $confIn) {
foreach ([false, true] as $confOut) {
-
$res = true;
if (!$annIn && !$confIn) {
$res = false;
@@ -142,11 +142,11 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
$this->reflector
->expects($this->atLeastOnce())
->method('hasAnnotation')
- ->will($this->returnValueMap($annotations));
+ ->willReturnMap($annotations);
$this->config
->method('getAppValue')
- ->will($this->returnValueMap($config));
+ ->willReturnMap($config);
$this->assertEquals($expectedResult, self::invokePrivate($this->sharingCheckMiddleware, 'externalSharesChecks'));
}
@@ -159,16 +159,16 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
->expects($this->once())
->method('isEnabledForUser')
->with('files_sharing')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->reflector
->expects($this->atLeastOnce())
->method('hasAnnotation')
- ->will($this->returnValueMap($annotations));
+ ->willReturnMap($annotations);
$this->config
->method('getAppValue')
- ->will($this->returnValueMap($config));
+ ->willReturnMap($config);
$controller = $this->createMock(ExternalSharesController::class);
@@ -184,14 +184,13 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
}
public function testBeforeControllerWithShareControllerWithSharingEnabled() {
-
$share = $this->createMock(IShare::class);
$this->appManager
->expects($this->once())
->method('isEnabledForUser')
->with('files_sharing')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$controller = $this->createMock(ShareController::class);
@@ -207,7 +206,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
->expects($this->once())
->method('isEnabledForUser')
->with('files_sharing')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->sharingCheckMiddleware->beforeController($this->controllerMock, 'myMethod');
}
@@ -227,6 +226,4 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
public function testAfterExceptionWithS2SException() {
$this->assertEquals(new JSONResponse('My Exception message', 405), $this->sharingCheckMiddleware->afterException($this->controllerMock, 'myMethod', new S2SException('My Exception message')));
}
-
-
}
diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
index 4658cbdf021..0a1737ba37f 100644
--- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
+++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
@@ -2,6 +2,7 @@
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
@@ -23,7 +24,6 @@
namespace OCA\Files_Sharing\Tests\Migration;
-
use OCA\Files_Sharing\Migration\SetPasswordColumn;
use OCA\Files_Sharing\Tests\TestCase;
use OCP\IConfig;
@@ -110,7 +110,7 @@ class SetPasswordColumnTest extends TestCase {
foreach ($allShares as $share) {
if ((int)$share['share_type'] === Share::SHARE_TYPE_LINK) {
- $this->assertNull( $share['share_with']);
+ $this->assertNull($share['share_with']);
$this->assertSame('shareWith', $share['password']);
} else {
$this->assertSame('shareWith', $share['share_with']);
diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php
index f80b5840bcf..ec52db8542e 100644
--- a/apps/files_sharing/tests/MountProviderTest.php
+++ b/apps/files_sharing/tests/MountProviderTest.php
@@ -2,6 +2,7 @@
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Calviño Sánchez <danxuliu@gmail.com>
* @author Maxence Lange <maxence@nextcloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
@@ -76,25 +77,25 @@ class MountProviderTest extends \Test\TestCase {
$share = $this->createMock(IShare::class);
$share->expects($this->any())
->method('getPermissions')
- ->will($this->returnValue($permissions));
+ ->willReturn($permissions);
$share->expects($this->any())
->method('getShareOwner')
- ->will($this->returnValue($owner));
+ ->willReturn($owner);
$share->expects($this->any())
->method('getTarget')
- ->will($this->returnValue($target));
+ ->willReturn($target);
$share->expects($this->any())
->method('getId')
- ->will($this->returnValue($id));
+ ->willReturn($id);
$share->expects($this->any())
->method('getNodeId')
- ->will($this->returnValue($nodeId));
+ ->willReturn($nodeId);
$share->expects($this->any())
->method('getShareTime')
- ->will($this->returnValue(
+ ->willReturn(
// compute share time based on id, simulating share order
new \DateTime('@' . (1469193980 + 1000 * $id))
- ));
+ );
return $share;
}
@@ -111,9 +112,9 @@ class MountProviderTest extends \Test\TestCase {
$this->makeMockShare(2, 100, 'user2', '/share2', 31),
];
$groupShares = [
- $this->makeMockShare(3, 100, 'user2', '/share2', 0),
- $this->makeMockShare(4, 101, 'user2', '/share4', 31),
- $this->makeMockShare(5, 100, 'user1', '/share4', 31),
+ $this->makeMockShare(3, 100, 'user2', '/share2', 0),
+ $this->makeMockShare(4, 101, 'user2', '/share4', 31),
+ $this->makeMockShare(5, 100, 'user1', '/share4', 31),
];
$roomShares = [
$this->makeMockShare(6, 102, 'user2', '/share6', 0),
@@ -125,28 +126,28 @@ class MountProviderTest extends \Test\TestCase {
$circleShares = [];
$this->user->expects($this->any())
->method('getUID')
- ->will($this->returnValue('user1'));
+ ->willReturn('user1');
$this->shareManager->expects($this->at(0))
->method('getSharedWith')
->with('user1', \OCP\Share::SHARE_TYPE_USER)
- ->will($this->returnValue($userShares));
+ ->willReturn($userShares);
$this->shareManager->expects($this->at(1))
->method('getSharedWith')
->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1)
- ->will($this->returnValue($groupShares));
+ ->willReturn($groupShares);
$this->shareManager->expects($this->at(2))
->method('getSharedWith')
->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)
- ->will($this->returnValue($circleShares));
+ ->willReturn($circleShares);
$this->shareManager->expects($this->at(3))
->method('getSharedWith')
->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1)
- ->will($this->returnValue($roomShares));
+ ->willReturn($roomShares);
$this->shareManager->expects($this->any())
->method('newShare')
- ->will($this->returnCallback(function() use ($rootFolder, $userManager) {
+ ->willReturnCallback(function () use ($rootFolder, $userManager) {
return new \OC\Share20\Share($rootFolder, $userManager);
- }));
+ });
$mounts = $this->provider->getMountsForUser($this->user, $this->loader);
$this->assertCount(3, $mounts);
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[0]);
@@ -179,10 +180,10 @@ class MountProviderTest extends \Test\TestCase {
// #0: share as outsider with "group1" and "user1" with same permissions
[
[
- [1, 100, 'user2', '/share2', 31],
+ [1, 100, 'user2', '/share2', 31],
],
[
- [2, 100, 'user2', '/share2', 31],
+ [2, 100, 'user2', '/share2', 31],
],
[
// combined, user share has higher priority
@@ -192,10 +193,10 @@ class MountProviderTest extends \Test\TestCase {
// #1: share as outsider with "group1" and "user1" with different permissions
[
[
- [1, 100, 'user2', '/share', 31],
+ [1, 100, 'user2', '/share', 31],
],
[
- [2, 100, 'user2', '/share', 15],
+ [2, 100, 'user2', '/share', 15],
],
[
// use highest permissions
@@ -207,8 +208,8 @@ class MountProviderTest extends \Test\TestCase {
[
],
[
- [1, 100, 'user2', '/share', 31],
- [2, 100, 'user2', '/share', 31],
+ [1, 100, 'user2', '/share', 31],
+ [2, 100, 'user2', '/share', 31],
],
[
// combined, first group share has higher priority
@@ -220,8 +221,8 @@ class MountProviderTest extends \Test\TestCase {
[
],
[
- [1, 100, 'user2', '/share', 31],
- [2, 100, 'user2', '/share', 15],
+ [1, 100, 'user2', '/share', 31],
+ [2, 100, 'user2', '/share', 15],
],
[
// use higher permissions
@@ -233,7 +234,7 @@ class MountProviderTest extends \Test\TestCase {
[
],
[
- [1, 100, 'user1', '/share', 31],
+ [1, 100, 'user1', '/share', 31],
],
[
// no received share since "user1" is the sharer/owner
@@ -244,8 +245,8 @@ class MountProviderTest extends \Test\TestCase {
[
],
[
- [1, 100, 'user1', '/share', 31],
- [2, 100, 'user1', '/share', 15],
+ [1, 100, 'user1', '/share', 31],
+ [2, 100, 'user1', '/share', 15],
],
[
// no received share since "user1" is the sharer/owner
@@ -256,7 +257,7 @@ class MountProviderTest extends \Test\TestCase {
[
],
[
- [1, 100, 'user2', '/share', 0],
+ [1, 100, 'user2', '/share', 0],
],
[
// no received share since "user1" opted out
@@ -265,10 +266,10 @@ class MountProviderTest extends \Test\TestCase {
// #7: share as outsider with "group1" and "user1" where recipient renamed in between
[
[
- [1, 100, 'user2', '/share2-renamed', 31],
+ [1, 100, 'user2', '/share2-renamed', 31],
],
[
- [2, 100, 'user2', '/share2', 31],
+ [2, 100, 'user2', '/share2', 31],
],
[
// use target of least recent share
@@ -278,10 +279,10 @@ class MountProviderTest extends \Test\TestCase {
// #8: share as outsider with "group1" and "user1" where recipient renamed in between
[
[
- [2, 100, 'user2', '/share2', 31],
+ [2, 100, 'user2', '/share2', 31],
],
[
- [1, 100, 'user2', '/share2-renamed', 31],
+ [1, 100, 'user2', '/share2-renamed', 31],
],
[
// use target of least recent share
@@ -321,16 +322,16 @@ class MountProviderTest extends \Test\TestCase {
$rootFolder = $this->createMock(IRootFolder::class);
$userManager = $this->createMock(IUserManager::class);
- $userShares = array_map(function($shareSpec) {
+ $userShares = array_map(function ($shareSpec) {
return $this->makeMockShare($shareSpec[0], $shareSpec[1], $shareSpec[2], $shareSpec[3], $shareSpec[4]);
}, $userShares);
- $groupShares = array_map(function($shareSpec) {
+ $groupShares = array_map(function ($shareSpec) {
return $this->makeMockShare($shareSpec[0], $shareSpec[1], $shareSpec[2], $shareSpec[3], $shareSpec[4]);
}, $groupShares);
$this->user->expects($this->any())
->method('getUID')
- ->will($this->returnValue('user1'));
+ ->willReturn('user1');
// tests regarding circles are made in the app itself.
$circleShares = [];
@@ -338,24 +339,24 @@ class MountProviderTest extends \Test\TestCase {
$this->shareManager->expects($this->at(0))
->method('getSharedWith')
->with('user1', \OCP\Share::SHARE_TYPE_USER)
- ->will($this->returnValue($userShares));
+ ->willReturn($userShares);
$this->shareManager->expects($this->at(1))
->method('getSharedWith')
->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1)
- ->will($this->returnValue($groupShares));
+ ->willReturn($groupShares);
$this->shareManager->expects($this->at(2))
->method('getSharedWith')
->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)
- ->will($this->returnValue($circleShares));
+ ->willReturn($circleShares);
$this->shareManager->expects($this->at(3))
->method('getSharedWith')
->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1)
- ->will($this->returnValue($roomShares));
+ ->willReturn($roomShares);
$this->shareManager->expects($this->any())
->method('newShare')
- ->will($this->returnCallback(function() use ($rootFolder, $userManager) {
+ ->willReturnCallback(function () use ($rootFolder, $userManager) {
return new \OC\Share20\Share($rootFolder, $userManager);
- }));
+ });
if ($moveFails) {
$this->shareManager->expects($this->any())
diff --git a/apps/files_sharing/tests/PermissionsTest.php b/apps/files_sharing/tests/PermissionsTest.php
index edbaf2f555a..30c6c2a73d2 100644
--- a/apps/files_sharing/tests/PermissionsTest.php
+++ b/apps/files_sharing/tests/PermissionsTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
@@ -137,7 +138,7 @@ class PermissionsTest extends TestCase {
/**
* Test that the permissions of shared directory are returned correctly
*/
- function testGetPermissions() {
+ public function testGetPermissions() {
$sharedDirPerms = $this->sharedStorage->getPermissions('');
$this->assertEquals(31, $sharedDirPerms);
$sharedDirPerms = $this->sharedStorage->getPermissions('textfile.txt');
@@ -151,7 +152,7 @@ class PermissionsTest extends TestCase {
/**
* Test that the permissions of shared directory are returned correctly
*/
- function testGetDirectoryPermissions() {
+ public function testGetDirectoryPermissions() {
$contents = $this->secondView->getDirectoryContent('files/shareddir');
$this->assertEquals('subdir', $contents[0]['name']);
$this->assertEquals(31, $contents[0]['permissions']);
diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php
index 50859984133..ba6b401e65e 100644
--- a/apps/files_sharing/tests/ShareTest.php
+++ b/apps/files_sharing/tests/ShareTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
@@ -33,8 +34,7 @@ namespace OCA\Files_Sharing\Tests;
* @group DB
*/
class ShareTest extends TestCase {
-
- const TEST_FOLDER_NAME = '/folder_share_api_test';
+ public const TEST_FOLDER_NAME = '/folder_share_api_test';
private static $tempStorage;
@@ -127,7 +127,6 @@ class ShareTest extends TestCase {
}
public function testShareWithDifferentShareFolder() {
-
$fileinfo = $this->view->getFileInfo($this->filename);
$folderinfo = $this->view->getFileInfo($this->folder);
@@ -202,7 +201,6 @@ class ShareTest extends TestCase {
* @dataProvider dataProviderTestFileSharePermissions
*/
public function testFileSharePermissions($permission, $expectedvalid) {
-
$pass = true;
try {
$this->share(
@@ -226,17 +224,16 @@ class ShareTest extends TestCase {
$permission5 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE;
$permission6 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE;
- return array(
- array($permission1, false),
- array($permission3, true),
- array($permission4, true),
- array($permission5, false),
- array($permission6, false),
- );
+ return [
+ [$permission1, false],
+ [$permission3, true],
+ [$permission4, true],
+ [$permission5, false],
+ [$permission6, false],
+ ];
}
public function testFileOwner() {
-
$this->share(
\OCP\Share::SHARE_TYPE_USER,
$this->filename,
diff --git a/apps/files_sharing/tests/SharedMountTest.php b/apps/files_sharing/tests/SharedMountTest.php
index 55abbd20cba..59c0e3b76af 100644
--- a/apps/files_sharing/tests/SharedMountTest.php
+++ b/apps/files_sharing/tests/SharedMountTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
@@ -28,6 +29,7 @@
*/
namespace OCA\Files_Sharing\Tests;
+
use OCP\IGroupManager;
use OCP\IUserManager;
@@ -184,7 +186,7 @@ class SharedMountTest extends TestCase {
* share file with a group if a user renames the file the filename should not change
* for the other users
*/
- public function testMoveGroupShare () {
+ public function testMoveGroupShare() {
$testGroup = $this->groupManager->createGroup('testGroup');
$user1 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER1);
$user2 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER2);
@@ -251,20 +253,20 @@ class SharedMountTest extends TestCase {
}
public 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),
- );
+ return [
+ ['/user/files/foo.txt', '/foo.txt', false],
+ ['/user/files/folder/foo.txt', '/folder/foo.txt', false],
+ ['/data/user/files/foo.txt', null, true],
+ ['/data/user/files/', null, true],
+ ['/files/foo.txt', null, true],
+ ['/foo.txt', null, true],
+ ];
}
public function dataPermissionMovedGroupShare() {
$data = [];
- $powerset = function($permissions) {
+ $powerset = function ($permissions) {
$results = [\OCP\Constants::PERMISSION_READ];
foreach ($permissions as $permission) {
@@ -285,7 +287,9 @@ class SharedMountTest extends TestCase {
foreach ($allPermissions as $before) {
foreach ($allPermissions as $after) {
- if ($before === $after) { continue; }
+ if ($before === $after) {
+ continue;
+ }
$data[] = [
'file',
@@ -307,7 +311,9 @@ class SharedMountTest extends TestCase {
foreach ($allPermissions as $before) {
foreach ($allPermissions as $after) {
- if ($before === $after) { continue; }
+ if ($before === $after) {
+ continue;
+ }
$data[] = [
'folder',
@@ -329,10 +335,9 @@ class SharedMountTest extends TestCase {
* @dataProvider dataPermissionMovedGroupShare
*/
public function testPermissionMovedGroupShare($type, $beforePerm, $afterPerm) {
-
if ($type === 'file') {
$path = $this->filename;
- } else if ($type === 'folder') {
+ } elseif ($type === 'folder') {
$path = $this->folder;
}
@@ -454,11 +459,10 @@ class SharedMountTest extends TestCase {
$testGroup->removeUser($user2);
$testGroup->removeUser($user3);
}
-
}
class DummyTestClassSharedMount extends \OCA\Files_Sharing\SharedMount {
- public function __construct($storage, $mountpoint, $arguments = null, $loader = null){
+ public function __construct($storage, $mountpoint, $arguments = null, $loader = null) {
// noop
}
diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php
index 59e411e47f7..7d20d98585f 100644
--- a/apps/files_sharing/tests/SharedStorageTest.php
+++ b/apps/files_sharing/tests/SharedStorageTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
@@ -39,7 +40,6 @@ use OCP\Share\IShare;
* @group DB
*/
class SharedStorageTest extends TestCase {
-
protected function setUp(): void {
parent::setUp();
\OCA\Files_Trashbin\Trashbin::registerHooks();
@@ -406,7 +406,7 @@ class SharedStorageTest extends TestCase {
$mountConfigManager = \OC::$server->getMountProviderCollection();
$mounts = $mountConfigManager->getMountsForUser(\OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3));
- array_walk($mounts, array(\OC\Files\Filesystem::getMountManager(), 'addMount'));
+ array_walk($mounts, [\OC\Files\Filesystem::getMountManager(), 'addMount']);
$this->assertTrue($rootView->file_exists('/' . self::TEST_FILES_SHARING_API_USER3 . '/files/' . $this->filename));
@@ -443,7 +443,7 @@ class SharedStorageTest extends TestCase {
list($sharedStorage,) = $view->resolvePath($this->folder);
$this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage'));
- $sourceStorage = new \OC\Files\Storage\Temporary(array());
+ $sourceStorage = new \OC\Files\Storage\Temporary([]);
$sourceStorage->file_put_contents('foo.txt', 'asd');
$sharedStorage->copyFromStorage($sourceStorage, 'foo.txt', 'bar.txt');
@@ -476,7 +476,7 @@ class SharedStorageTest extends TestCase {
list($sharedStorage,) = $view->resolvePath($this->folder);
$this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage'));
- $sourceStorage = new \OC\Files\Storage\Temporary(array());
+ $sourceStorage = new \OC\Files\Storage\Temporary([]);
$sourceStorage->file_put_contents('foo.txt', 'asd');
$sharedStorage->moveFromStorage($sourceStorage, 'foo.txt', 'bar.txt');
@@ -564,7 +564,6 @@ class SharedStorageTest extends TestCase {
$this->view->unlink($this->folder);
$this->shareManager->deleteShare($share);
-
}
public function testInitWithNonExistingUser() {
diff --git a/apps/files_sharing/tests/TestCase.php b/apps/files_sharing/tests/TestCase.php
index 8ea72943be4..a201974de45 100644
--- a/apps/files_sharing/tests/TestCase.php
+++ b/apps/files_sharing/tests/TestCase.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
@@ -32,7 +33,6 @@
namespace OCA\Files_Sharing\Tests;
-use OC\Files\Cache\Scanner;
use OC\Files\Filesystem;
use OCA\Files_Sharing\AppInfo\Application;
use OCP\Share\IShare;
@@ -48,12 +48,12 @@ use Test\Traits\MountProviderTrait;
abstract class TestCase extends \Test\TestCase {
use MountProviderTrait;
- const TEST_FILES_SHARING_API_USER1 = "test-share-user1";
- const TEST_FILES_SHARING_API_USER2 = "test-share-user2";
- const TEST_FILES_SHARING_API_USER3 = "test-share-user3";
- const TEST_FILES_SHARING_API_USER4 = "test-share-user4";
+ public const TEST_FILES_SHARING_API_USER1 = "test-share-user1";
+ public const TEST_FILES_SHARING_API_USER2 = "test-share-user2";
+ public const TEST_FILES_SHARING_API_USER3 = "test-share-user3";
+ public const TEST_FILES_SHARING_API_USER4 = "test-share-user4";
- const TEST_FILES_SHARING_API_GROUP1 = "test-share-group1";
+ public const TEST_FILES_SHARING_API_GROUP1 = "test-share-group1";
public $filename;
public $data;
@@ -131,11 +131,17 @@ abstract class TestCase extends \Test\TestCase {
public static function tearDownAfterClass(): void {
// cleanup users
$user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER1);
- if ($user !== null) { $user->delete(); }
+ if ($user !== null) {
+ $user->delete();
+ }
$user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER2);
- if ($user !== null) { $user->delete(); }
+ if ($user !== null) {
+ $user->delete();
+ }
$user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3);
- if ($user !== null) { $user->delete(); }
+ if ($user !== null) {
+ $user->delete();
+ }
// delete group
$group = \OC::$server->getGroupManager()->get(self::TEST_FILES_SHARING_API_GROUP1);
@@ -162,7 +168,6 @@ abstract class TestCase extends \Test\TestCase {
* @param bool $password
*/
protected static function loginHelper($user, $create = false, $password = false) {
-
if ($password === false) {
$password = $user;
}
@@ -219,7 +224,6 @@ abstract class TestCase extends \Test\TestCase {
$result->closeCursor();
return $share;
-
}
/**
diff --git a/apps/files_sharing/tests/UnshareChildrenTest.php b/apps/files_sharing/tests/UnshareChildrenTest.php
index d12bda4006c..3d0f13c7212 100644
--- a/apps/files_sharing/tests/UnshareChildrenTest.php
+++ b/apps/files_sharing/tests/UnshareChildrenTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
@@ -35,10 +36,9 @@ namespace OCA\Files_Sharing\Tests;
* @package OCA\Files_Sharing\Tests
*/
class UnshareChildrenTest extends TestCase {
-
protected $subsubfolder;
- const TEST_FOLDER_NAME = '/folder_share_api_test';
+ public const TEST_FOLDER_NAME = '/folder_share_api_test';
private static $tempStorage;
@@ -75,7 +75,6 @@ class UnshareChildrenTest extends TestCase {
* @medium
*/
public function testUnshareChildren() {
-
$fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder);
$this->share(
diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php
index 7ca883c78f8..7f6f3172fcc 100644
--- a/apps/files_sharing/tests/UpdaterTest.php
+++ b/apps/files_sharing/tests/UpdaterTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
@@ -36,8 +37,7 @@ namespace OCA\Files_Sharing\Tests;
* @group DB
*/
class UpdaterTest extends TestCase {
-
- const TEST_FOLDER_NAME = '/folder_share_updater_test';
+ public const TEST_FOLDER_NAME = '/folder_share_updater_test';
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
@@ -199,7 +199,6 @@ class UpdaterTest extends TestCase {
* if a folder gets renamed all children mount points should be renamed too
*/
public function testRename() {
-
$fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
$share = $this->share(
@@ -234,5 +233,4 @@ class UpdaterTest extends TestCase {
// cleanup
$this->shareManager->deleteShare($share);
}
-
}
diff --git a/apps/files_sharing/tests/WatcherTest.php b/apps/files_sharing/tests/WatcherTest.php
index 093f6139dd3..e105bf16161 100644
--- a/apps/files_sharing/tests/WatcherTest.php
+++ b/apps/files_sharing/tests/WatcherTest.php
@@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Morris Jobke <hey@morrisjobke.de>
@@ -110,14 +111,14 @@ class WatcherTest extends TestCase {
* Tests that writing a file using the shared storage will propagate the file
* size to the owner's parent folders.
*/
- function testFolderSizePropagationToOwnerStorage() {
+ public function testFolderSizePropagationToOwnerStorage() {
$initialSizes = self::getOwnerDirSizes('files/container/shareddir');
$textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$dataLen = strlen($textData);
- $this->sharedCache->put('bar.txt', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
+ $this->sharedCache->put('bar.txt', ['mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain']);
$this->sharedStorage->file_put_contents('bar.txt', $textData);
- $this->sharedCache->put('', array('mtime' => 10, 'storage_mtime' => 10, 'size' => '-1', 'mimetype' => 'httpd/unix-directory'));
+ $this->sharedCache->put('', ['mtime' => 10, 'storage_mtime' => 10, 'size' => '-1', 'mimetype' => 'httpd/unix-directory']);
// run the propagation code
$this->sharedStorage->getWatcher()->checkUpdate('');
@@ -140,14 +141,14 @@ class WatcherTest extends TestCase {
* Tests that writing a file using the shared storage will propagate the file
* size to the owner's parent folders.
*/
- function testSubFolderSizePropagationToOwnerStorage() {
+ public function testSubFolderSizePropagationToOwnerStorage() {
$initialSizes = self::getOwnerDirSizes('files/container/shareddir/subdir');
$textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$dataLen = strlen($textData);
- $this->sharedCache->put('subdir/bar.txt', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
+ $this->sharedCache->put('subdir/bar.txt', ['mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain']);
$this->sharedStorage->file_put_contents('subdir/bar.txt', $textData);
- $this->sharedCache->put('subdir', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
+ $this->sharedCache->put('subdir', ['mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain']);
// run the propagation code
$this->sharedStorage->getWatcher()->checkUpdate('subdir');
@@ -172,8 +173,8 @@ class WatcherTest extends TestCase {
* where the key is the path and the value is the size.
* @param string $path
*/
- function getOwnerDirSizes($path) {
- $result = array();
+ public function getOwnerDirSizes($path) {
+ $result = [];
while ($path != '' && $path != '' && $path != '.') {
$cachedData = $this->ownerCache->get($path);