summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/appinfo/v1/publicwebdav.php2
-rw-r--r--apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php3
-rw-r--r--apps/dav/tests/unit/CardDAV/AddressBookImplTest.php8
-rw-r--r--apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php6
-rw-r--r--apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php5
-rw-r--r--apps/dav/tests/unit/CardDAV/SyncServiceTest.php5
-rw-r--r--apps/dav/tests/unit/Comments/CommentsNodeTest.php54
-rw-r--r--apps/dav/tests/unit/Comments/CommentsPluginTest.php44
-rw-r--r--apps/dav/tests/unit/Comments/EntityCollectionTest.php34
-rw-r--r--apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php16
-rw-r--r--apps/dav/tests/unit/Comments/RootCollectionTest.php22
-rw-r--r--apps/dav/tests/unit/Connector/PublicAuthTest.php36
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/AuthTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php16
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php14
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php8
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php12
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php27
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FileTest.php72
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php12
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php60
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/NodeTest.php16
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php44
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php5
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php32
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php8
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php9
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php6
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php12
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php12
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php9
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php21
-rw-r--r--apps/federatedfilesharing/appinfo/app.php15
-rw-r--r--apps/federatedfilesharing/appinfo/routes.php27
-rw-r--r--apps/federatedfilesharing/js/external.js (renamed from apps/files_sharing/js/external.js)36
-rw-r--r--apps/federatedfilesharing/lib/AppInfo/Application.php4
-rw-r--r--apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php324
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php8
-rw-r--r--apps/federatedfilesharing/settings-admin.php2
-rw-r--r--apps/federatedfilesharing/settings-personal.php2
-rw-r--r--apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php200
-rw-r--r--apps/federatedfilesharing/tests/js/externalSpec.js (renamed from apps/files_sharing/tests/js/externalSpec.js)0
-rw-r--r--apps/files/l10n/ja.js1
-rw-r--r--apps/files/l10n/ja.json1
-rw-r--r--apps/files_sharing/ajax/external.php153
-rw-r--r--apps/files_sharing/ajax/shareinfo.php15
-rw-r--r--apps/files_sharing/appinfo/app.php3
-rw-r--r--apps/files_sharing/appinfo/routes.php2
-rw-r--r--apps/files_sharing/js/public.js88
-rw-r--r--apps/files_sharing/l10n/cs_CZ.js2
-rw-r--r--apps/files_sharing/l10n/cs_CZ.json2
-rw-r--r--apps/files_sharing/l10n/fr.js2
-rw-r--r--apps/files_sharing/l10n/fr.json2
-rw-r--r--apps/files_sharing/l10n/it.js2
-rw-r--r--apps/files_sharing/l10n/it.json2
-rw-r--r--apps/files_sharing/l10n/pt_BR.js2
-rw-r--r--apps/files_sharing/l10n/pt_BR.json2
-rw-r--r--apps/files_sharing/l10n/tr.js4
-rw-r--r--apps/files_sharing/l10n/tr.json4
-rw-r--r--apps/files_sharing/lib/API/Share20OCS.php11
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php2
-rw-r--r--apps/files_sharing/lib/Helper.php88
-rw-r--r--apps/files_sharing/lib/share/file.php2
-rw-r--r--apps/files_sharing/templates/public.php4
-rw-r--r--apps/files_sharing/tests/API/Share20OCSTest.php178
-rw-r--r--apps/files_sharing/tests/ApiTest.php4
-rw-r--r--apps/files_sharing/tests/Controllers/ShareControllerTest.php30
-rw-r--r--apps/files_sharing/tests/MountProviderTest.php20
-rw-r--r--apps/systemtags/l10n/it.js40
-rw-r--r--apps/systemtags/l10n/it.json40
-rw-r--r--apps/theming/js/settings-admin.js35
-rw-r--r--apps/theming/lib/controller/themingcontroller.php7
-rw-r--r--apps/theming/lib/util.php57
-rw-r--r--apps/theming/tests/lib/UtilTest.php66
-rw-r--r--apps/theming/tests/lib/controller/ThemingControllerTest.php67
-rw-r--r--apps/updatenotification/l10n/cs_CZ.js4
-rw-r--r--apps/updatenotification/l10n/cs_CZ.json4
83 files changed, 1596 insertions, 624 deletions
diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php
index 261a4d4b96d..2202cbb977c 100644
--- a/apps/dav/appinfo/v1/publicwebdav.php
+++ b/apps/dav/appinfo/v1/publicwebdav.php
@@ -57,7 +57,7 @@ $linkCheckPlugin = new \OCA\DAV\Files\Sharing\PublicLinkCheckPlugin();
$server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin) {
$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
- $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
+ $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
// this is what is thrown when trying to access a non-existing share
diff --git a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php
index 38bddef8769..addacec9b03 100644
--- a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php
@@ -32,6 +32,9 @@ use Sabre\HTTP\Response;
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
protected $nonFatalExceptions = array(
'Sabre\DAV\Exception\NotAuthenticated' => true,
+ // If tokenauth can throw this exception (which is basically as
+ // NotAuthenticated. So not fatal.
+ 'OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden' => true,
// the sync client uses this to find out whether files exist,
// so it is not always an error, log it as debug
'Sabre\DAV\Exception\NotFound' => true,
diff --git a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
index 4ccc841157f..749a98e307e 100644
--- a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
+++ b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
@@ -63,8 +63,12 @@ class AddressBookImplTest extends TestCase {
->disableOriginalConstructor()->getMock();
$this->backend = $this->getMockBuilder('\OCA\DAV\CardDAV\CardDavBackend')
->disableOriginalConstructor()->getMock();
- $this->vCard = $this->getMock('Sabre\VObject\Component\VCard');
- $this->urlGenerator = $this->getMock('OCP\IURLGenerator');
+ $this->vCard = $this->getMockBuilder('Sabre\VObject\Component\VCard')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->addressBookImpl = new AddressBookImpl(
$this->addressBook,
diff --git a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
index be680b219d8..9b11c3b82a0 100644
--- a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
+++ b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
@@ -105,8 +105,10 @@ class BirthdayServiceTest extends TestCase {
$this->cardDav->expects($this->once())->method('getShares')->willReturn([]);
/** @var BirthdayService | \PHPUnit_Framework_MockObject_MockObject $service */
- $service = $this->getMock('\OCA\DAV\CalDAV\BirthdayService',
- ['buildBirthdayFromContact', 'birthdayEvenChanged'], [$this->calDav, $this->cardDav, $this->groupPrincialBackend]);
+ $service = $this->getMockBuilder('\OCA\DAV\CalDAV\BirthdayService')
+ ->setMethods(['buildBirthdayFromContact', 'birthdayEvenChanged'])
+ ->setConstructorArgs([$this->calDav, $this->cardDav, $this->groupPrincialBackend])
+ ->getMock();
if ($expectedOp === 'delete') {
$this->calDav->expects($this->once())->method('getCalendarObject')->willReturn('');
diff --git a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
index 3a9dc144584..0679df4e2f7 100644
--- a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
+++ b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
@@ -57,7 +57,10 @@ class ImageExportPluginTest extends TestCase {
$this->server->tree = $this->tree;
$this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
- $this->plugin = $this->getMock('OCA\DAV\CardDAV\ImageExportPlugin', ['getPhoto'], [$this->logger]);
+ $this->plugin = $this->getMockBuilder('OCA\DAV\CardDAV\ImageExportPlugin')
+ ->setMethods(['getPhoto'])
+ ->setConstructorArgs([$this->logger])
+ ->getMock();
$this->plugin->initialize($this->server);
}
diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
index f63b9acf13a..c9fde55c527 100644
--- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
+++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
@@ -132,7 +132,10 @@ class SyncServiceTest extends TestCase {
$userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock();
$logger = $this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock();
/** @var SyncService | \PHPUnit_Framework_MockObject_MockObject $ss */
- $ss = $this->getMock('OCA\DAV\CardDAV\SyncService', ['ensureSystemAddressBookExists', 'requestSyncReport', 'download'], [$backend, $userManager, $logger]);
+ $ss = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService')
+ ->setMethods(['ensureSystemAddressBookExists', 'requestSyncReport', 'download'])
+ ->setConstructorArgs([$backend, $userManager, $logger])
+ ->getMock();
$ss->method('requestSyncReport')->withAnyParameters()->willReturn(['response' => $response, 'token' => 'sync-token-1']);
$ss->method('ensureSystemAddressBookExists')->willReturn(['id' => 1]);
$ss->method('download')->willReturn([
diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
index 18b18ab8d3b..e7b3dd548c7 100644
--- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
@@ -38,11 +38,21 @@ class CommentsNodeTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
- $this->comment = $this->getMock('\OCP\Comments\IComment');
- $this->userManager = $this->getMock('\OCP\IUserManager');
- $this->userSession = $this->getMock('\OCP\IUserSession');
- $this->logger = $this->getMock('\OCP\ILogger');
+ $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->comment = $this->getMockBuilder('\OCP\Comments\IComment')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userManager = $this->getMockBuilder('\OCP\IUserManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->logger = $this->getMockBuilder('\OCP\ILogger')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->node = new CommentNode(
$this->commentsManager,
@@ -54,7 +64,9 @@ class CommentsNodeTest extends \Test\TestCase {
}
public function testDelete() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
@@ -87,7 +99,9 @@ class CommentsNodeTest extends \Test\TestCase {
* @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testDeleteForbidden() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
@@ -137,7 +151,9 @@ class CommentsNodeTest extends \Test\TestCase {
public function testUpdateComment() {
$msg = 'Hello Earth';
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
@@ -173,7 +189,9 @@ class CommentsNodeTest extends \Test\TestCase {
public function testUpdateCommentLogException() {
$msg = null;
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
@@ -210,7 +228,9 @@ class CommentsNodeTest extends \Test\TestCase {
* @expectedExceptionMessage Message exceeds allowed character limit of
*/
public function testUpdateCommentMessageTooLongException() {
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
@@ -248,7 +268,9 @@ class CommentsNodeTest extends \Test\TestCase {
public function testUpdateForbiddenByUser() {
$msg = 'HaXX0r';
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
@@ -281,7 +303,9 @@ class CommentsNodeTest extends \Test\TestCase {
public function testUpdateForbiddenByType() {
$msg = 'HaXX0r';
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->never())
->method('getUID');
@@ -454,7 +478,11 @@ class CommentsNodeTest extends \Test\TestCase {
$this->userSession->expects($this->once())
->method('getUser')
- ->will($this->returnValue($this->getMock('\OCP\IUser')));
+ ->will($this->returnValue(
+ $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ));
$properties = $this->node->getProperties(null);
diff --git a/apps/dav/tests/unit/Comments/CommentsPluginTest.php b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
index a43ef94a1b9..74223e8d5ca 100644
--- a/apps/dav/tests/unit/Comments/CommentsPluginTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
@@ -55,8 +55,12 @@ class CommentsPluginTest extends \Test\TestCase {
->setMethods(['getRequestUri'])
->getMock();
- $this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
- $this->userSession = $this->getMock('\OCP\IUserSession');
+ $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->plugin = new CommentsPluginImplementation($this->commentsManager, $this->userSession);
}
@@ -80,7 +84,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('alice'));
@@ -174,7 +180,9 @@ class CommentsPluginTest extends \Test\TestCase {
$path = 'comments/files/666';
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->never())
->method('getUID');
@@ -256,7 +264,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->never())
->method('getUID');
@@ -342,7 +352,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->never())
->method('getUID');
@@ -430,7 +442,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('alice'));
@@ -522,7 +536,9 @@ class CommentsPluginTest extends \Test\TestCase {
$requestData = json_encode($commentData);
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('alice'));
@@ -599,7 +615,11 @@ class CommentsPluginTest extends \Test\TestCase {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
- ->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
+ ->will($this->returnValue(
+ $this->getMockBuilder('\Sabre\DAV\INode')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ));
$this->server->expects($this->any())
->method('getRequestUri')
@@ -618,7 +638,11 @@ class CommentsPluginTest extends \Test\TestCase {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
- ->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
+ ->will($this->returnValue(
+ $this->getMockBuilder('\Sabre\DAV\INode')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ));
$this->server->expects($this->any())
->method('getRequestUri')
diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
index d5a6c940545..c96db595394 100644
--- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
@@ -38,10 +38,18 @@ class EntityCollectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
- $this->userManager = $this->getMock('\OCP\IUserManager');
- $this->userSession = $this->getMock('\OCP\IUserSession');
- $this->logger = $this->getMock('\OCP\ILogger');
+ $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userManager = $this->getMockBuilder('\OCP\IUserManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->logger = $this->getMockBuilder('\OCP\ILogger')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->collection = new \OCA\DAV\Comments\EntityCollection(
'19',
@@ -61,7 +69,11 @@ class EntityCollectionTest extends \Test\TestCase {
$this->commentsManager->expects($this->once())
->method('get')
->with('55')
- ->will($this->returnValue($this->getMock('\OCP\Comments\IComment')));
+ ->will($this->returnValue(
+ $this->getMockBuilder('\OCP\Comments\IComment')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ));
$node = $this->collection->getChild('55');
$this->assertTrue($node instanceof \OCA\DAV\Comments\CommentNode);
@@ -83,7 +95,11 @@ class EntityCollectionTest extends \Test\TestCase {
$this->commentsManager->expects($this->once())
->method('getForObject')
->with('files', '19')
- ->will($this->returnValue([$this->getMock('\OCP\Comments\IComment')]));
+ ->will($this->returnValue([
+ $this->getMockBuilder('\OCP\Comments\IComment')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ]));
$result = $this->collection->getChildren();
@@ -96,7 +112,11 @@ class EntityCollectionTest extends \Test\TestCase {
$this->commentsManager->expects($this->once())
->method('getForObject')
->with('files', '19', 5, 15, $dt)
- ->will($this->returnValue([$this->getMock('\OCP\Comments\IComment')]));
+ ->will($this->returnValue([
+ $this->getMockBuilder('\OCP\Comments\IComment')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ]));
$result = $this->collection->findChildren(5, 15, $dt);
diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
index 14fc99d6e8b..771e9d48569 100644
--- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
@@ -42,10 +42,18 @@ class EntityTypeCollectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
- $this->userManager = $this->getMock('\OCP\IUserManager');
- $this->userSession = $this->getMock('\OCP\IUserSession');
- $this->logger = $this->getMock('\OCP\ILogger');
+ $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userManager = $this->getMockBuilder('\OCP\IUserManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->logger = $this->getMockBuilder('\OCP\ILogger')
+ ->disableOriginalConstructor()
+ ->getMock();
$instance = $this;
diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php
index abf965f9d9b..322db53d7b9 100644
--- a/apps/dav/tests/unit/Comments/RootCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php
@@ -46,13 +46,23 @@ class RootCollectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->user = $this->getMock('\OCP\IUser');
-
- $this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
- $this->userManager = $this->getMock('\OCP\IUserManager');
- $this->userSession = $this->getMock('\OCP\IUserSession');
+ $this->user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userManager = $this->getMockBuilder('\OCP\IUserManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->dispatcher = new EventDispatcher();
- $this->logger = $this->getMock('\OCP\ILogger');
+ $this->logger = $this->getMockBuilder('\OCP\ILogger')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->collection = new \OCA\DAV\Comments\RootCollection(
$this->commentsManager,
diff --git a/apps/dav/tests/unit/Connector/PublicAuthTest.php b/apps/dav/tests/unit/Connector/PublicAuthTest.php
index bc67772ef84..e985775f41c 100644
--- a/apps/dav/tests/unit/Connector/PublicAuthTest.php
+++ b/apps/dav/tests/unit/Connector/PublicAuthTest.php
@@ -51,9 +51,15 @@ class PublicAuthTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->session = $this->getMock('\OCP\ISession');
- $this->request = $this->getMock('\OCP\IRequest');
- $this->shareManager = $this->getMock('\OCP\Share\IManager');
+ $this->session = $this->getMockBuilder('\OCP\ISession')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->request = $this->getMockBuilder('\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->auth = new \OCA\DAV\Connector\PublicAuth(
$this->request,
@@ -86,7 +92,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testShareNoPassword() {
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')
+ ->disableOriginalConstructor()
+ ->getMock();
$share->method('getPassword')->willReturn(null);
$this->shareManager->expects($this->once())
@@ -99,7 +107,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testSharePasswordFancyShareType() {
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')
+ ->disableOriginalConstructor()
+ ->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(42);
@@ -114,7 +124,9 @@ class PublicAuthTest extends \Test\TestCase {
public function testSharePasswordRemote() {
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')
+ ->disableOriginalConstructor()
+ ->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_REMOTE);
@@ -128,7 +140,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testSharePasswordLinkValidPassword() {
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')
+ ->disableOriginalConstructor()
+ ->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
@@ -148,7 +162,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testSharePasswordLinkValidSession() {
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')
+ ->disableOriginalConstructor()
+ ->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getId')->willReturn('42');
@@ -172,7 +188,9 @@ class PublicAuthTest extends \Test\TestCase {
}
public function testSharePasswordLinkInvalidSession() {
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')
+ ->disableOriginalConstructor()
+ ->getMock();
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getId')->willReturn('42');
diff --git a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
index 9564298f23a..92798797d6c 100644
--- a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
@@ -586,7 +586,9 @@ class AuthTest extends TestCase {
->disableOriginalConstructor()
->getMock();
/** @var IUser */
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->method('getUID')->willReturn('MyTestUser');
$this->userSession
->expects($this->any())
diff --git a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
index 3859e4f2790..890d11465a4 100644
--- a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
@@ -41,7 +41,9 @@ class BlockLegacyClientPluginTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMock('\OCP\IConfig');
+ $this->config = $this->getMockBuilder('\OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->blockLegacyClientVersionPlugin = new BlockLegacyClientPlugin($this->config);
}
@@ -66,7 +68,9 @@ class BlockLegacyClientPluginTest extends TestCase {
*/
public function testBeforeHandlerException($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$request
->expects($this->once())
->method('getHeader')
@@ -101,7 +105,9 @@ class BlockLegacyClientPluginTest extends TestCase {
*/
public function testBeforeHandlerSuccess($userAgent) {
/** @var \Sabre\HTTP\RequestInterface $request */
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$request
->expects($this->once())
->method('getHeader')
@@ -119,7 +125,9 @@ class BlockLegacyClientPluginTest extends TestCase {
public function testBeforeHandlerNoUserAgent() {
/** @var \Sabre\HTTP\RequestInterface $request */
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$request
->expects($this->once())
->method('getHeader')
diff --git a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php
index 6ade77e34f3..70ef5233598 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php
@@ -35,8 +35,12 @@ class CommentsPropertiesPluginTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
- $this->userSession = $this->getMock('\OCP\IUserSession');
+ $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->server = $this->getMockBuilder('\Sabre\DAV\Server')
->disableOriginalConstructor()
@@ -114,7 +118,11 @@ class CommentsPropertiesPluginTest extends \Test\TestCase {
public function userProvider() {
return [
- [$this->getMock('\OCP\IUser')],
+ [
+ $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ],
[null]
];
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
index f4f5e13fcf8..0fb012d9538 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
@@ -67,7 +67,9 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
$userId = $this->getUniqueID('testcustompropertiesuser');
- $this->user = $this->getMock('\OCP\IUser');
+ $this->user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue($userId));
diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
index 66f0a803807..7511d6b02f7 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
@@ -39,8 +39,12 @@ class DirectoryTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->view = $this->getMock('OC\Files\View', array(), array(), '', false);
- $this->info = $this->getMock('OC\Files\FileInfo', array(), array(), '', false);
+ $this->view = $this->getMockBuilder('OC\Files\View')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->info = $this->getMockBuilder('OC\Files\FileInfo')
+ ->disableOriginalConstructor()
+ ->getMock();
}
private function getDir($path = '/') {
diff --git a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php
index 28e4bd7e836..797f306c7ba 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php
@@ -43,7 +43,9 @@ class DummyGetResponsePluginTest extends TestCase {
public function testInitialize() {
/** @var \Sabre\DAV\Server $server */
- $server = $this->getMock('\Sabre\DAV\Server');
+ $server = $this->getMockBuilder('\Sabre\DAV\Server')
+ ->disableOriginalConstructor()
+ ->getMock();
$server
->expects($this->once())
->method('on')
@@ -55,9 +57,13 @@ class DummyGetResponsePluginTest extends TestCase {
public function testHttpGet() {
/** @var \Sabre\HTTP\RequestInterface $request */
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
/** @var \Sabre\HTTP\ResponseInterface $response */
- $response = $server = $this->getMock('\Sabre\HTTP\ResponseInterface');
+ $response = $server = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$response
->expects($this->once())
->method('setBody');
diff --git a/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php b/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php
index 44e9e17b695..61f78d13547 100644
--- a/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/Exception/ForbiddenTest.php
@@ -47,7 +47,9 @@ class ForbiddenTest extends \Test\TestCase {
EOD;
$ex = new Forbidden($message, $retry);
- $server = $this->getMock('Sabre\DAV\Server');
+ $server = $this->getMockBuilder('Sabre\DAV\Server')
+ ->disableOriginalConstructor()
+ ->getMock();
$ex->serialize($server, $error);
// assert
diff --git a/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php b/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php
index 0e1224f596a..25960cc3cb8 100644
--- a/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/Exception/InvalidPathTest.php
@@ -48,7 +48,9 @@ class InvalidPathTest extends \Test\TestCase {
EOD;
$ex = new InvalidPath($message, $retry);
- $server = $this->getMock('Sabre\DAV\Server');
+ $server = $this->getMockBuilder('Sabre\DAV\Server')
+ ->disableOriginalConstructor()
+ ->getMock();
$ex->serialize($server, $error);
// assert
diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
index 096e4439074..29d2ce469a1 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
@@ -42,7 +42,9 @@ class FakeLockerPluginTest extends TestCase {
public function testInitialize() {
/** @var \Sabre\DAV\Server $server */
- $server = $this->getMock('\Sabre\DAV\Server');
+ $server = $this->getMockBuilder('\Sabre\DAV\Server')
+ ->disableOriginalConstructor()
+ ->getMock();
$server
->expects($this->at(0))
->method('on')
@@ -82,7 +84,9 @@ class FakeLockerPluginTest extends TestCase {
$propFind = $this->getMockBuilder('\Sabre\DAV\PropFind')
->disableOriginalConstructor()
->getMock();
- $node = $this->getMock('\Sabre\DAV\INode');
+ $node = $this->getMockBuilder('\Sabre\DAV\INode')
+ ->disableOriginalConstructor()
+ ->getMock();
$propFind->expects($this->at(0))
->method('handle')
@@ -137,15 +141,20 @@ class FakeLockerPluginTest extends TestCase {
* @param array $expected
*/
public function testValidateTokens(array $input, array $expected) {
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->fakeLockerPlugin->validateTokens($request, $input);
$this->assertSame($expected, $input);
}
public function testFakeLockProvider() {
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$response = new Response();
- $server = $this->getMock('\Sabre\DAV\Server');
+ $server = $this->getMockBuilder('\Sabre\DAV\Server')
+ ->getMock();
$this->fakeLockerPlugin->initialize($server);
$request->expects($this->exactly(2))
@@ -160,8 +169,12 @@ class FakeLockerPluginTest extends TestCase {
}
public function testFakeUnlockProvider() {
- $request = $this->getMock('\Sabre\HTTP\RequestInterface');
- $response = $this->getMock('\Sabre\HTTP\ResponseInterface');
+ $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $response = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
$response->expects($this->once())
->method('setStatus')
diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php
index 0f404a6a16c..bb87027bd1d 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php
@@ -65,7 +65,9 @@ class FileTest extends \Test\TestCase {
}
private function getMockStorage() {
- $storage = $this->getMock('\OCP\Files\Storage');
+ $storage = $this->getMockBuilder('\OCP\Files\Storage')
+ ->disableOriginalConstructor()
+ ->getMock();
$storage->expects($this->any())
->method('getId')
->will($this->returnValue('home::someuser'));
@@ -144,13 +146,14 @@ class FileTest extends \Test\TestCase {
*/
public function testSimplePutFails($thrownException, $expectedException, $checkPreviousClass = true) {
// setup
- $storage = $this->getMock(
- '\OC\Files\Storage\Local',
- ['fopen'],
- [['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]
- );
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Local')
+ ->setMethods(['fopen'])
+ ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]])
+ ->getMock();
\OC\Files\Filesystem::mount($storage, [], $this->user . '/');
- $view = $this->getMock('\OC\Files\View', array('getRelativePath', 'resolvePath'), array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['getRelativePath', 'resolvePath'])
+ ->getMock();
$view->expects($this->atLeastOnce())
->method('resolvePath')
->will($this->returnCallback(
@@ -202,13 +205,14 @@ class FileTest extends \Test\TestCase {
*/
public function testChunkedPutFails($thrownException, $expectedException, $checkPreviousClass = false) {
// setup
- $storage = $this->getMock(
- '\OC\Files\Storage\Local',
- ['fopen'],
- [['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]
- );
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Local')
+ ->setMethods(['fopen'])
+ ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]])
+ ->getMock();
\OC\Files\Filesystem::mount($storage, [], $this->user . '/');
- $view = $this->getMock('\OC\Files\View', ['getRelativePath', 'resolvePath'], []);
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['getRelativePath', 'resolvePath'])
+ ->getMock();
$view->expects($this->atLeastOnce())
->method('resolvePath')
->will($this->returnCallback(
@@ -526,8 +530,9 @@ class FileTest extends \Test\TestCase {
*/
public function testSimplePutFailsSizeCheck() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array('rename', 'getRelativePath', 'filesize'));
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['rename', 'getRelativePath', 'filesize'])
+ ->getMock();
$view->expects($this->any())
->method('rename')
->withAnyParameters()
@@ -643,7 +648,9 @@ class FileTest extends \Test\TestCase {
*/
public function testSimplePutInvalidChars() {
// setup
- $view = $this->getMock('\OC\Files\View', array('getRelativePath'));
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['getRelativePath'])
+ ->getMock();
$view->expects($this->any())
->method('getRelativePath')
->will($this->returnArgument(0));
@@ -678,7 +685,9 @@ class FileTest extends \Test\TestCase {
*/
public function testSetNameInvalidChars() {
// setup
- $view = $this->getMock('\OC\Files\View', array('getRelativePath'));
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['getRelativePath'])
+ ->getMock();
$view->expects($this->any())
->method('getRelativePath')
@@ -695,8 +704,9 @@ class FileTest extends \Test\TestCase {
*/
public function testUploadAbort() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array('rename', 'getRelativePath', 'filesize'));
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['rename', 'getRelativePath', 'filesize'])
+ ->getMock();
$view->expects($this->any())
->method('rename')
->withAnyParameters()
@@ -740,8 +750,8 @@ class FileTest extends \Test\TestCase {
*/
public function testDeleteWhenAllowed() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->getMock();
$view->expects($this->once())
->method('unlink')
@@ -762,8 +772,8 @@ class FileTest extends \Test\TestCase {
*/
public function testDeleteThrowsWhenDeletionNotAllowed() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->getMock();
$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array(
'permissions' => 0
@@ -780,8 +790,8 @@ class FileTest extends \Test\TestCase {
*/
public function testDeleteThrowsWhenDeletionFailed() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->getMock();
// but fails
$view->expects($this->once())
@@ -803,8 +813,8 @@ class FileTest extends \Test\TestCase {
*/
public function testDeleteThrowsWhenDeletionThrows() {
// setup
- $view = $this->getMock('\OC\Files\View',
- array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->getMock();
// but fails
$view->expects($this->once())
@@ -953,7 +963,9 @@ class FileTest extends \Test\TestCase {
* @expectedException \Sabre\DAV\Exception\ServiceUnavailable
*/
public function testGetFopenFails() {
- $view = $this->getMock('\OC\Files\View', ['fopen'], array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['fopen'])
+ ->getMock();
$view->expects($this->atLeastOnce())
->method('fopen')
->will($this->returnValue(false));
@@ -971,7 +983,9 @@ class FileTest extends \Test\TestCase {
* @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden
*/
public function testGetFopenThrows() {
- $view = $this->getMock('\OC\Files\View', ['fopen'], array());
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['fopen'])
+ ->getMock();
$view->expects($this->atLeastOnce())
->method('fopen')
->willThrowException(new ForbiddenException('', true));
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
index 2b3f3e15d1a..9419296bd5b 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
@@ -89,11 +89,15 @@ class FilesPluginTest extends TestCase {
$this->view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
- $this->config = $this->getMock('\OCP\IConfig');
+ $this->config = $this->getMockBuilder('\OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->config->expects($this->any())->method('getSystemValue')
->with($this->equalTo('data-fingerprint'), $this->equalTo(''))
->willReturn('my_fingerprint');
- $this->request = $this->getMock('\OCP\IRequest');
+ $this->request = $this->getMockBuilder('\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->plugin = new FilesPlugin(
$this->tree,
@@ -275,7 +279,9 @@ class FilesPluginTest extends TestCase {
$this->tree,
$this->view,
$this->config,
- $this->getMock('\OCP\IRequest'),
+ $this->getMockBuilder('\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock(),
true);
$this->plugin->initialize($this->server);
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
index baf4259b215..71beccd079c 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
@@ -82,11 +82,19 @@ class FilesReportPluginTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
- $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
- $this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper');
- $this->userSession = $this->getMock('\OCP\IUserSession');
+ $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('testuser'));
@@ -114,7 +122,11 @@ class FilesReportPluginTest extends \Test\TestCase {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
- ->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
+ ->will($this->returnValue(
+ $this->getMockBuilder('\Sabre\DAV\INode')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ));
$this->server->expects($this->any())
->method('getRequestUri')
@@ -133,7 +145,11 @@ class FilesReportPluginTest extends \Test\TestCase {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
- ->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
+ ->will($this->returnValue(
+ $this->getMockBuilder('\Sabre\DAV\INode')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ));
$this->server->expects($this->any())
->method('getRequestUri')
@@ -337,14 +353,18 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('getSize')
->will($this->returnValue(1024));
- $config = $this->getMock('\OCP\IConfig');
+ $config = $this->getMockBuilder('\OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->server->addPlugin(
new \OCA\DAV\Connector\Sabre\FilesPlugin(
$this->tree,
$this->view,
$config,
- $this->getMock('\OCP\IRequest')
+ $this->getMockBuilder('\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock()
)
);
$this->plugin->initialize($this->server);
@@ -494,7 +514,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isAdmin')
->will($this->returnValue(true));
- $tag1 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag1->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -502,7 +524,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isUserVisible')
->will($this->returnValue(true));
- $tag2 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag2->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -539,7 +563,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isAdmin')
->will($this->returnValue(false));
- $tag1 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag1->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -547,7 +573,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isUserVisible')
->will($this->returnValue(true));
- $tag2 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag2->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -573,7 +601,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isAdmin')
->will($this->returnValue(false));
- $tag1 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag1->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
@@ -581,7 +611,9 @@ class FilesReportPluginTest extends \Test\TestCase {
->method('isUserVisible')
->will($this->returnValue(true));
- $tag2 = $this->getMock('\OCP\SystemTag\ISystemTag');
+ $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag')
+ ->disableOriginalConstructor()
+ ->getMock();
$tag2->expects($this->any())
->method('getId')
->will($this->returnValue('123'));
diff --git a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php
index ca7d09565ce..43e875d25d7 100644
--- a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php
@@ -40,7 +40,7 @@ class MaintenancePluginTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMock('\OCP\IConfig');
+ $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
$this->maintenancePlugin = new MaintenancePlugin($this->config);
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
index 3c7eb6f72c3..328e99c9fbe 100644
--- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php
@@ -66,7 +66,9 @@ class NodeTest extends \Test\TestCase {
$info->expects($this->any())
->method('getType')
->will($this->returnValue($type));
- $view = $this->getMock('\OC\Files\View');
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->disableOriginalConstructor()
+ ->getMock();
$node = new \OCA\DAV\Connector\Sabre\File($view, $info);
$this->assertEquals($expected, $node->getDavPermissions());
@@ -116,10 +118,14 @@ class NodeTest extends \Test\TestCase {
* @dataProvider sharePermissionsProvider
*/
public function testSharePermissions($type, $user, $permissions, $expected) {
- $storage = $this->getMock('\OCP\Files\Storage');
+ $storage = $this->getMockBuilder('\OCP\Files\Storage')
+ ->disableOriginalConstructor()
+ ->getMock();
$storage->method('getPermissions')->willReturn($permissions);
- $mountpoint = $this->getMock('\OCP\Files\Mount\IMountPoint');
+ $mountpoint = $this->getMockBuilder('\OCP\Files\Mount\IMountPoint')
+ ->disableOriginalConstructor()
+ ->getMock();
$mountpoint->method('getMountPoint')->willReturn('myPath');
$shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock();
$share = $this->getMockBuilder('OCP\Share\IShare')->disableOriginalConstructor()->getMock();
@@ -142,7 +148,9 @@ class NodeTest extends \Test\TestCase {
$info->method('getType')->willReturn($type);
$info->method('getMountPoint')->willReturn($mountpoint);
- $view = $this->getMock('\OC\Files\View');
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->disableOriginalConstructor()
+ ->getMock();
$node = new \OCA\DAV\Connector\Sabre\File($view, $info);
$this->invokePrivate($node, 'shareManager', [$shareManager]);
diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
index 96d4357660e..617a0bd5dfa 100644
--- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
@@ -74,7 +74,9 @@ class TestDoubleFileView extends \OC\Files\View {
class ObjectTreeTest extends \Test\TestCase {
public function getFileInfoMock() {
- $mock = $this->getMock('\OCP\Files\FileInfo');
+ $mock = $this->getMockBuilder('\OCP\Files\FileInfo')
+ ->disableOriginalConstructor()
+ ->getMock();
$mock
->expects($this->any())
->method('isDeletable')
@@ -147,9 +149,10 @@ class ObjectTreeTest extends \Test\TestCase {
$info = new FileInfo('', null, null, array(), null);
$rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info);
- $objectTree = $this->getMock('\OCA\DAV\Connector\Sabre\ObjectTree',
- array('nodeExists', 'getNodeForPath'),
- array($rootDir, $view));
+ $objectTree = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\ObjectTree')
+ ->setMethods(['nodeExists', 'getNodeForPath'])
+ ->setConstructorArgs([$rootDir, $view])
+ ->getMock();
$objectTree->expects($this->once())
->method('getNodeForPath')
@@ -180,9 +183,15 @@ class ObjectTreeTest extends \Test\TestCase {
$rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor()
->getMock();
- $mountManager = $this->getMock('\OC\Files\Mount\Manager');
- $view = $this->getMock('\OC\Files\View');
- $fileInfo = $this->getMock('\OCP\Files\FileInfo');
+ $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileInfo = $this->getMockBuilder('\OCP\Files\FileInfo')
+ ->disableOriginalConstructor()
+ ->getMock();
$fileInfo->expects($this->once())
->method('getType')
->will($this->returnValue($type));
@@ -290,7 +299,9 @@ class ObjectTreeTest extends \Test\TestCase {
$storage = new Temporary([]);
- $view = $this->getMock('\OC\Files\View', ['resolvePath']);
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['resolvePath'])
+ ->getMock();
$view->expects($this->once())
->method('resolvePath')
->will($this->returnCallback(function($path) use ($storage){
@@ -300,7 +311,8 @@ class ObjectTreeTest extends \Test\TestCase {
$rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor()
->getMock();
- $mountManager = $this->getMock('\OC\Files\Mount\Manager');
+ $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ ->getMock();
$tree = new \OCA\DAV\Connector\Sabre\ObjectTree();
$tree->init($rootNode, $view, $mountManager);
@@ -314,7 +326,9 @@ class ObjectTreeTest extends \Test\TestCase {
$storage = new Temporary([]);
- $view = $this->getMock('\OC\Files\View', ['resolvePath']);
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['resolvePath'])
+ ->getMock();
$view->expects($this->any())
->method('resolvePath')
->will($this->returnCallback(function ($path) use ($storage) {
@@ -324,7 +338,8 @@ class ObjectTreeTest extends \Test\TestCase {
$rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor()
->getMock();
- $mountManager = $this->getMock('\OC\Files\Mount\Manager');
+ $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ ->getMock();
$tree = new \OCA\DAV\Connector\Sabre\ObjectTree();
$tree->init($rootNode, $view, $mountManager);
@@ -347,9 +362,10 @@ class ObjectTreeTest extends \Test\TestCase {
$info = new FileInfo('', null, null, array(), null);
$rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info);
- $objectTree = $this->getMock('\OCA\DAV\Connector\Sabre\ObjectTree',
- array('nodeExists', 'getNodeForPath'),
- array($rootDir, $view));
+ $objectTree = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\ObjectTree')
+ ->setMethods(['nodeExists', 'getNodeForPath'])
+ ->setConstructorArgs([$rootDir, $view])
+ ->getMock();
$sourceNode = $this->getMockBuilder('\Sabre\DAV\ICollection')
->disableOriginalConstructor()
diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
index c6a1bc3dd4b..bf827fd3585 100644
--- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
@@ -212,7 +212,10 @@ class QuotaPluginTest extends \Test\TestCase {
private function buildFileViewMock($quota, $checkedPath) {
// mock filesysten
- $view = $this->getMock('\OC\Files\View', array('free_space'), array(), '', false);
+ $view = $this->getMockBuilder('\OC\Files\View')
+ ->setMethods(['free_space'])
+ ->disableOriginalConstructor()
+ ->getMock();
$view->expects($this->any())
->method('free_space')
->with($this->identicalTo($checkedPath))
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
index a69e21c9e32..efa1f0a7a5c 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
@@ -35,7 +35,9 @@ use Test\Traits\EncryptionTrait;
class PartFileInRootUploadTest extends UploadTest {
protected function setUp() {
$config = \OC::$server->getConfig();
- $mockConfig = $this->getMock('\OCP\IConfig');
+ $mockConfig = $this->getMockBuilder('\OCP\IConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$mockConfig->expects($this->any())
->method('getSystemValue')
->will($this->returnCallback(function ($key, $default) use ($config) {
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php
index 292c66c003f..3e3f9e59946 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php
@@ -62,7 +62,9 @@ abstract class RequestTest extends TestCase {
\OC::$server->getUserSession(),
\OC::$server->getMountManager(),
\OC::$server->getTagManager(),
- $this->getMock('\OCP\IRequest')
+ $this->getMockBuilder('\OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock()
);
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
index b2d4384133d..0c6446e2911 100644
--- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
@@ -56,17 +56,25 @@ class SharesPluginTest extends \Test\TestCase {
$this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
->disableOriginalConstructor()
->getMock();
- $this->shareManager = $this->getMock('\OCP\Share\IManager');
- $user = $this->getMock('\OCP\IUser');
+ $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('user1'));
- $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
$userSession->expects($this->once())
->method('getUser')
->will($this->returnValue($user));
- $this->userFolder = $this->getMock('\OCP\Files\Folder');
+ $this->userFolder = $this->getMockBuilder('\OCP\Files\Folder')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->plugin = new \OCA\DAV\Connector\Sabre\SharesPlugin(
$this->tree,
@@ -92,7 +100,9 @@ class SharesPluginTest extends \Test\TestCase {
->will($this->returnValue('/subdir'));
// node API nodes
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->userFolder->expects($this->once())
->method('get')
@@ -168,15 +178,21 @@ class SharesPluginTest extends \Test\TestCase {
->will($this->returnValue('/subdir'));
// node API nodes
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')
+ ->disableOriginalConstructor()
+ ->getMock();
$node->expects($this->any())
->method('getId')
->will($this->returnValue(123));
- $node1 = $this->getMock('\OCP\Files\File');
+ $node1 = $this->getMockBuilder('\OCP\Files\File')
+ ->disableOriginalConstructor()
+ ->getMock();
$node1->expects($this->any())
->method('getId')
->will($this->returnValue(111));
- $node2 = $this->getMock('\OCP\Files\File');
+ $node2 = $this->getMockBuilder('\OCP\Files\File')
+ ->disableOriginalConstructor()
+ ->getMock();
$node2->expects($this->any())
->method('getId')
->will($this->returnValue(222));
diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
index 96bd39de899..8e6e5149714 100644
--- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
@@ -65,8 +65,12 @@ class TagsPluginTest extends \Test\TestCase {
$this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
->disableOriginalConstructor()
->getMock();
- $this->tagger = $this->getMock('\OCP\ITags');
- $this->tagManager = $this->getMock('\OCP\ITagManager');
+ $this->tagger = $this->getMockBuilder('\OCP\ITags')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->tagManager = $this->getMockBuilder('\OCP\ITagManager')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->tagManager->expects($this->any())
->method('load')
->with('files')
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
index 038ba24aa6d..7e0e98eb78d 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
@@ -47,9 +47,12 @@ class SystemTagMappingNodeTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
- $this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper');
- $this->user = $this->getMock('\OCP\IUser');
+ $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
+ ->getMock();
+ $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper')
+ ->getMock();
+ $this->user = $this->getMockBuilder('\OCP\IUser')
+ ->getMock();
}
public function getMappingNode($tag = null) {
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
index f5207ef18d9..0a6c6b93560 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
@@ -46,8 +46,10 @@ class SystemTagNodeTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
- $this->user = $this->getMock('\OCP\IUser');
+ $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
+ ->getMock();
+ $this->user = $this->getMockBuilder('\OCP\IUser')
+ ->getMock();
}
protected function getTagNode($isAdmin = true, $tag = null) {
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
index 9cfcafc4ea6..d8d955d89ef 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
@@ -83,10 +83,14 @@ class SystemTagPluginTest extends \Test\TestCase {
$this->server = new \Sabre\DAV\Server($this->tree);
- $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
- $this->groupManager = $this->getMock('\OCP\IGroupManager');
- $this->user = $this->getMock('\OCP\IUser');
- $this->userSession = $this->getMock('\OCP\IUserSession');
+ $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
+ ->getMock();
+ $this->groupManager = $this->getMockBuilder('\OCP\IGroupManager')
+ ->getMock();
+ $this->user = $this->getMockBuilder('\OCP\IUser')
+ ->getMock();
+ $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->getMock();
$this->userSession
->expects($this->any())
->method('getUser')
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
index b37a01af5fc..05a84731338 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
@@ -41,19 +41,23 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
+ $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
+ ->getMock();
}
public function getNode($isAdmin = true) {
- $this->user = $this->getMock('\OCP\IUser');
+ $this->user = $this->getMockBuilder('\OCP\IUser')
+ ->getMock();
$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue('testuser'));
- $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->getMock();
$userSession->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
- $groupManager = $this->getMock('\OCP\IGroupManager');
+ $groupManager = $this->getMockBuilder('\OCP\IGroupManager')
+ ->getMock();
$groupManager->expects($this->any())
->method('isAdmin')
->with('testuser')
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php
index 7eb38f9f1ec..cca781dc28e 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php
@@ -46,10 +46,13 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
- $this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper');
+ $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
+ ->getMock();
+ $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper')
+ ->getMock();
- $this->user = $this->getMock('\OCP\IUser');
+ $this->user = $this->getMockBuilder('\OCP\IUser')
+ ->getMock();
}
public function getNode() {
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php
index 2fb1f63b1e3..628abe6689a 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php
@@ -47,26 +47,33 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->tagManager = $this->getMock('\OCP\SystemTag\ISystemTagManager');
- $this->tagMapper = $this->getMock('\OCP\SystemTag\ISystemTagObjectMapper');
+ $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
+ ->getMock();
+ $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper')
+ ->getMock();
- $user = $this->getMock('\OCP\IUser');
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('testuser'));
- $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession = $this->getMockBuilder('\OCP\IUserSession')
+ ->getMock();
$userSession->expects($this->any())
->method('getUser')
->will($this->returnValue($user));
- $groupManager = $this->getMock('\OCP\IGroupManager');
+ $groupManager = $this->getMockBuilder('\OCP\IGroupManager')
+ ->getMock();
$groupManager->expects($this->any())
->method('isAdmin')
->with('testuser')
->will($this->returnValue(true));
- $this->userFolder = $this->getMock('\OCP\Files\Folder');
+ $this->userFolder = $this->getMockBuilder('\OCP\Files\Folder')
+ ->getMock();
- $fileRoot = $this->getMock('\OCP\Files\IRootFolder');
+ $fileRoot = $this->getMockBuilder('\OCP\Files\IRootFolder')
+ ->getMock();
$fileRoot->expects($this->any())
->method('getUserfolder')
->with('testuser')
diff --git a/apps/federatedfilesharing/appinfo/app.php b/apps/federatedfilesharing/appinfo/app.php
index 5891b9cbbc1..e6fbe615e7f 100644
--- a/apps/federatedfilesharing/appinfo/app.php
+++ b/apps/federatedfilesharing/appinfo/app.php
@@ -20,11 +20,11 @@
*
*/
-$app = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
-
use OCA\FederatedFileSharing\Notifier;
+$app = new \OCA\FederatedFileSharing\AppInfo\Application();
$l = \OC::$server->getL10N('files_sharing');
+$eventDispatcher = \OC::$server->getEventDispatcher();
$app->registerSettings();
@@ -39,3 +39,14 @@ $manager->registerNotifier(function() {
'name' => $l->t('Federated sharing'),
];
});
+
+$federatedShareProvider = $app->getFederatedShareProvider();
+
+$eventDispatcher->addListener(
+ 'OCA\Files::loadAdditionalScripts',
+ function() use ($federatedShareProvider) {
+ if ($federatedShareProvider->isIncomingServer2serverShareEnabled()) {
+ \OCP\Util::addScript('federatedfilesharing', 'external');
+ }
+ }
+);
diff --git a/apps/federatedfilesharing/appinfo/routes.php b/apps/federatedfilesharing/appinfo/routes.php
new file mode 100644
index 00000000000..ec7b662686f
--- /dev/null
+++ b/apps/federatedfilesharing/appinfo/routes.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+return [
+ 'routes' => [
+ ['name' => 'MountPublicLink#createFederatedShare', 'url' => '/createFederatedShare', 'verb' => 'POST'],
+ ['name' => 'MountPublicLink#askForFederatedShare', 'url' => '/askForFederatedShare', 'verb' => 'POST'],
+ ]
+];
diff --git a/apps/files_sharing/js/external.js b/apps/federatedfilesharing/js/external.js
index 0ca8213168e..1daecd2e744 100644
--- a/apps/files_sharing/js/external.js
+++ b/apps/federatedfilesharing/js/external.js
@@ -99,20 +99,29 @@
var callbackAddShare = function(result, share) {
var password = share.password || '';
if (result) {
- //$.post(OC.generateUrl('/apps/files_sharing/api/externalShares'), {id: share.id});
- $.post(OC.generateUrl('apps/files_sharing/external'), {
- remote: share.remote,
- token: share.token,
- owner: share.owner,
- ownerDisplayName: share.ownerDisplayName || share.owner,
- name: share.name,
- password: password}, function(result) {
- if (result.status === 'error') {
- OC.Notification.showTemporary(result.data.message);
- } else {
- fileList.reload();
+ $.post(
+ OC.generateUrl('apps/federatedfilesharing/askForFederatedShare'),
+ {
+ remote: share.remote,
+ token: share.token,
+ owner: share.owner,
+ ownerDisplayName: share.ownerDisplayName || share.owner,
+ name: share.name,
+ password: password
}
- });
+ ).done(
+ function(data) {
+ if (data.hasOwnProperty('legacyMount')) {
+ fileList.reload();
+ } else {
+ OC.Notification.showTemporary(data.message);
+ }
+ }
+ ).fail(
+ function(data) {
+ OC.Notification.showTemporary(JSON.parse(data.responseText).message);
+ }
+ );
}
};
@@ -166,4 +175,3 @@
})();
OC.Plugins.register('OCA.Files.App', OCA.Sharing.ExternalShareDialogPlugin);
-
diff --git a/apps/federatedfilesharing/lib/AppInfo/Application.php b/apps/federatedfilesharing/lib/AppInfo/Application.php
index 4faebea7b0a..ea5018e6a90 100644
--- a/apps/federatedfilesharing/lib/AppInfo/Application.php
+++ b/apps/federatedfilesharing/lib/AppInfo/Application.php
@@ -31,6 +31,10 @@ class Application extends App {
/** @var FederatedShareProvider */
protected $federatedShareProvider;
+ public function __construct() {
+ parent::__construct('federatedfilesharing');
+ }
+
/**
* register personal and admin settings page
*/
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
new file mode 100644
index 00000000000..3e61d355b63
--- /dev/null
+++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
@@ -0,0 +1,324 @@
+<?php
+/**
+ * @author Björn Schießle <bjoern@schiessle.org>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @copyright Copyright (c) 2016, Björn Schießle <bjoern@schiessle.org>
+ *
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+
+namespace OCA\FederatedFileSharing\Controller;
+
+use OC\HintException;
+use OCA\FederatedFileSharing\AddressHandler;
+use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\JSONResponse;
+use OCP\Http\Client\IClientService;
+use OCP\IL10N;
+use OCP\IRequest;
+use OCP\ISession;
+use OCP\IUserSession;
+use OCP\Share\IManager;
+
+/**
+ * Class MountPublicLinkController
+ *
+ * convert public links to federated shares
+ *
+ * @package OCA\FederatedFileSharing\Controller
+ */
+class MountPublicLinkController extends Controller {
+
+ /** @var FederatedShareProvider */
+ private $federatedShareProvider;
+
+ /** @var AddressHandler */
+ private $addressHandler;
+
+ /** @var IManager */
+ private $shareManager;
+
+ /** @var ISession */
+ private $session;
+
+ /** @var IL10N */
+ private $l;
+
+ /** @var IUserSession */
+ private $userSession;
+
+ /** @var IClientService */
+ private $clientService;
+
+ /**
+ * MountPublicLinkController constructor.
+ *
+ * @param string $appName
+ * @param IRequest $request
+ * @param FederatedShareProvider $federatedShareProvider
+ * @param IManager $shareManager
+ * @param AddressHandler $addressHandler
+ * @param ISession $session
+ * @param IL10N $l
+ * @param IUserSession $userSession
+ * @param IClientService $clientService
+ */
+ public function __construct($appName,
+ IRequest $request,
+ FederatedShareProvider $federatedShareProvider,
+ IManager $shareManager,
+ AddressHandler $addressHandler,
+ ISession $session,
+ IL10N $l,
+ IUserSession $userSession,
+ IClientService $clientService
+ ) {
+ parent::__construct($appName, $request);
+
+ $this->federatedShareProvider = $federatedShareProvider;
+ $this->shareManager = $shareManager;
+ $this->addressHandler = $addressHandler;
+ $this->session = $session;
+ $this->l = $l;
+ $this->userSession = $userSession;
+ $this->clientService = $clientService;
+ }
+
+ /**
+ * send federated share to a user of a public link
+ *
+ * @NoCSRFRequired
+ * @PublicPage
+ *
+ * @param string $shareWith
+ * @param string $token
+ * @param string $password
+ * @return JSONResponse
+ */
+ public function createFederatedShare($shareWith, $token, $password = '') {
+
+ if (!$this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) {
+ return new JSONResponse(
+ ['message' => 'This server doesn\'t support outgoing federated shares'],
+ Http::STATUS_BAD_REQUEST
+ );
+ }
+
+ try {
+ list(, $server) = $this->addressHandler->splitUserRemote($shareWith);
+ $share = $this->shareManager->getShareByToken($token);
+ } catch (HintException $e) {
+ return new JSONResponse(['message' => $e->getHint()], Http::STATUS_BAD_REQUEST);
+ }
+
+ // make sure that user is authenticated in case of a password protected link
+ $storedPassword = $share->getPassword();
+ $authenticated = $this->session->get('public_link_authenticated') === $share->getId() ||
+ $this->shareManager->checkPassword($share, $password);
+ if (!empty($storedPassword) && !$authenticated ) {
+ return new JSONResponse(
+ ['message' => 'No permission to access the share'],
+ Http::STATUS_BAD_REQUEST
+ );
+ }
+
+ $share->setSharedWith($shareWith);
+
+ try {
+ $this->federatedShareProvider->create($share);
+ } catch (\Exception $e) {
+ return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
+ }
+
+ return new JSONResponse(['remoteUrl' => $server]);
+ }
+
+ /**
+ * ask other server to get a federated share
+ *
+ * @NoAdminRequired
+ *
+ * @param string $token
+ * @param string $remote
+ * @param string $password
+ * @param string $owner (only for legacy reasons, can be removed with legacyMountPublicLink())
+ * @param string $ownerDisplayName (only for legacy reasons, can be removed with legacyMountPublicLink())
+ * @param string $name (only for legacy reasons, can be removed with legacyMountPublicLink())
+ * @return JSONResponse
+ */
+ public function askForFederatedShare($token, $remote, $password = '', $owner = '', $ownerDisplayName = '', $name = '') {
+ // check if server admin allows to mount public links from other servers
+ if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() === false) {
+ return new JSONResponse(['message' => $this->l->t('Server to server sharing is not enabled on this server')], Http::STATUS_BAD_REQUEST);
+ }
+
+ $shareWith = $this->userSession->getUser()->getUID() . '@' . $this->addressHandler->generateRemoteURL();
+
+ $httpClient = $this->clientService->newClient();
+
+ try {
+ $response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/createFederatedShare',
+ [
+ 'body' =>
+ [
+ 'token' => $token,
+ 'shareWith' => rtrim($shareWith, '/'),
+ 'password' => $password
+ ],
+ 'connect_timeout' => 10,
+ ]
+ );
+ } catch (\Exception $e) {
+ if (empty($password)) {
+ $message = $this->l->t("Couldn't establish a federated share.");
+ } else {
+ $message = $this->l->t("Couldn't establish a federated share, maybe the password was wrong.");
+ }
+ return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST);
+ }
+
+ $body = $response->getBody();
+ $result = json_decode($body, true);
+
+ if (is_array($result) && isset($result['remoteUrl'])) {
+ return new JSONResponse(['message' => $this->l->t('Federated Share request was successful, you will receive a invitation. Check your notifications.')]);
+ }
+
+ // if we doesn't get the expected response we assume that we try to add
+ // a federated share from a Nextcloud <= 9 server
+ return $this->legacyMountPublicLink($token, $remote, $password, $name, $owner, $ownerDisplayName);
+ }
+
+ /**
+ * Allow Nextcloud to mount a public link directly
+ *
+ * This code was copied from the apps/files_sharing/ajax/external.php with
+ * minimal changes, just to guarantee backward compatibility
+ *
+ * ToDo: Remove this method once Nextcloud 9 reaches end of life
+ *
+ * @param string $token
+ * @param string $remote
+ * @param string $password
+ * @param string $name
+ * @param string $owner
+ * @param string $ownerDisplayName
+ * @return JSONResponse
+ */
+ private function legacyMountPublicLink($token, $remote, $password, $name, $owner, $ownerDisplayName) {
+
+ // Check for invalid name
+ if (!\OCP\Util::isValidFileName($name)) {
+ return new JSONResponse(['message' => $this->l->t('The mountpoint name contains invalid characters.')], Http::STATUS_BAD_REQUEST);
+ }
+ $currentUser = $this->userSession->getUser()->getUID();
+ $currentServer = $this->addressHandler->generateRemoteURL();
+ if (\OC\Share\Helper::isSameUserOnSameServer($owner, $remote, $currentUser, $currentServer)) {
+ return new JSONResponse(['message' => $this->l->t('Not allowed to create a federated share with the owner.')], Http::STATUS_BAD_REQUEST);
+ }
+ $discoveryManager = new \OCA\FederatedFileSharing\DiscoveryManager(
+ \OC::$server->getMemCacheFactory(),
+ \OC::$server->getHTTPClientService()
+ );
+ $externalManager = new \OCA\Files_Sharing\External\Manager(
+ \OC::$server->getDatabaseConnection(),
+ \OC\Files\Filesystem::getMountManager(),
+ \OC\Files\Filesystem::getLoader(),
+ \OC::$server->getHTTPHelper(),
+ \OC::$server->getNotificationManager(),
+ $discoveryManager,
+ \OC::$server->getUserSession()->getUser()->getUID()
+ );
+
+ // check for ssl cert
+ if (substr($remote, 0, 5) === 'https') {
+ try {
+ $client = $this->clientService->newClient();
+ $client->get($remote, [
+ 'timeout' => 10,
+ 'connect_timeout' => 10,
+ ])->getBody();
+ } catch (\Exception $e) {
+ return new JSONResponse(['message' => $this->l->t('Invalid or untrusted SSL certificate')], Http::STATUS_BAD_REQUEST);
+ }
+ }
+ $mount = $externalManager->addShare($remote, $token, $password, $name, $ownerDisplayName, true);
+ /**
+ * @var \OCA\Files_Sharing\External\Storage $storage
+ */
+ $storage = $mount->getStorage();
+ try {
+ // check if storage exists
+ $storage->checkStorageAvailability();
+ } catch (\OCP\Files\StorageInvalidException $e) {
+ // note: checkStorageAvailability will already remove the invalid share
+ \OCP\Util::writeLog(
+ 'federatedfilesharing',
+ 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
+ \OCP\Util::DEBUG
+ );
+ return new JSONResponse(['message' => $this->l->t('Could not authenticate to remote share, password might be wrong')], Http::STATUS_BAD_REQUEST);
+ } catch (\Exception $e) {
+ \OCP\Util::writeLog(
+ 'federatedfilesharing',
+ 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
+ \OCP\Util::DEBUG
+ );
+ $externalManager->removeShare($mount->getMountPoint());
+ return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST);
+ }
+ $result = $storage->file_exists('');
+ if ($result) {
+ try {
+ $storage->getScanner()->scanAll();
+ return new JSONResponse(
+ [
+ 'message' => $this->l->t('Federated Share successfully added'),
+ 'legacyMount' => '1'
+ ]
+ );
+ } catch (\OCP\Files\StorageInvalidException $e) {
+ \OCP\Util::writeLog(
+ 'federatedfilesharing',
+ 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
+ \OCP\Util::DEBUG
+ );
+ return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST);
+ } catch (\Exception $e) {
+ \OCP\Util::writeLog(
+ 'federatedfilesharing',
+ 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
+ \OCP\Util::DEBUG
+ );
+ return new JSONResponse(['message' => $this->l->t('Couldn\'t add remote share')], Http::STATUS_BAD_REQUEST);
+ }
+ } else {
+ $externalManager->removeShare($mount->getMountPoint());
+ \OCP\Util::writeLog(
+ 'federatedfilesharing',
+ 'Couldn\'t add remote share',
+ \OCP\Util::DEBUG
+ );
+ return new JSONResponse(['message' => $this->l->t('Couldn\'t add remote share')], Http::STATUS_BAD_REQUEST);
+ }
+
+ }
+
+}
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index 1ea31f2dbc0..7b64b56a16d 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -135,7 +135,7 @@ class FederatedShareProvider implements IShareProvider {
$itemType = $share->getNodeType();
$permissions = $share->getPermissions();
$sharedBy = $share->getSharedBy();
-
+
/*
* Check if file is not already shared with the remote user
*/
@@ -626,7 +626,7 @@ class FederatedShareProvider implements IShareProvider {
->from('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_REMOTE)));
-
+
$cursor = $qb->execute();
$data = $cursor->fetch();
$cursor->closeCursor();
@@ -727,13 +727,13 @@ class FederatedShareProvider implements IShareProvider {
$data = $cursor->fetch();
if ($data === false) {
- throw new ShareNotFound();
+ throw new ShareNotFound('Share not found', $this->l->t('Could not find share'));
}
try {
$share = $this->createShareObject($data);
} catch (InvalidShare $e) {
- throw new ShareNotFound();
+ throw new ShareNotFound('Share not found', $this->l->t('Could not find share'));
}
return $share;
diff --git a/apps/federatedfilesharing/settings-admin.php b/apps/federatedfilesharing/settings-admin.php
index 9875dcf3b5b..dc5a4d6826c 100644
--- a/apps/federatedfilesharing/settings-admin.php
+++ b/apps/federatedfilesharing/settings-admin.php
@@ -22,7 +22,7 @@
use OCA\FederatedFileSharing\AppInfo\Application;
-$app = new Application('federatedfilesharing');
+$app = new Application();
$federatedShareProvider = $app->getFederatedShareProvider();
$tmpl = new OCP\Template('federatedfilesharing', 'settings-admin');
diff --git a/apps/federatedfilesharing/settings-personal.php b/apps/federatedfilesharing/settings-personal.php
index a36cdd712c4..261d540f48d 100644
--- a/apps/federatedfilesharing/settings-personal.php
+++ b/apps/federatedfilesharing/settings-personal.php
@@ -27,7 +27,7 @@ use OCA\FederatedFileSharing\AppInfo\Application;
$l = \OC::$server->getL10N('federatedfilesharing');
-$app = new Application('federatedfilesharing');
+$app = new Application();
$federatedShareProvider = $app->getFederatedShareProvider();
$isIE8 = false;
diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
new file mode 100644
index 00000000000..3fe05e72cf4
--- /dev/null
+++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
@@ -0,0 +1,200 @@
+<?php
+/**
+ * @author Björn Schießle <schiessle@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @copyright Copyright (c) 2016, Björn Schießle <bjoern@schiessle.org>
+ *
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+
+namespace OCA\FederatedFileSharing\Tests\Controller;
+
+use OC\HintException;
+use OCA\FederatedFileSharing\AddressHandler;
+use OCA\FederatedFileSharing\Controller\MountPublicLinkController;
+use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCP\AppFramework\Http;
+use OCP\Files\IRootFolder;
+use OCP\Http\Client\IClientService;
+use OCP\IL10N;
+use OCP\ISession;
+use OCP\IUserManager;
+use OCP\IUserSession;
+use OCP\Share\IManager;
+use OCP\Share\IShare;
+
+class MountPublicLinkControllerTest extends \Test\TestCase {
+
+ /** @var MountPublicLinkController */
+ private $controller;
+
+ /** @var \OCP\IRequest | \PHPUnit_Framework_MockObject_MockObject */
+ private $request;
+
+ /** @var FederatedShareProvider | \PHPUnit_Framework_MockObject_MockObject */
+ private $federatedShareProvider;
+
+ /** @var IManager | \PHPUnit_Framework_MockObject_MockObject */
+ private $shareManager;
+
+ /** @var AddressHandler | \PHPUnit_Framework_MockObject_MockObject */
+ private $addressHandler;
+
+ /** @var IRootFolder | \PHPUnit_Framework_MockObject_MockObject */
+ private $rootFolder;
+
+ /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject */
+ private $userManager;
+
+ /** @var ISession | \PHPUnit_Framework_MockObject_MockObject */
+ private $session;
+
+ /** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */
+ private $l10n;
+
+ /** @var IUserSession | \PHPUnit_Framework_MockObject_MockObject */
+ private $userSession;
+
+ /** @var IClientService | \PHPUnit_Framework_MockObject_MockObject */
+ private $clientService;
+
+ /** @var IShare */
+ private $share;
+
+ public function setUp() {
+ parent::setUp();
+
+ $this->request = $this->getMockBuilder('OCP\IRequest')->disableOriginalConstructor()->getMock();
+ $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider')
+ ->disableOriginalConstructor()->getMock();
+ $this->shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock();
+ $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')
+ ->disableOriginalConstructor()->getMock();
+ $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->disableOriginalConstructor()->getMock();
+ $this->userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock();
+ $this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
+ $this->session = $this->getMockBuilder('OCP\ISession')->disableOriginalConstructor()->getMock();
+ $this->l10n = $this->getMockBuilder('OCP\IL10N')->disableOriginalConstructor()->getMock();
+ $this->userSession = $this->getMockBuilder('OCP\IUserSession')->disableOriginalConstructor()->getMock();
+ $this->clientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->disableOriginalConstructor()->getMock();
+
+ $this->controller = new MountPublicLinkController(
+ 'federatedfilesharing', $this->request,
+ $this->federatedShareProvider,
+ $this->shareManager,
+ $this->addressHandler,
+ $this->session,
+ $this->l10n,
+ $this->userSession,
+ $this->clientService
+ );
+ }
+
+ /**
+ * @dataProvider dataTestCreateFederatedShare
+ *
+ * @param string $shareWith
+ * @param bool $outgoingSharesAllowed
+ * @param bool $validShareWith
+ * @param string $token
+ * @param bool $validToken
+ * @param bool $createSuccessful
+ * @param string $expectedReturnData
+ */
+ public function testCreateFederatedShare($shareWith,
+ $outgoingSharesAllowed,
+ $validShareWith,
+ $token,
+ $validToken,
+ $createSuccessful,
+ $expectedReturnData
+ ) {
+
+ $this->federatedShareProvider->expects($this->any())
+ ->method('isOutgoingServer2serverShareEnabled')
+ ->willReturn($outgoingSharesAllowed);
+
+ $this->addressHandler->expects($this->any())->method('splitUserRemote')
+ ->with($shareWith)
+ ->willReturnCallback(
+ function($shareWith) use ($validShareWith, $expectedReturnData) {
+ if ($validShareWith) {
+ return ['user', 'server'];
+ }
+ throw new HintException($expectedReturnData, $expectedReturnData);
+ }
+ );
+
+ $share = $this->share;
+
+ $this->shareManager->expects($this->any())->method('getShareByToken')
+ ->with($token)
+ ->willReturnCallback(
+ function ($token) use ($validToken, $share, $expectedReturnData) {
+ if ($validToken) {
+ return $share;
+ }
+ throw new HintException($expectedReturnData, $expectedReturnData);
+ }
+ );
+
+ $this->federatedShareProvider->expects($this->any())->method('create')
+ ->with($share)
+ ->willReturnCallback(
+ function (IShare $share) use ($createSuccessful, $shareWith, $expectedReturnData) {
+ $this->assertEquals($shareWith, $share->getSharedWith());
+ if ($createSuccessful) {
+ return $share;
+ }
+ throw new HintException($expectedReturnData, $expectedReturnData);
+ }
+ );
+
+ $result = $this->controller->createFederatedShare($shareWith, $token);
+
+ $errorCase = !$validShareWith || !$validToken || !$createSuccessful || !$outgoingSharesAllowed;
+
+ if ($errorCase) {
+ $this->assertSame(Http::STATUS_BAD_REQUEST, $result->getStatus());
+ $this->assertTrue(isset($result->getData()['message']));
+ $this->assertSame($expectedReturnData, $result->getData()['message']);
+ } else {
+ $this->assertSame(Http::STATUS_OK, $result->getStatus());
+ $this->assertTrue(isset($result->getData()['remoteUrl']));
+ $this->assertSame($expectedReturnData, $result->getData()['remoteUrl']);
+
+ }
+
+ }
+
+ public function dataTestCreateFederatedShare() {
+ return [
+ //shareWith, outgoingSharesAllowed, validShareWith, token, validToken, createSuccessful, expectedReturnData
+ ['user@server', true, true, 'token', true, true, 'server'],
+ ['user@server', true, false, 'token', true, true, 'invalid federated cloud id'],
+ ['user@server', true, false, 'token', false, true, 'invalid federated cloud id'],
+ ['user@server', true, false, 'token', false, false, 'invalid federated cloud id'],
+ ['user@server', true, false, 'token', true, false, 'invalid federated cloud id'],
+ ['user@server', true, true, 'token', false, true, 'invalid token'],
+ ['user@server', true, true, 'token', false, false, 'invalid token'],
+ ['user@server', true, true, 'token', true, false, 'can not create share'],
+ ['user@server', false, true, 'token', true, true, 'This server doesn\'t support outgoing federated shares'],
+ ];
+ }
+
+}
diff --git a/apps/files_sharing/tests/js/externalSpec.js b/apps/federatedfilesharing/tests/js/externalSpec.js
index 362df49252b..362df49252b 100644
--- a/apps/files_sharing/tests/js/externalSpec.js
+++ b/apps/federatedfilesharing/tests/js/externalSpec.js
diff --git a/apps/files/l10n/ja.js b/apps/files/l10n/ja.js
index 70ccebb7883..81de770bc1b 100644
--- a/apps/files/l10n/ja.js
+++ b/apps/files/l10n/ja.js
@@ -83,6 +83,7 @@ OC.L10N.register(
"Storage of {owner} is almost full ({usedSpacePercent}%)" : "{owner} のストレージはほぼ一杯です。({usedSpacePercent}%)",
"Your storage is almost full ({usedSpacePercent}%)" : "ストレージがほぼ一杯です({usedSpacePercent}%)",
"_matches '{filter}'_::_match '{filter}'_" : [" '{filter}' にマッチ"],
+ "View in folder" : "フォルダー内で表示",
"Path" : "Path",
"_%n byte_::_%n bytes_" : ["%n バイト"],
"Favorited" : "お気に入り済",
diff --git a/apps/files/l10n/ja.json b/apps/files/l10n/ja.json
index 7be54e85840..dd3fd5529a2 100644
--- a/apps/files/l10n/ja.json
+++ b/apps/files/l10n/ja.json
@@ -81,6 +81,7 @@
"Storage of {owner} is almost full ({usedSpacePercent}%)" : "{owner} のストレージはほぼ一杯です。({usedSpacePercent}%)",
"Your storage is almost full ({usedSpacePercent}%)" : "ストレージがほぼ一杯です({usedSpacePercent}%)",
"_matches '{filter}'_::_match '{filter}'_" : [" '{filter}' にマッチ"],
+ "View in folder" : "フォルダー内で表示",
"Path" : "Path",
"_%n byte_::_%n bytes_" : ["%n バイト"],
"Favorited" : "お気に入り済",
diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php
deleted file mode 100644
index 4a7a6096c91..00000000000
--- a/apps/files_sharing/ajax/external.php
+++ /dev/null
@@ -1,153 +0,0 @@
-<?php
-/**
- * @author Björn Schießle <bjoern@schiessle.org>
- * @author Joas Schilling <nickvergessen@owncloud.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- * @author Vincent Petry <pvince81@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-OCP\JSON::callCheck();
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('files_sharing');
-
-$l = \OC::$server->getL10N('files_sharing');
-
-$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
-$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
-
-// check if server admin allows to mount public links from other servers
-if ($federatedShareProvider->isIncomingServer2serverShareEnabled() === false) {
- \OCP\JSON::error(array('data' => array('message' => $l->t('Server to server sharing is not enabled on this server'))));
- exit();
-}
-
-$token = $_POST['token'];
-$remote = $_POST['remote'];
-$owner = $_POST['owner'];
-$ownerDisplayName = $_POST['ownerDisplayName'];
-$name = $_POST['name'];
-$password = $_POST['password'];
-
-// Check for invalid name
-if(!\OCP\Util::isValidFileName($name)) {
- \OCP\JSON::error(array('data' => array('message' => $l->t('The mountpoint name contains invalid characters.'))));
- exit();
-}
-
-$currentUser = \OC::$server->getUserSession()->getUser()->getUID();
-$currentServer = \OC::$server->getURLGenerator()->getAbsoluteURL('/');
-if (\OC\Share\Helper::isSameUserOnSameServer($owner, $remote, $currentUser, $currentServer )) {
- \OCP\JSON::error(array('data' => array('message' => $l->t('Not allowed to create a federated share with the same user server'))));
- exit();
-}
-
-$discoveryManager = new \OCA\FederatedFileSharing\DiscoveryManager(
- \OC::$server->getMemCacheFactory(),
- \OC::$server->getHTTPClientService()
-);
-$externalManager = new \OCA\Files_Sharing\External\Manager(
- \OC::$server->getDatabaseConnection(),
- \OC\Files\Filesystem::getMountManager(),
- \OC\Files\Filesystem::getLoader(),
- \OC::$server->getHTTPHelper(),
- \OC::$server->getNotificationManager(),
- $discoveryManager,
- \OC::$server->getUserSession()->getUser()->getUID()
-);
-
-// check for ssl cert
-if (substr($remote, 0, 5) === 'https') {
- try {
- \OC::$server->getHTTPClientService()->newClient()->get($remote, [
- 'timeout' => 10,
- 'connect_timeout' => 10,
- ])->getBody();
- } catch (\Exception $e) {
- \OCP\JSON::error(array('data' => array('message' => $l->t('Invalid or untrusted SSL certificate'))));
- exit;
- }
-}
-
-$mount = $externalManager->addShare($remote, $token, $password, $name, $ownerDisplayName, true);
-
-/**
- * @var \OCA\Files_Sharing\External\Storage $storage
- */
-$storage = $mount->getStorage();
-try {
- // check if storage exists
- $storage->checkStorageAvailability();
-} catch (\OCP\Files\StorageInvalidException $e) {
- // note: checkStorageAvailability will already remove the invalid share
- \OCP\Util::writeLog(
- 'files_sharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- \OCP\Util::DEBUG
- );
- \OCP\JSON::error(
- array(
- 'data' => array(
- 'message' => $l->t('Could not authenticate to remote share, password might be wrong')
- )
- )
- );
- exit();
-} catch (\Exception $e) {
- \OCP\Util::writeLog(
- 'files_sharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- \OCP\Util::DEBUG
- );
- $externalManager->removeShare($mount->getMountPoint());
- \OCP\JSON::error(array('data' => array('message' => $l->t('Storage not valid'))));
- exit();
-}
-$result = $storage->file_exists('');
-if ($result) {
- try {
- $storage->getScanner()->scanAll();
- \OCP\JSON::success();
- } catch (\OCP\Files\StorageInvalidException $e) {
- \OCP\Util::writeLog(
- 'files_sharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- \OCP\Util::DEBUG
- );
- \OCP\JSON::error(array('data' => array('message' => $l->t('Storage not valid'))));
- } catch (\Exception $e) {
- \OCP\Util::writeLog(
- 'files_sharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- \OCP\Util::DEBUG
- );
- \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t add remote share'))));
- }
-} else {
- $externalManager->removeShare($mount->getMountPoint());
- \OCP\Util::writeLog(
- 'files_sharing',
- 'Couldn\'t add remote share',
- \OCP\Util::DEBUG
- );
- \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t add remote share'))));
-}
-
diff --git a/apps/files_sharing/ajax/shareinfo.php b/apps/files_sharing/ajax/shareinfo.php
index 0b93e3d2ee9..b9b29022cc3 100644
--- a/apps/files_sharing/ajax/shareinfo.php
+++ b/apps/files_sharing/ajax/shareinfo.php
@@ -31,7 +31,7 @@ if (!isset($_GET['t'])) {
exit;
}
-$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
+$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false) {
@@ -53,11 +53,12 @@ if (isset($_GET['dir'])) {
$data = \OCA\Files_Sharing\Helper::setupFromToken($token, $relativePath, $password);
-$linkItem = $data['linkItem'];
+/** @var \OCP\Share\IShare $share */
+$share = $data['share'];
// Load the files
$path = $data['realPath'];
-$isWritable = $linkItem['permissions'] & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
+$isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
if (!$isWritable) {
\OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE));
@@ -67,10 +68,6 @@ if (!$isWritable) {
$rootInfo = \OC\Files\Filesystem::getFileInfo($path);
$rootView = new \OC\Files\View('');
-$shareManager = \OC::$server->getShareManager();
-$share = $shareManager->getShareByToken($token);
-$sharePermissions= (int)$share->getPermissions();
-
if($rootInfo === false || !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
OCP\JSON::error(array('data' => 'Share is not readable.'));
exit();
@@ -98,11 +95,11 @@ function getChildInfo($dir, $view, $sharePermissions) {
$result = \OCA\Files\Helper::formatFileInfo($rootInfo);
$result['mtime'] = $result['mtime'] / 1000;
-$result['permissions'] = (int)$result['permissions'] & $sharePermissions;
+$result['permissions'] = (int)$result['permissions'] & $share->getPermissions();
if ($rootInfo->getType() === 'dir') {
- $result['children'] = getChildInfo($rootInfo, $rootView, $sharePermissions);
+ $result['children'] = getChildInfo($rootInfo, $rootView, $share->getPermissions());
}
OCP\JSON::success(array('data' => $result));
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index c6ae6903eec..219fa298d51 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -46,9 +46,6 @@ $eventDispatcher->addListener(
function() {
\OCP\Util::addScript('files_sharing', 'share');
\OCP\Util::addScript('files_sharing', 'sharetabview');
- if (\OC::$server->getConfig()->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes') {
- \OCP\Util::addScript('files_sharing', 'external');
- }
\OCP\Util::addStyle('files_sharing', 'sharetabview');
}
);
diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php
index 0e72934d094..26d32c3a990 100644
--- a/apps/files_sharing/appinfo/routes.php
+++ b/apps/files_sharing/appinfo/routes.php
@@ -53,8 +53,6 @@ $this->create('files_sharing_ajax_publicpreview', 'ajax/publicpreview.php')
->actionInclude('files_sharing/ajax/publicpreview.php');
$this->create('sharing_external_shareinfo', '/shareinfo')
->actionInclude('files_sharing/ajax/shareinfo.php');
-$this->create('sharing_external_add', '/external')
- ->actionInclude('files_sharing/ajax/external.php');
// OCS API
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 3befeaeda1f..0dfff235998 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2014
+ * @copyright Copyright (c) 2016, Björn Schießle <bjoern@schiessle.org>
*
* This file is licensed under the Affero General Public License version 3
* or later.
@@ -247,7 +248,7 @@ OCA.Sharing.PublicApp = {
var ownerDisplayName = $('#save').data('owner-display-name');
var name = $('#save').data('name');
var isProtected = $('#save').data('protected') ? 1 : 0;
- OCA.Sharing.PublicApp._saveToOwnCloud(remote, token, owner, ownerDisplayName, name, isProtected);
+ OCA.Sharing.PublicApp._createFederatedShare(remote, token, owner, ownerDisplayName, name, isProtected);
});
$('#remote_address').on("keyup paste", function() {
@@ -294,30 +295,26 @@ OCA.Sharing.PublicApp = {
this.fileList.changeDirectory(params.path || params.dir, false, true);
},
- _saveToOwnCloud: function (remote, token, owner, ownerDisplayName, name, isProtected) {
- var toggleLoading = function() {
- var iconClass = $('#save-button-confirm').attr('class');
- var loading = iconClass.indexOf('icon-loading-small') !== -1;
- if(loading) {
- $('#save-button-confirm')
- .removeClass("icon-loading-small")
- .addClass("icon-confirm");
- }
- else {
- $('#save-button-confirm')
- .removeClass("icon-confirm")
- .addClass("icon-loading-small");
-
- }
- };
+ /**
+ * fall back to old behaviour where we redirect the user to his server to mount
+ * the public link instead of creating a dedicated federated share
+ *
+ * @param remote
+ * @param token
+ * @param owner
+ * @param ownerDisplayName
+ * @param name
+ * @param isProtected
+ * @private
+ */
+ _legacyCreateFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) {
- toggleLoading();
var location = window.location.protocol + '//' + window.location.host + OC.webroot;
if(remote.substr(-1) !== '/') {
remote += '/'
- };
+ }
var url = remote + 'index.php/apps/files#' + 'remote=' + encodeURIComponent(location) // our location is the remote for the other server
+ "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) +"&ownerDisplayName=" + encodeURIComponent(ownerDisplayName) + "&name=" + encodeURIComponent(name) + "&protected=" + isProtected;
@@ -330,7 +327,6 @@ OCA.Sharing.PublicApp = {
// this check needs to happen on the server due to the Content Security Policy directive
$.get(OC.generateUrl('apps/files_sharing/testremote'), {remote: remote}).then(function (protocol) {
if (protocol !== 'http' && protocol !== 'https') {
- toggleLoading();
OC.dialogs.alert(t('files_sharing', 'No compatible server found at {remote}', {remote: remote}),
t('files_sharing', 'Invalid server URL'));
} else {
@@ -338,6 +334,58 @@ OCA.Sharing.PublicApp = {
}
});
}
+ },
+
+ _createFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) {
+
+ var toggleLoading = function() {
+ var iconClass = $('#save-button-confirm').attr('class');
+ var loading = iconClass.indexOf('icon-loading-small') !== -1;
+ if(loading) {
+ $('#save-button-confirm')
+ .removeClass("icon-loading-small")
+ .addClass("icon-confirm");
+
+ }
+ else {
+ $('#save-button-confirm')
+ .removeClass("icon-confirm")
+ .addClass("icon-loading-small");
+
+ }
+ };
+
+ toggleLoading();
+
+ if (remote.indexOf('@') === -1) {
+ this._legacyCreateFederatedShare(remote, token, owner, ownerDisplayName, name, isProtected);
+ toggleLoading();
+ return;
+ }
+
+ $.post(
+ OC.generateUrl('/apps/federatedfilesharing/createFederatedShare'),
+ {
+ 'shareWith': remote,
+ 'token': token
+ }
+ ).done(
+ function (data) {
+ var url = data.remoteUrl;
+
+ if (url.indexOf('://') > 0) {
+ OC.redirect(url);
+ } else {
+ OC.redirect('http://' + url);
+ }
+ }
+ ).fail(
+ function (jqXHR) {
+ OC.dialogs.alert(JSON.parse(jqXHR.responseText).message,
+ t('files_sharing', 'Failed to add the public link to your Nextcloud'));
+ toggleLoading();
+ }
+ );
}
};
diff --git a/apps/files_sharing/l10n/cs_CZ.js b/apps/files_sharing/l10n/cs_CZ.js
index 91695f0f653..0f050734990 100644
--- a/apps/files_sharing/l10n/cs_CZ.js
+++ b/apps/files_sharing/l10n/cs_CZ.js
@@ -23,6 +23,8 @@ OC.L10N.register(
"Cancel" : "Zrušit",
"Add remote share" : "Přidat vzdálené úložiště",
"You can upload into this folder" : "Můžete nahrávat do tohoto adresáře",
+ "No compatible server found at {remote}" : "Na {remote} nebyl nalezen kompatibilní server",
+ "Invalid server URL" : "Neplatná URL serveru",
"No expiration date set" : "Není nastaveno datum vypršení platnosti",
"Shared by" : "Sdílí",
"Sharing" : "Sdílení",
diff --git a/apps/files_sharing/l10n/cs_CZ.json b/apps/files_sharing/l10n/cs_CZ.json
index a40273e2fb5..c88e2230599 100644
--- a/apps/files_sharing/l10n/cs_CZ.json
+++ b/apps/files_sharing/l10n/cs_CZ.json
@@ -21,6 +21,8 @@
"Cancel" : "Zrušit",
"Add remote share" : "Přidat vzdálené úložiště",
"You can upload into this folder" : "Můžete nahrávat do tohoto adresáře",
+ "No compatible server found at {remote}" : "Na {remote} nebyl nalezen kompatibilní server",
+ "Invalid server URL" : "Neplatná URL serveru",
"No expiration date set" : "Není nastaveno datum vypršení platnosti",
"Shared by" : "Sdílí",
"Sharing" : "Sdílení",
diff --git a/apps/files_sharing/l10n/fr.js b/apps/files_sharing/l10n/fr.js
index 67206f439d9..a0962c77dcc 100644
--- a/apps/files_sharing/l10n/fr.js
+++ b/apps/files_sharing/l10n/fr.js
@@ -23,6 +23,8 @@ OC.L10N.register(
"Cancel" : "Annuler",
"Add remote share" : "Ajouter un partage distant",
"You can upload into this folder" : "Vous pouvez téléverser dans ce dossier",
+ "No compatible server found at {remote}" : "Aucun serveur compatible trouvé sur {remote}",
+ "Invalid server URL" : "URL serveur invalide",
"No expiration date set" : "Aucune date d'expiration définie",
"Shared by" : "Partagé par",
"Sharing" : "Partage",
diff --git a/apps/files_sharing/l10n/fr.json b/apps/files_sharing/l10n/fr.json
index ee27d57ea4c..39ec40a5a48 100644
--- a/apps/files_sharing/l10n/fr.json
+++ b/apps/files_sharing/l10n/fr.json
@@ -21,6 +21,8 @@
"Cancel" : "Annuler",
"Add remote share" : "Ajouter un partage distant",
"You can upload into this folder" : "Vous pouvez téléverser dans ce dossier",
+ "No compatible server found at {remote}" : "Aucun serveur compatible trouvé sur {remote}",
+ "Invalid server URL" : "URL serveur invalide",
"No expiration date set" : "Aucune date d'expiration définie",
"Shared by" : "Partagé par",
"Sharing" : "Partage",
diff --git a/apps/files_sharing/l10n/it.js b/apps/files_sharing/l10n/it.js
index fed1e071e9f..e56a5d30551 100644
--- a/apps/files_sharing/l10n/it.js
+++ b/apps/files_sharing/l10n/it.js
@@ -23,6 +23,8 @@ OC.L10N.register(
"Cancel" : "Annulla",
"Add remote share" : "Aggiungi condivisione remota",
"You can upload into this folder" : "Puoi caricare in questa cartella",
+ "No compatible server found at {remote}" : "Nessun server compatibile trovato su {remote}",
+ "Invalid server URL" : "URL del server non valido",
"No expiration date set" : "Nessuna data di scandenza impostata",
"Shared by" : "Condiviso da",
"Sharing" : "Condivisione",
diff --git a/apps/files_sharing/l10n/it.json b/apps/files_sharing/l10n/it.json
index 0d87df2f1c8..33d948128ae 100644
--- a/apps/files_sharing/l10n/it.json
+++ b/apps/files_sharing/l10n/it.json
@@ -21,6 +21,8 @@
"Cancel" : "Annulla",
"Add remote share" : "Aggiungi condivisione remota",
"You can upload into this folder" : "Puoi caricare in questa cartella",
+ "No compatible server found at {remote}" : "Nessun server compatibile trovato su {remote}",
+ "Invalid server URL" : "URL del server non valido",
"No expiration date set" : "Nessuna data di scandenza impostata",
"Shared by" : "Condiviso da",
"Sharing" : "Condivisione",
diff --git a/apps/files_sharing/l10n/pt_BR.js b/apps/files_sharing/l10n/pt_BR.js
index eb5f31acce2..d957ae6d523 100644
--- a/apps/files_sharing/l10n/pt_BR.js
+++ b/apps/files_sharing/l10n/pt_BR.js
@@ -23,6 +23,8 @@ OC.L10N.register(
"Cancel" : "Cancelar",
"Add remote share" : "Adicionar compartilhamento remoto",
"You can upload into this folder" : "Você não pode enviar arquivos para esta pasta",
+ "No compatible server found at {remote}" : "Nenhum servidor compativel encnotrado em {remote}",
+ "Invalid server URL" : "URL do servidor inválida",
"No expiration date set" : "Nenhuma data de expiração definida",
"Shared by" : "Compartilhado por",
"Sharing" : "Compartilhamento",
diff --git a/apps/files_sharing/l10n/pt_BR.json b/apps/files_sharing/l10n/pt_BR.json
index 5ec68a769b4..f8d6eab2abf 100644
--- a/apps/files_sharing/l10n/pt_BR.json
+++ b/apps/files_sharing/l10n/pt_BR.json
@@ -21,6 +21,8 @@
"Cancel" : "Cancelar",
"Add remote share" : "Adicionar compartilhamento remoto",
"You can upload into this folder" : "Você não pode enviar arquivos para esta pasta",
+ "No compatible server found at {remote}" : "Nenhum servidor compativel encnotrado em {remote}",
+ "Invalid server URL" : "URL do servidor inválida",
"No expiration date set" : "Nenhuma data de expiração definida",
"Shared by" : "Compartilhado por",
"Sharing" : "Compartilhamento",
diff --git a/apps/files_sharing/l10n/tr.js b/apps/files_sharing/l10n/tr.js
index a78c7f3bad3..e68fb662e84 100644
--- a/apps/files_sharing/l10n/tr.js
+++ b/apps/files_sharing/l10n/tr.js
@@ -25,6 +25,7 @@ OC.L10N.register(
"You can upload into this folder" : "Bu dizine yükleme yapabilirsiniz",
"Shared by" : "Paylaşan",
"Sharing" : "Paylaşım",
+ "Could not delete share" : "Paylaşım kaldırılamadı",
"A file or folder has been <strong>shared</strong>" : "Bir dosya veya klasör <strong>paylaşıldı</strong>",
"A file or folder was shared from <strong>another server</strong>" : "<strong>Başka sunucudan</strong> bir dosya veya klasör paylaşıldı",
"A public shared file or folder was <strong>downloaded</strong>" : "Herkese açık paylaşılan bir dosya veya klasör <strong>indirildi</strong>",
@@ -83,6 +84,7 @@ OC.L10N.register(
"Add to your ownCloud" : "ownCloud'ınıza Ekleyin",
"Download" : "İndir",
"Download %s" : "İndir: %s",
- "Direct link" : "Doğrudan bağlantı"
+ "Direct link" : "Doğrudan bağlantı",
+ "Uploaded files:" : "Yüklenmiş dosyalar:"
},
"nplurals=2; plural=(n > 1);");
diff --git a/apps/files_sharing/l10n/tr.json b/apps/files_sharing/l10n/tr.json
index 435ed212c72..9559a63a944 100644
--- a/apps/files_sharing/l10n/tr.json
+++ b/apps/files_sharing/l10n/tr.json
@@ -23,6 +23,7 @@
"You can upload into this folder" : "Bu dizine yükleme yapabilirsiniz",
"Shared by" : "Paylaşan",
"Sharing" : "Paylaşım",
+ "Could not delete share" : "Paylaşım kaldırılamadı",
"A file or folder has been <strong>shared</strong>" : "Bir dosya veya klasör <strong>paylaşıldı</strong>",
"A file or folder was shared from <strong>another server</strong>" : "<strong>Başka sunucudan</strong> bir dosya veya klasör paylaşıldı",
"A public shared file or folder was <strong>downloaded</strong>" : "Herkese açık paylaşılan bir dosya veya klasör <strong>indirildi</strong>",
@@ -81,6 +82,7 @@
"Add to your ownCloud" : "ownCloud'ınıza Ekleyin",
"Download" : "İndir",
"Download %s" : "İndir: %s",
- "Direct link" : "Doğrudan bağlantı"
+ "Direct link" : "Doğrudan bağlantı",
+ "Uploaded files:" : "Yüklenmiş dosyalar:"
},"pluralForm" :"nplurals=2; plural=(n > 1);"
} \ No newline at end of file
diff --git a/apps/files_sharing/lib/API/Share20OCS.php b/apps/files_sharing/lib/API/Share20OCS.php
index 436b8d15ac8..9d7aeffcc1b 100644
--- a/apps/files_sharing/lib/API/Share20OCS.php
+++ b/apps/files_sharing/lib/API/Share20OCS.php
@@ -602,11 +602,12 @@ class Share20OCS {
}
if ($newPermissions !== null &&
- $newPermissions !== \OCP\Constants::PERMISSION_READ &&
- // legacy
- $newPermissions !== (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE) &&
- // correct
- $newPermissions !== (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE)
+ !in_array($newPermissions, [
+ \OCP\Constants::PERMISSION_READ,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE, // legacy
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE, // correct
+ \OCP\Constants::PERMISSION_CREATE, // hidden file list
+ ])
) {
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED);
return new \OC_OCS_Result(null, 400, $this->l->t('Can\'t change permissions for public share links'));
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index fda16c7acac..5ed8d886e2e 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -46,7 +46,7 @@ class Application extends App {
* Controllers
*/
$container->registerService('ShareController', function (SimpleContainer $c) use ($server) {
- $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
+ $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
return new ShareController(
$c->query('AppName'),
$c->query('Request'),
diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php
index 2353a281b7e..67312ae97cd 100644
--- a/apps/files_sharing/lib/Helper.php
+++ b/apps/files_sharing/lib/Helper.php
@@ -31,6 +31,7 @@ namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
use OC\Files\View;
use OCP\Files\NotFoundException;
+use OCP\Share\Exceptions\ShareNotFound;
use OCP\User;
class Helper {
@@ -53,29 +54,23 @@ class Helper {
public static function setupFromToken($token, $relativePath = null, $password = null) {
\OC_User::setIncognitoMode(true);
- $linkItem = \OCP\Share::getShareByToken($token, !$password);
- if($linkItem === false || ($linkItem['item_type'] !== 'file' && $linkItem['item_type'] !== 'folder')) {
+ $shareManager = \OC::$server->getShareManager();
+
+ try {
+ $share = $shareManager->getShareByToken($token);
+ } catch (ShareNotFound $e) {
\OC_Response::setStatus(404);
\OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG);
exit;
}
- if(!isset($linkItem['uid_owner']) || !isset($linkItem['file_source'])) {
- \OC_Response::setStatus(500);
- \OCP\Util::writeLog('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OCP\Util::WARN);
- exit;
- }
+ \OCP\JSON::checkUserExists($share->getShareOwner());
+ \OC_Util::tearDownFS();
+ \OC_Util::setupFS($share->getShareOwner());
- $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
- $path = null;
- if (isset($rootLinkItem['uid_owner'])) {
- \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
- \OC_Util::tearDownFS();
- \OC_Util::setupFS($rootLinkItem['uid_owner']);
- }
try {
- $path = Filesystem::getPath($linkItem['file_source']);
+ $path = Filesystem::getPath($share->getNodeId());
} catch (NotFoundException $e) {
\OCP\Util::writeLog('share', 'could not resolve linkItem', \OCP\Util::DEBUG);
\OC_Response::setStatus(404);
@@ -83,15 +78,8 @@ class Helper {
exit();
}
- if (!isset($linkItem['item_type'])) {
- \OCP\Util::writeLog('share', 'No item type set for share id: ' . $linkItem['id'], \OCP\Util::ERROR);
- \OC_Response::setStatus(404);
- \OCP\JSON::error(array('success' => false));
- exit();
- }
-
- if (isset($linkItem['share_with']) && (int)$linkItem['share_type'] === \OCP\Share::SHARE_TYPE_LINK) {
- if (!self::authenticate($linkItem, $password)) {
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && $share->getPassword() !== null) {
+ if (!self::authenticate($share, $password)) {
\OC_Response::setStatus(403);
\OCP\JSON::error(array('success' => false));
exit();
@@ -105,7 +93,7 @@ class Helper {
}
return array(
- 'linkItem' => $linkItem,
+ 'share' => $share,
'basePath' => $basePath,
'realPath' => $path
);
@@ -114,53 +102,29 @@ class Helper {
/**
* Authenticate link item with the given password
* or with the session if no password was given.
- * @param array $linkItem link item array
+ * @param \OCP\Share\IShare $share
* @param string $password optional password
*
* @return boolean true if authorized, false otherwise
*/
- public static function authenticate($linkItem, $password = null) {
+ public static function authenticate($share, $password = null) {
+ $shareManager = \OC::$server->getShareManager();
+
if ($password !== null) {
- if ($linkItem['share_type'] == \OCP\Share::SHARE_TYPE_LINK) {
- // Check Password
- $newHash = '';
- if(\OC::$server->getHasher()->verify($password, $linkItem['share_with'], $newHash)) {
- // Save item id in session for future requests
- \OC::$server->getSession()->set('public_link_authenticated', (string) $linkItem['id']);
-
- /**
- * FIXME: Migrate old hashes to new hash format
- * Due to the fact that there is no reasonable functionality to update the password
- * of an existing share no migration is yet performed there.
- * The only possibility is to update the existing share which will result in a new
- * share ID and is a major hack.
- *
- * In the future the migration should be performed once there is a proper method
- * to update the share's password. (for example `$share->updatePassword($password)`
- *
- * @link https://github.com/owncloud/core/issues/10671
- */
- if(!empty($newHash)) {
-
- }
- } else {
- return false;
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
+ if ($shareManager->checkPassword($share, $password)) {
+ \OC::$server->getSession()->set('public_link_authenticated', (string)$share->getId());
+ return true;
}
- } else {
- \OCP\Util::writeLog('share', 'Unknown share type '.$linkItem['share_type']
- .' for share id '.$linkItem['id'], \OCP\Util::ERROR);
- return false;
}
-
- }
- else {
+ } else {
// not authenticated ?
- if ( ! \OC::$server->getSession()->exists('public_link_authenticated')
- || \OC::$server->getSession()->get('public_link_authenticated') !== (string)$linkItem['id']) {
- return false;
+ if (\OC::$server->getSession()->exists('public_link_authenticated')
+ && \OC::$server->getSession()->get('public_link_authenticated') !== (string)$share->getId()) {
+ return true;
}
}
- return true;
+ return false;
}
public static function getSharesFromItem($target) {
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index 4643e46eeb2..e7588a589e8 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -77,7 +77,7 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
if ($federatedShareProvider) {
$this->federatedShareProvider = $federatedShareProvider;
} else {
- $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
+ $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
$this->federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
}
}
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index c15001ad24b..8a906f02a7e 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -82,9 +82,9 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
?>
<span id="save" data-protected="<?php p($_['protected']) ?>"
data-owner-display-name="<?php p($_['displayName']) ?>" data-owner="<?php p($_['owner']) ?>" data-name="<?php p($_['filename']) ?>">
- <button id="save-button"><?php p($l->t('Add to your ownCloud')) ?></button>
+ <button id="save-button"><?php p($l->t('Add to your Nextcloud')) ?></button>
<form class="save-form hidden" action="#">
- <input type="text" id="remote_address" placeholder="example.com/owncloud"/>
+ <input type="text" id="remote_address" placeholder="user@yourNextcloud.org"/>
<button id="save-button-confirm" class="icon-confirm svg" disabled></button>
</form>
</span>
diff --git a/apps/files_sharing/tests/API/Share20OCSTest.php b/apps/files_sharing/tests/API/Share20OCSTest.php
index 6435c992f25..02c2eb42419 100644
--- a/apps/files_sharing/tests/API/Share20OCSTest.php
+++ b/apps/files_sharing/tests/API/Share20OCSTest.php
@@ -75,17 +75,17 @@ class Share20OCSTest extends \Test\TestCase {
->expects($this->any())
->method('shareApiEnabled')
->willReturn(true);
- $this->groupManager = $this->getMock('OCP\IGroupManager');
- $this->userManager = $this->getMock('OCP\IUserManager');
- $this->request = $this->getMock('OCP\IRequest');
- $this->rootFolder = $this->getMock('OCP\Files\IRootFolder');
- $this->urlGenerator = $this->getMock('OCP\IURLGenerator');
- $this->currentUser = $this->getMock('OCP\IUser');
+ $this->groupManager = $this->getMockBuilder('OCP\IGroupManager')->getMock();
+ $this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock();
+ $this->request = $this->getMockBuilder('OCP\IRequest')->getMock();
+ $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock();
+ $this->urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')->getMock();
+ $this->currentUser = $this->getMockBuilder('OCP\IUser')->getMock();
$this->currentUser->method('getUID')->willReturn('currentUser');
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
- $this->l = $this->getMock('\OCP\IL10N');
+ $this->l = $this->getMockBuilder('\OCP\IL10N')->getMock();
$this->l->method('t')
->will($this->returnCallback(function($text, $parameters = []) {
return vsprintf($text, $parameters);
@@ -141,7 +141,7 @@ class Share20OCSTest extends \Test\TestCase {
}
public function testDeleteShare() {
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = $this->newShare();
$share->setSharedBy($this->currentUser->getUID())
@@ -168,7 +168,7 @@ class Share20OCSTest extends \Test\TestCase {
}
public function testDeleteShareLocked() {
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = $this->newShare();
$share->setSharedBy($this->currentUser->getUID())
@@ -213,7 +213,7 @@ class Share20OCSTest extends \Test\TestCase {
public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions,
$shareTime, $expiration, $parent, $target, $mail_send, $token=null,
$password=null) {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share->method('getId')->willReturn($id);
$share->method('getShareType')->willReturn($shareType);
$share->method('getSharedWith')->willReturn($sharedWith);
@@ -253,17 +253,17 @@ class Share20OCSTest extends \Test\TestCase {
$storage->method('getId')->willReturn('STORAGE');
$storage->method('getCache')->willReturn($cache);
- $parentFolder = $this->getMock('OCP\Files\Folder');
+ $parentFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$parentFolder->method('getId')->willReturn(3);
- $file = $this->getMock('OCP\Files\File');
+ $file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getId')->willReturn(1);
$file->method('getPath')->willReturn('file');
$file->method('getStorage')->willReturn($storage);
$file->method('getParent')->willReturn($parentFolder);
$file->method('getMimeType')->willReturn('myMimeType');
- $folder = $this->getMock('OCP\Files\Folder');
+ $folder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$folder->method('getId')->willReturn(2);
$folder->method('getPath')->willReturn('folder');
$folder->method('getStorage')->willReturn($storage);
@@ -428,7 +428,7 @@ class Share20OCSTest extends \Test\TestCase {
->with($share->getFullId())
->willReturn($share);
- $userFolder = $this->getMock('OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$userFolder
->method('getRelativePath')
->will($this->returnArgument(0));
@@ -445,19 +445,19 @@ class Share20OCSTest extends \Test\TestCase {
->method('linkToRouteAbsolute')
->willReturn('url');
- $initiator = $this->getMock('OCP\IUser');
+ $initiator = $this->getMockBuilder('OCP\IUser')->getMock();
$initiator->method('getUID')->willReturn('initiatorId');
$initiator->method('getDisplayName')->willReturn('initiatorDisplay');
- $owner = $this->getMock('OCP\IUser');
+ $owner = $this->getMockBuilder('OCP\IUser')->getMock();
$owner->method('getUID')->willReturn('ownerId');
$owner->method('getDisplayName')->willReturn('ownerDisplay');
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')->getMock();
$user->method('getUID')->willReturn('userId');
$user->method('getDisplayName')->willReturn('userDisplay');
- $group = $this->getMock('OCP\IGroup');
+ $group = $this->getMockBuilder('OCP\IGroup')->getMock();
$group->method('getGID')->willReturn('groupId');
$this->userManager->method('get')->will($this->returnValueMap([
@@ -490,31 +490,31 @@ class Share20OCSTest extends \Test\TestCase {
}
public function testCanAccessShare() {
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareOwner')->willReturn($this->currentUser->getUID());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getSharedBy')->willReturn($this->currentUser->getUID());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$share->method('getSharedWith')->willReturn($this->currentUser->getUID());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
- $share->method('getSharedWith')->willReturn($this->getMock('OCP\IUser'));
+ $share->method('getSharedWith')->willReturn($this->getMockBuilder('OCP\IUser')->getMock());
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
$share->method('getSharedWith')->willReturn('group');
- $group = $this->getMock('OCP\IGroup');
+ $group = $this->getMockBuilder('OCP\IGroup')->getMock();
$group->method('inGroup')->with($this->currentUser)->willReturn(true);
- $group2 = $this->getMock('OCP\IGroup');
+ $group2 = $this->getMockBuilder('OCP\IGroup')->getMock();
$group2->method('inGroup')->with($this->currentUser)->willReturn(false);
@@ -524,14 +524,14 @@ class Share20OCSTest extends \Test\TestCase {
]));
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
$share->method('getSharedWith')->willReturn('group2');
$this->groupManager->method('get')->with('group2')->willReturn($group);
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
}
@@ -552,7 +552,7 @@ class Share20OCSTest extends \Test\TestCase {
['path', null, 'invalid-path'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
@@ -582,13 +582,13 @@ class Share20OCSTest extends \Test\TestCase {
['permissions', null, 32],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
$userFolder->expects($this->once())
->method('get')
->with('valid-path')
@@ -618,14 +618,14 @@ class Share20OCSTest extends \Test\TestCase {
['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -660,14 +660,14 @@ class Share20OCSTest extends \Test\TestCase {
['shareWith', $this->any(), 'invalidUser'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -715,14 +715,14 @@ class Share20OCSTest extends \Test\TestCase {
['shareWith', null, 'validUser'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -776,14 +776,14 @@ class Share20OCSTest extends \Test\TestCase {
['shareWith', $this->any(), 'invalidGroup'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -831,14 +831,14 @@ class Share20OCSTest extends \Test\TestCase {
['shareWith', null, 'validGroup'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -891,14 +891,14 @@ class Share20OCSTest extends \Test\TestCase {
['shareWith', null, 'validGroup'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -930,8 +930,8 @@ class Share20OCSTest extends \Test\TestCase {
['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -957,8 +957,8 @@ class Share20OCSTest extends \Test\TestCase {
['publicUpload', null, 'true'],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -985,8 +985,8 @@ class Share20OCSTest extends \Test\TestCase {
['publicUpload', null, 'true'],
]));
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1018,8 +1018,8 @@ class Share20OCSTest extends \Test\TestCase {
['password', '', ''],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1062,8 +1062,8 @@ class Share20OCSTest extends \Test\TestCase {
['password', '', 'password'],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1106,8 +1106,8 @@ class Share20OCSTest extends \Test\TestCase {
['password', '', ''],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1153,8 +1153,8 @@ class Share20OCSTest extends \Test\TestCase {
['password', '', ''],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1203,14 +1203,14 @@ class Share20OCSTest extends \Test\TestCase {
['shareWith', null, 'validUser'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(true);
@@ -1235,7 +1235,7 @@ class Share20OCSTest extends \Test\TestCase {
}
public function testUpdateShareCantAccess() {
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = $this->newShare();
$share->setNode($node);
@@ -1253,7 +1253,7 @@ class Share20OCSTest extends \Test\TestCase {
}
public function testUpdateNoParametersLink() {
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
@@ -1274,7 +1274,7 @@ class Share20OCSTest extends \Test\TestCase {
}
public function testUpdateNoParametersOther() {
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
@@ -1297,7 +1297,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateLinkShareClear() {
$ocs = $this->mockFormatShare();
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
@@ -1342,7 +1342,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateLinkShareSet() {
$ocs = $this->mockFormatShare();
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1385,7 +1385,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateLinkShareEnablePublicUpload($params) {
$ocs = $this->mockFormatShare();
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1420,7 +1420,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateLinkShareInvalidDate() {
$ocs = $this->mockFormatShare();
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1472,7 +1472,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateLinkSharePublicUploadNotAllowed($params) {
$ocs = $this->mockFormatShare();
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1497,7 +1497,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateLinkSharePublicUploadOnFile() {
$ocs = $this->mockFormatShare();
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1529,7 +1529,7 @@ class Share20OCSTest extends \Test\TestCase {
$date = new \DateTime('2000-01-01');
$date->setTime(0,0,0);
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
@@ -1572,7 +1572,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateLinkShareExpireDateDoesNotChangeOther() {
$ocs = $this->mockFormatShare();
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
@@ -1620,7 +1620,7 @@ class Share20OCSTest extends \Test\TestCase {
$date = new \DateTime('2000-01-01');
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1660,7 +1660,7 @@ class Share20OCSTest extends \Test\TestCase {
$date = new \DateTime('2000-01-01');
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1702,7 +1702,7 @@ class Share20OCSTest extends \Test\TestCase {
$date = new \DateTime('2000-01-01');
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1732,7 +1732,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateOtherPermissions() {
$ocs = $this->mockFormatShare();
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1765,9 +1765,9 @@ class Share20OCSTest extends \Test\TestCase {
}
public function dataFormatShare() {
- $file = $this->getMock('\OCP\Files\File');
- $folder = $this->getMock('\OCP\Files\Folder');
- $parent = $this->getMock('\OCP\Files\Folder');
+ $file = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $parent = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$file->method('getMimeType')->willReturn('myMimeType');
$folder->method('getMimeType')->willReturn('myFolderMimeType');
@@ -1782,20 +1782,20 @@ class Share20OCSTest extends \Test\TestCase {
$file->method('getParent')->willReturn($parent);
$folder->method('getParent')->willReturn($parent);
- $cache = $this->getMock('OCP\Files\Cache\ICache');
+ $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock();
$cache->method('getNumericStorageId')->willReturn(100);
- $storage = $this->getMock('\OCP\Files\Storage');
+ $storage = $this->getMockBuilder('\OCP\Files\Storage')->getMock();
$storage->method('getId')->willReturn('storageId');
$storage->method('getCache')->willReturn($cache);
$file->method('getStorage')->willReturn($storage);
$folder->method('getStorage')->willReturn($storage);
- $owner = $this->getMock('\OCP\IUser');
+ $owner = $this->getMockBuilder('\OCP\IUser')->getMock();
$owner->method('getDisplayName')->willReturn('ownerDN');
- $initiator = $this->getMock('\OCP\IUser');
+ $initiator = $this->getMockBuilder('\OCP\IUser')->getMock();
$initiator->method('getDisplayName')->willReturn('initiatorDN');
- $recipient = $this->getMock('\OCP\IUser');
+ $recipient = $this->getMockBuilder('\OCP\IUser')->getMock();
$recipient->method('getDisplayName')->willReturn('recipientDN');
$result = [];
diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php
index 40c9085353c..c642f21ef1c 100644
--- a/apps/files_sharing/tests/ApiTest.php
+++ b/apps/files_sharing/tests/ApiTest.php
@@ -81,7 +81,7 @@ class ApiTest extends TestCase {
* @return \OCP\IRequest
*/
private function createRequest(array $data) {
- $request = $this->getMock('\OCP\IRequest');
+ $request = $this->getMockBuilder('\OCP\IRequest')->getMock();
$request->method('getParam')
->will($this->returnCallback(function($param, $default = null) use ($data) {
if (isset($data[$param])) {
@@ -100,7 +100,7 @@ class ApiTest extends TestCase {
private function createOCS($request, $userId) {
$currentUser = \OC::$server->getUserManager()->get($userId);
- $l = $this->getMock('\OCP\IL10N');
+ $l = $this->getMockBuilder('\OCP\IL10N')->getMock();
$l->method('t')
->will($this->returnCallback(function($text, $parameters = []) {
return vsprintf($text, $parameters);
diff --git a/apps/files_sharing/tests/Controllers/ShareControllerTest.php b/apps/files_sharing/tests/Controllers/ShareControllerTest.php
index 0c35449fb1a..343d5c58d69 100644
--- a/apps/files_sharing/tests/Controllers/ShareControllerTest.php
+++ b/apps/files_sharing/tests/Controllers/ShareControllerTest.php
@@ -78,11 +78,11 @@ class ShareControllerTest extends \Test\TestCase {
$this->appName = 'files_sharing';
$this->shareManager = $this->getMockBuilder('\OC\Share20\Manager')->disableOriginalConstructor()->getMock();
- $this->urlGenerator = $this->getMock('\OCP\IURLGenerator');
- $this->session = $this->getMock('\OCP\ISession');
- $this->previewManager = $this->getMock('\OCP\IPreview');
- $this->config = $this->getMock('\OCP\IConfig');
- $this->userManager = $this->getMock('\OCP\IUserManager');
+ $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock();
+ $this->session = $this->getMockBuilder('\OCP\ISession')->getMock();
+ $this->previewManager = $this->getMockBuilder('\OCP\IPreview')->getMock();
+ $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
+ $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
$this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider')
->disableOriginalConstructor()->getMock();
$this->federatedShareProvider->expects($this->any())
@@ -92,16 +92,16 @@ class ShareControllerTest extends \Test\TestCase {
$this->shareController = new \OCA\Files_Sharing\Controllers\ShareController(
$this->appName,
- $this->getMock('\OCP\IRequest'),
+ $this->getMockBuilder('\OCP\IRequest')->getMock(),
$this->config,
$this->urlGenerator,
$this->userManager,
- $this->getMock('\OCP\ILogger'),
- $this->getMock('\OCP\Activity\IManager'),
+ $this->getMockBuilder('\OCP\ILogger')->getMock(),
+ $this->getMockBuilder('\OCP\Activity\IManager')->getMock(),
$this->shareManager,
$this->session,
$this->previewManager,
- $this->getMock('\OCP\Files\IRootFolder'),
+ $this->getMockBuilder('\OCP\Files\IRootFolder')->getMock(),
$this->federatedShareProvider
);
@@ -310,11 +310,11 @@ class ShareControllerTest extends \Test\TestCase {
public function testShowShare() {
- $owner = $this->getMock('OCP\IUser');
+ $owner = $this->getMockBuilder('OCP\IUser')->getMock();
$owner->method('getDisplayName')->willReturn('ownerDisplay');
$owner->method('getUID')->willReturn('ownerUID');
- $file = $this->getMock('OCP\Files\File');
+ $file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getName')->willReturn('file1.txt');
$file->method('getMimetype')->willReturn('text/plain');
$file->method('getSize')->willReturn(33);
@@ -389,11 +389,11 @@ class ShareControllerTest extends \Test\TestCase {
* @expectedException \OCP\Files\NotFoundException
*/
public function testShowShareInvalid() {
- $owner = $this->getMock('OCP\IUser');
+ $owner = $this->getMockBuilder('OCP\IUser')->getMock();
$owner->method('getDisplayName')->willReturn('ownerDisplay');
$owner->method('getUID')->willReturn('ownerUID');
- $file = $this->getMock('OCP\Files\File');
+ $file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getName')->willReturn('file1.txt');
$file->method('getMimetype')->willReturn('text/plain');
$file->method('getSize')->willReturn(33);
@@ -434,7 +434,7 @@ class ShareControllerTest extends \Test\TestCase {
}
public function testDownloadShare() {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share->method('getPassword')->willReturn('password');
$share
->expects($this->once())
@@ -459,7 +459,7 @@ class ShareControllerTest extends \Test\TestCase {
}
public function testDownloadShareWithCreateOnlyShare() {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share->method('getPassword')->willReturn('password');
$share
->expects($this->once())
diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php
index 90d9f0a8567..ea2e213ca9a 100644
--- a/apps/files_sharing/tests/MountProviderTest.php
+++ b/apps/files_sharing/tests/MountProviderTest.php
@@ -56,23 +56,23 @@ class MountProviderTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->config = $this->getMock('OCP\IConfig');
- $this->user = $this->getMock('OCP\IUser');
- $this->loader = $this->getMock('OCP\Files\Storage\IStorageFactory');
- $this->shareManager = $this->getMock('\OCP\Share\IManager');
- $this->logger = $this->getMock('\OCP\ILogger');
+ $this->config = $this->getMockBuilder('OCP\IConfig')->getMock();
+ $this->user = $this->getMockBuilder('OCP\IUser')->getMock();
+ $this->loader = $this->getMockBuilder('OCP\Files\Storage\IStorageFactory')->getMock();
+ $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')->getMock();
+ $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
$this->provider = new MountProvider($this->config, $this->shareManager, $this->logger);
}
public function testExcludeShares() {
/** @var IShare | \PHPUnit_Framework_MockObject_MockObject $share1 */
- $share1 = $this->getMock('\OCP\Share\IShare');
+ $share1 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share1->expects($this->once())
->method('getPermissions')
->will($this->returnValue(0));
- $share2 = $this->getMock('\OCP\Share\IShare');
+ $share2 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share2->expects($this->once())
->method('getPermissions')
->will($this->returnValue(31));
@@ -83,13 +83,13 @@ class MountProviderTest extends \Test\TestCase {
->method('getTarget')
->will($this->returnValue('/share2'));
- $share3 = $this->getMock('\OCP\Share\IShare');
+ $share3 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share3->expects($this->once())
->method('getPermissions')
->will($this->returnValue(0));
/** @var IShare | \PHPUnit_Framework_MockObject_MockObject $share4 */
- $share4 = $this->getMock('\OCP\Share\IShare');
+ $share4 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share4->expects($this->once())
->method('getPermissions')
->will($this->returnValue(31));
@@ -100,7 +100,7 @@ class MountProviderTest extends \Test\TestCase {
->method('getTarget')
->will($this->returnValue('/share4'));
- $share5 = $this->getMock('\OCP\Share\IShare');
+ $share5 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share5->expects($this->once())
->method('getPermissions')
->will($this->returnValue(31));
diff --git a/apps/systemtags/l10n/it.js b/apps/systemtags/l10n/it.js
index 4a2dfc93a79..4d6ae6b8a72 100644
--- a/apps/systemtags/l10n/it.js
+++ b/apps/systemtags/l10n/it.js
@@ -1,26 +1,26 @@
OC.L10N.register(
"systemtags",
{
- "Tags" : "Tag",
- "Tagged files" : "File con tag",
- "Select tags to filter by" : "Seleziona i tag per filtrare",
- "Please select tags to filter by" : "Seleziona i tag per filtrare",
- "No files found for the selected tags" : "Nessun file trovato per i tag selezionati",
- "<strong>System tags</strong> for a file have been modified" : "I <strong>tag di sistema</strong> per un file sono stati modificati",
- "You assigned system tag %3$s" : "Hai assegnato il tag di sistema %3$s",
- "%1$s assigned system tag %3$s" : "%1$s ha assegnato il tag di sistema %3$s",
- "You unassigned system tag %3$s" : "Hai rimosso il tag di sistema %3$s",
- "%1$s unassigned system tag %3$s" : "%1$s ha rimosso il tag di sistema %3$s",
- "You created system tag %2$s" : "Hai creato il tag di sistema %2$s",
- "%1$s created system tag %2$s" : "%1$s ha creato il tag di sistema %2$s",
- "You deleted system tag %2$s" : "Hai eliminato il tag di sistema %2$s",
- "%1$s deleted system tag %2$s" : "%1$s ha eliminato il tag di sistema %2$s",
- "You updated system tag %3$s to %2$s" : "Hai aggiornato il tag di sistema %3$s in %2$s",
- "%1$s updated system tag %3$s to %2$s" : "%1$s ha aggiornato il tag di sistema %3$s in %2$s",
- "You assigned system tag %3$s to %2$s" : "Hai assegnato il tag di sistema %3$s a %2$s",
- "%1$s assigned system tag %3$s to %2$s" : "%1$s ha assegnato il tag di sistema %3$s a %2$s",
- "You unassigned system tag %3$s from %2$s" : "Hai rimosso il tag di sistema %3$s da %2$s",
- "%1$s unassigned system tag %3$s from %2$s" : "%1$s ha rimosso il tag di sistema %3$s da %2$s",
+ "Tags" : "Etichette",
+ "Tagged files" : "File etichettati",
+ "Select tags to filter by" : "Seleziona le etichette per filtrare",
+ "Please select tags to filter by" : "Seleziona le etichette per filtrare",
+ "No files found for the selected tags" : "Nessun file trovato per le etichette selezionate",
+ "<strong>System tags</strong> for a file have been modified" : "Le <strong>etichette di sistema</strong> per un file sono state modificate",
+ "You assigned system tag %3$s" : "Hai assegnato l'etichetta di sistema %3$s",
+ "%1$s assigned system tag %3$s" : "%1$s ha assegnato l'etichetta di sistema %3$s",
+ "You unassigned system tag %3$s" : "Hai rimosso l'etichetta di sistema %3$s",
+ "%1$s unassigned system tag %3$s" : "%1$s ha rimosso l'etichetta di sistema %3$s",
+ "You created system tag %2$s" : "Hai creato l'etichetta di sistema %2$s",
+ "%1$s created system tag %2$s" : "%1$s ha creato l'etichetta di sistema %2$s",
+ "You deleted system tag %2$s" : "Hai eliminato l'etichetta di sistema %2$s",
+ "%1$s deleted system tag %2$s" : "%1$s ha eliminato l'etichetta di sistema %2$s",
+ "You updated system tag %3$s to %2$s" : "Hai aggiornato l'etichetta di sistema %3$s in %2$s",
+ "%1$s updated system tag %3$s to %2$s" : "%1$s ha aggiornato l'etichetta di sistema %3$s in %2$s",
+ "You assigned system tag %3$s to %2$s" : "Hai assegnato l'etichetta di sistema %3$s a %2$s",
+ "%1$s assigned system tag %3$s to %2$s" : "%1$s ha assegnato l'etichetta di sistema %3$s a %2$s",
+ "You unassigned system tag %3$s from %2$s" : "Hai rimosso l'etichetta di sistema %3$s da %2$s",
+ "%1$s unassigned system tag %3$s from %2$s" : "%1$s ha rimosso l'etichetta di sistema %3$s da %2$s",
"%s (restricted)" : "%s (limitato)",
"%s (invisible)" : "%s (invisibile)",
"No files in here" : "Qui non c'è alcun file",
diff --git a/apps/systemtags/l10n/it.json b/apps/systemtags/l10n/it.json
index 78c96549406..fc7204f35a8 100644
--- a/apps/systemtags/l10n/it.json
+++ b/apps/systemtags/l10n/it.json
@@ -1,24 +1,24 @@
{ "translations": {
- "Tags" : "Tag",
- "Tagged files" : "File con tag",
- "Select tags to filter by" : "Seleziona i tag per filtrare",
- "Please select tags to filter by" : "Seleziona i tag per filtrare",
- "No files found for the selected tags" : "Nessun file trovato per i tag selezionati",
- "<strong>System tags</strong> for a file have been modified" : "I <strong>tag di sistema</strong> per un file sono stati modificati",
- "You assigned system tag %3$s" : "Hai assegnato il tag di sistema %3$s",
- "%1$s assigned system tag %3$s" : "%1$s ha assegnato il tag di sistema %3$s",
- "You unassigned system tag %3$s" : "Hai rimosso il tag di sistema %3$s",
- "%1$s unassigned system tag %3$s" : "%1$s ha rimosso il tag di sistema %3$s",
- "You created system tag %2$s" : "Hai creato il tag di sistema %2$s",
- "%1$s created system tag %2$s" : "%1$s ha creato il tag di sistema %2$s",
- "You deleted system tag %2$s" : "Hai eliminato il tag di sistema %2$s",
- "%1$s deleted system tag %2$s" : "%1$s ha eliminato il tag di sistema %2$s",
- "You updated system tag %3$s to %2$s" : "Hai aggiornato il tag di sistema %3$s in %2$s",
- "%1$s updated system tag %3$s to %2$s" : "%1$s ha aggiornato il tag di sistema %3$s in %2$s",
- "You assigned system tag %3$s to %2$s" : "Hai assegnato il tag di sistema %3$s a %2$s",
- "%1$s assigned system tag %3$s to %2$s" : "%1$s ha assegnato il tag di sistema %3$s a %2$s",
- "You unassigned system tag %3$s from %2$s" : "Hai rimosso il tag di sistema %3$s da %2$s",
- "%1$s unassigned system tag %3$s from %2$s" : "%1$s ha rimosso il tag di sistema %3$s da %2$s",
+ "Tags" : "Etichette",
+ "Tagged files" : "File etichettati",
+ "Select tags to filter by" : "Seleziona le etichette per filtrare",
+ "Please select tags to filter by" : "Seleziona le etichette per filtrare",
+ "No files found for the selected tags" : "Nessun file trovato per le etichette selezionate",
+ "<strong>System tags</strong> for a file have been modified" : "Le <strong>etichette di sistema</strong> per un file sono state modificate",
+ "You assigned system tag %3$s" : "Hai assegnato l'etichetta di sistema %3$s",
+ "%1$s assigned system tag %3$s" : "%1$s ha assegnato l'etichetta di sistema %3$s",
+ "You unassigned system tag %3$s" : "Hai rimosso l'etichetta di sistema %3$s",
+ "%1$s unassigned system tag %3$s" : "%1$s ha rimosso l'etichetta di sistema %3$s",
+ "You created system tag %2$s" : "Hai creato l'etichetta di sistema %2$s",
+ "%1$s created system tag %2$s" : "%1$s ha creato l'etichetta di sistema %2$s",
+ "You deleted system tag %2$s" : "Hai eliminato l'etichetta di sistema %2$s",
+ "%1$s deleted system tag %2$s" : "%1$s ha eliminato l'etichetta di sistema %2$s",
+ "You updated system tag %3$s to %2$s" : "Hai aggiornato l'etichetta di sistema %3$s in %2$s",
+ "%1$s updated system tag %3$s to %2$s" : "%1$s ha aggiornato l'etichetta di sistema %3$s in %2$s",
+ "You assigned system tag %3$s to %2$s" : "Hai assegnato l'etichetta di sistema %3$s a %2$s",
+ "%1$s assigned system tag %3$s to %2$s" : "%1$s ha assegnato l'etichetta di sistema %3$s a %2$s",
+ "You unassigned system tag %3$s from %2$s" : "Hai rimosso l'etichetta di sistema %3$s da %2$s",
+ "%1$s unassigned system tag %3$s from %2$s" : "%1$s ha rimosso l'etichetta di sistema %3$s da %2$s",
"%s (restricted)" : "%s (limitato)",
"%s (invisible)" : "%s (invisibile)",
"No files in here" : "Qui non c'è alcun file",
diff --git a/apps/theming/js/settings-admin.js b/apps/theming/js/settings-admin.js
index bd4b4b34ed1..85e781411ed 100644
--- a/apps/theming/js/settings-admin.js
+++ b/apps/theming/js/settings-admin.js
@@ -31,17 +31,50 @@ function setThemingValue(setting, value) {
preview(setting, value);
}
+function calculateLuminance(rgb) {
+ var hexValue = rgb.replace(/[^0-9A-Fa-f]/, '');
+ var r,g,b;
+ if (hexValue.length === 3) {
+ hexValue = hexValue[0] + hexValue[0] + hexValue[1] + hexValue[1] + hexValue[2] + hexValue[2];
+ }
+ if (hexValue.length !== 6) {
+ return 0;
+ }
+ r = parseInt(hexValue.substring(0,2), 16);
+ g = parseInt(hexValue.substring(2,4), 16);
+ b = parseInt(hexValue.substring(4,6), 16);
+ return (0.299*r + 0.587*g + 0.114*b)/255;
+}
+
function preview(setting, value) {
if (setting === 'color') {
var headerClass = document.getElementById('header');
+ var expandDisplayNameClass = document.getElementById('expandDisplayName');
+ var headerAppName = headerClass.getElementsByClassName('header-appname')[0];
+ var textColor, icon;
+
+ if (calculateLuminance(value) > 0.5) {
+ textColor = "#000000";
+ icon = 'caret-dark';
+ } else {
+ textColor = "#ffffff";
+ icon = 'caret';
+ }
+
headerClass.style.background = value;
headerClass.style.backgroundImage = '../img/logo-icon.svg';
+ expandDisplayNameClass.style.color = textColor;
+ headerAppName.style.color = textColor;
+
+ $(headerClass).find('.icon-caret').each(function() {
+ $(this).css('background-image', "url('" + OC.getRootPath() + '/core/img/actions/' + icon + ".svg')");
+ });
}
if (setting === 'logoMime') {
console.log(setting);
var logos = document.getElementsByClassName('logo-icon');
var timestamp = new Date().getTime();
- if(value !== '') {
+ if (value !== '') {
logos[0].style.background = "url('" + OC.generateUrl('/apps/theming/logo') + "?v" + timestamp + "')";
logos[0].style.backgroundSize = "62px 34px";
} else {
diff --git a/apps/theming/lib/controller/themingcontroller.php b/apps/theming/lib/controller/themingcontroller.php
index a9ac36ca786..303bb85f540 100644
--- a/apps/theming/lib/controller/themingcontroller.php
+++ b/apps/theming/lib/controller/themingcontroller.php
@@ -30,6 +30,7 @@ use OCP\Files\IRootFolder;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
+use OCA\Theming\Util;
/**
* Class ThemingController
@@ -231,6 +232,12 @@ class ThemingController extends Controller {
background-image: url(\'./loginbackground?v='.$cacheBusterValue.'\');
}';
}
+ if(Util::invertTextColor($color)) {
+ $responseCss .= '#header .header-appname, #expandDisplayName { color: #000000; } ';
+ $responseCss .= '#header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); } ';
+ $responseCss .= '.searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }';
+ $responseCss .= '.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }';
+ }
\OC_Response::setExpiresHeader(gmdate('D, d M Y H:i:s', time() + (60*60*24*45)) . ' GMT');
\OC_Response::enableCaching();
diff --git a/apps/theming/lib/util.php b/apps/theming/lib/util.php
new file mode 100644
index 00000000000..8ff5ae89b14
--- /dev/null
+++ b/apps/theming/lib/util.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Theming;
+
+class Util {
+
+ /**
+ * @param string $color rgb color value
+ * @return bool
+ */
+ public static function invertTextColor($color) {
+ $l = self::calculateLuminance($color);
+ if($l>0.5) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @param string $color rgb color value
+ * @return float
+ */
+ public static function calculateLuminance($color) {
+ $hex = preg_replace("/[^0-9A-Fa-f]/", '', $color);
+ if (strlen($hex) === 3) {
+ $hex = $hex{0} . $hex{0} . $hex{1} . $hex{1} . $hex{2} . $hex{2};
+ }
+ if (strlen($hex) !== 6) {
+ return 0;
+ }
+ $r = hexdec(substr($hex, 0, 2));
+ $g = hexdec(substr($hex, 2, 2));
+ $b = hexdec(substr($hex, 4, 2));
+ return (0.299 * $r + 0.587 * $g + 0.114 * $b)/255;
+ }
+
+}
diff --git a/apps/theming/tests/lib/UtilTest.php b/apps/theming/tests/lib/UtilTest.php
new file mode 100644
index 00000000000..266e6fc6c2d
--- /dev/null
+++ b/apps/theming/tests/lib/UtilTest.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCA\Theming\Tests;
+
+use OCA\Theming\Util;
+use Test\TestCase;
+
+class UtilTest extends TestCase {
+
+ public function testInvertTextColorLight() {
+ $invert = Util::invertTextColor('#ffffff');
+ $this->assertEquals(true, $invert);
+ }
+
+ public function testInvertTextColorDark() {
+ $invert = Util::invertTextColor('#000000');
+ $this->assertEquals(false, $invert);
+ }
+
+ public function testCalculateLuminanceLight() {
+ $luminance = Util::calculateLuminance('#ffffff');
+ $this->assertEquals(1, $luminance);
+ }
+
+ public function testCalculateLuminanceDark() {
+ $luminance = Util::calculateLuminance('#000000');
+ $this->assertEquals(0, $luminance);
+ }
+
+ public function testCalculateLuminanceLightShorthand() {
+ $luminance = Util::calculateLuminance('#fff');
+ $this->assertEquals(1, $luminance);
+ }
+
+ public function testCalculateLuminanceDarkShorthand() {
+ $luminance = Util::calculateLuminance('#000');
+ $this->assertEquals(0, $luminance);
+ }
+ public function testInvertTextColorInvalid() {
+ $invert = Util::invertTextColor('aaabbbcccddd123');
+ $this->assertEquals(false, $invert);
+ }
+
+ public function testInvertTextColorEmpty() {
+ $invert = Util::invertTextColor('');
+ $this->assertEquals(false, $invert);
+ }
+}
diff --git a/apps/theming/tests/lib/controller/ThemingControllerTest.php b/apps/theming/tests/lib/controller/ThemingControllerTest.php
index d08ebce8663..1ed82ab8b58 100644
--- a/apps/theming/tests/lib/controller/ThemingControllerTest.php
+++ b/apps/theming/tests/lib/controller/ThemingControllerTest.php
@@ -311,6 +311,33 @@ class ThemingControllerTest extends TestCase {
->expects($this->at(1))
->method('getAppValue')
->with('theming', 'color', '')
+ ->willReturn('#000');
+ $this->config
+ ->expects($this->at(2))
+ ->method('getAppValue')
+ ->with('theming', 'logoMime', '')
+ ->willReturn('');
+ $this->config
+ ->expects($this->at(3))
+ ->method('getAppValue')
+ ->with('theming', 'backgroundMime', '')
+ ->willReturn('');
+
+ $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header {background-color: #000}', 'style', 'text/css');
+ $expected->cacheFor(3600);
+ @$this->assertEquals($expected, $this->themingController->getStylesheet());
+ }
+
+ public function testGetStylesheetWithOnlyColorInvert() {
+ $this->config
+ ->expects($this->at(0))
+ ->method('getAppValue')
+ ->with('theming', 'cachebuster', '0')
+ ->willReturn('0');
+ $this->config
+ ->expects($this->at(1))
+ ->method('getAppValue')
+ ->with('theming', 'color', '')
->willReturn('#fff');
$this->config
->expects($this->at(2))
@@ -323,7 +350,7 @@ class ThemingControllerTest extends TestCase {
->with('theming', 'backgroundMime', '')
->willReturn('');
- $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header {background-color: #fff}', 'style', 'text/css');
+ $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header {background-color: #fff}#header .header-appname, #expandDisplayName { color: #000000; } #header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); } .searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }', 'style', 'text/css');
$expected->cacheFor(3600);
@$this->assertEquals($expected, $this->themingController->getStylesheet());
}
@@ -400,7 +427,7 @@ class ThemingControllerTest extends TestCase {
->expects($this->at(1))
->method('getAppValue')
->with('theming', 'color', '')
- ->willReturn('#abc');
+ ->willReturn('#000');
$this->config
->expects($this->at(2))
->method('getAppValue')
@@ -412,7 +439,7 @@ class ThemingControllerTest extends TestCase {
->with('theming', 'backgroundMime', '')
->willReturn('image/png');
- $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header {background-color: #abc}#header .logo {
+ $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header {background-color: #000}#header .logo {
background-image: url(\'./logo?v=0\');
}
#header .logo-icon {
@@ -424,5 +451,39 @@ class ThemingControllerTest extends TestCase {
$expected->cacheFor(3600);
@$this->assertEquals($expected, $this->themingController->getStylesheet());
}
+ public function testGetStylesheetWithAllCombinedInverted() {
+ $this->config
+ ->expects($this->at(0))
+ ->method('getAppValue')
+ ->with('theming', 'cachebuster', '0')
+ ->willReturn('0');
+ $this->config
+ ->expects($this->at(1))
+ ->method('getAppValue')
+ ->with('theming', 'color', '')
+ ->willReturn('#fff');
+ $this->config
+ ->expects($this->at(2))
+ ->method('getAppValue')
+ ->with('theming', 'logoMime', '')
+ ->willReturn('text/svg');
+ $this->config
+ ->expects($this->at(3))
+ ->method('getAppValue')
+ ->with('theming', 'backgroundMime', '')
+ ->willReturn('image/png');
+
+ $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header {background-color: #fff}#header .logo {
+ background-image: url(\'./logo?v=0\');
+ }
+ #header .logo-icon {
+ background-image: url(\'./logo?v=0\');
+ background-size: 62px 34px;
+ }#body-login {
+ background-image: url(\'./loginbackground?v=0\');
+ }#header .header-appname, #expandDisplayName { color: #000000; } #header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); } .searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }', 'style', 'text/css');
+ $expected->cacheFor(3600);
+ @$this->assertEquals($expected, $this->themingController->getStylesheet());
+ }
}
diff --git a/apps/updatenotification/l10n/cs_CZ.js b/apps/updatenotification/l10n/cs_CZ.js
index a9c22301675..37fef1c73f9 100644
--- a/apps/updatenotification/l10n/cs_CZ.js
+++ b/apps/updatenotification/l10n/cs_CZ.js
@@ -13,6 +13,8 @@ OC.L10N.register(
"Checked on %s" : "Zkontrolováno %s",
"Update channel:" : "Aktualizovat kanál:",
"You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel." : "Vždy můžete aktualizovat na novější verzi / experimentální kanál. Poté ale nelze nikdy provést downgrade zpět na nižší stabilní kanál.",
- "Notify members of the following groups about available updates:" : "Upozorňovat členy následujících skupin na dostupné aktualizace:"
+ "Notify members of the following groups about available updates:" : "Upozorňovat členy následujících skupin na dostupné aktualizace:",
+ "Only notification for app updates are available." : "Je možné pouze upozornění na dostupné aktualizace aplikací.",
+ "The selected update channel does not support updates of the server." : "Vybraný kanál aktualizací nepodporuje aktualizace serveru."
},
"nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;");
diff --git a/apps/updatenotification/l10n/cs_CZ.json b/apps/updatenotification/l10n/cs_CZ.json
index f22aa060276..29f2c9a027c 100644
--- a/apps/updatenotification/l10n/cs_CZ.json
+++ b/apps/updatenotification/l10n/cs_CZ.json
@@ -11,6 +11,8 @@
"Checked on %s" : "Zkontrolováno %s",
"Update channel:" : "Aktualizovat kanál:",
"You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel." : "Vždy můžete aktualizovat na novější verzi / experimentální kanál. Poté ale nelze nikdy provést downgrade zpět na nižší stabilní kanál.",
- "Notify members of the following groups about available updates:" : "Upozorňovat členy následujících skupin na dostupné aktualizace:"
+ "Notify members of the following groups about available updates:" : "Upozorňovat členy následujících skupin na dostupné aktualizace:",
+ "Only notification for app updates are available." : "Je možné pouze upozornění na dostupné aktualizace aplikací.",
+ "The selected update channel does not support updates of the server." : "Vybraný kanál aktualizací nepodporuje aktualizace serveru."
},"pluralForm" :"nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;"
} \ No newline at end of file