summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/features/app-files-sharing.feature83
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppSharingContext.php142
-rwxr-xr-xtests/acceptance/run-local.sh3
-rw-r--r--tests/lib/App/AppStore/Fetcher/FetcherBase.php6
-rw-r--r--tests/lib/AppFramework/Bootstrap/BootContextTest.php67
-rw-r--r--tests/lib/AppFramework/Bootstrap/CoordinatorTest.php128
-rw-r--r--tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php162
-rw-r--r--tests/lib/AppFramework/Controller/ControllerTest.php3
-rw-r--r--tests/lib/AppFramework/Http/DataResponseTest.php1
-rw-r--r--tests/lib/AppFramework/Http/RequestTest.php28
-rw-r--r--tests/lib/AppFramework/Http/ResponseTest.php30
-rw-r--r--tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php117
-rw-r--r--tests/lib/Collaboration/Collaborators/GroupPluginTest.php54
-rw-r--r--tests/lib/Collaboration/Collaborators/LookupPluginTest.php32
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php32
-rw-r--r--tests/lib/Collaboration/Collaborators/RemotePluginTest.php20
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchTest.php46
-rw-r--r--tests/lib/Collaboration/Collaborators/UserPluginTest.php161
-rw-r--r--tests/lib/Command/Integrity/SignAppTest.php10
-rw-r--r--tests/lib/Command/Integrity/SignCoreTest.php8
-rw-r--r--tests/lib/DB/OCPostgreSqlPlatformTest.php6
-rw-r--r--tests/lib/DB/schemDiffData/core.xml2
-rw-r--r--tests/lib/Files/Node/HookConnectorTest.php1
-rw-r--r--tests/lib/Files/ViewTest.php10
-rw-r--r--tests/lib/Repair/OldGroupMembershipSharesTest.php8
-rw-r--r--tests/lib/Repair/RepairInvalidSharesTest.php6
-rw-r--r--tests/lib/Share/ShareTest.php20
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php285
-rw-r--r--tests/lib/Share20/LegacyHooksTest.php29
-rw-r--r--tests/lib/Share20/ManagerTest.php246
-rw-r--r--tests/lib/Support/CrashReport/RegistryTest.php48
-rw-r--r--tests/lib/TagsTest.php3
32 files changed, 1302 insertions, 495 deletions
diff --git a/tests/acceptance/features/app-files-sharing.feature b/tests/acceptance/features/app-files-sharing.feature
index e3b0ec30cf8..e0701efd9f2 100644
--- a/tests/acceptance/features/app-files-sharing.feature
+++ b/tests/acceptance/features/app-files-sharing.feature
@@ -294,3 +294,86 @@ Feature: app-files-sharing
And I open the "Sharing" tab in the details view
And I see that the "Sharing" tab in the details view is eventually loaded
And I see that resharing the file is not allowed
+
+ Scenario: sharee can not reshare a file with edit permission if the sharer disables it
+ Given I act as John
+ And I am logged in as the admin
+ And I act as Jane
+ And I am logged in
+ And I act as John
+ And I rename "welcome.txt" to "farewell.txt"
+ And I see that the file list contains a file named "farewell.txt"
+ And I share "farewell.txt" with "user0"
+ And I see that the file is shared with "user0"
+ And I set the share with "user0" as not editable
+ And I see that "user0" can not edit the share
+ When I act as Jane
+ # The Files app is open again to reload the file list
+ And I open the Files app
+ And I share "farewell.txt" with "user1"
+ Then I see that the file is shared with "user1"
+ And I see that "user1" can not edit the share
+ And I see that "user1" can not be allowed to edit the share
+
+ Scenario: sharee can not reshare a folder with create permission if the sharer disables it
+ Given I act as John
+ And I am logged in as the admin
+ And I act as Jane
+ And I am logged in
+ And I act as John
+ And I create a new folder named "Shared folder"
+ And I see that the file list contains a file named "Shared folder"
+ And I share "Shared folder" with "user0"
+ And I see that the file is shared with "user0"
+ And I set the share with "user0" as not creatable
+ And I see that "user0" can not create in the share
+ When I act as Jane
+ # The Files app is open again to reload the file list
+ And I open the Files app
+ And I share "Shared folder" with "user1"
+ Then I see that the file is shared with "user1"
+ And I see that "user1" can not create in the share
+ And I see that "user1" can not be allowed to create in the share
+
+ Scenario: sharee can revoke create permission from reshare after the sharer disabled it
+ Given I act as John
+ And I am logged in as the admin
+ And I act as Jane
+ And I am logged in
+ And I act as Jim
+ And I am logged in as "user1"
+ And I act as John
+ And I create a new folder named "Shared folder"
+ And I see that the file list contains a file named "Shared folder"
+ And I share "Shared folder" with "user0"
+ And I see that the file is shared with "user0"
+ And I act as Jane
+ # The Files app is open again to reload the file list
+ And I open the Files app
+ And I share "Shared folder" with "user1"
+ And I see that the file is shared with "user1"
+ And I act as John
+ And I set the share with "user0" as not creatable
+ And I see that "user0" can not create in the share
+ And I act as Jim
+ # The Files app is open again to reload the file list
+ And I open the Files app
+ And I enter in the folder named "Shared folder"
+ # Creation is still allowed in already created reshares
+ And I create a new folder named "Subfolder"
+ And I see that the file list contains a file named "Subfolder"
+ When I act as Jane
+ # The Files app is open again to reload the file list
+ And I open the Files app
+ And I open the details view for "Shared folder"
+ And I see that the details view is open
+ And I open the "Sharing" tab in the details view
+ And I see that the "Sharing" tab in the details view is eventually loaded
+ And I set the share with "user1" as not creatable
+ Then I see that "user1" can not create in the share
+ And I see that "user1" can not be allowed to create in the share
+ And I act as Jim
+ # The Files app is open again to reload the file list
+ And I open the Files app
+ And I enter in the folder named "Shared folder"
+ And I see that it is not possible to create new files
diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php
index 6b30d49d71e..80d21a0faf9 100644
--- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php
@@ -103,22 +103,64 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
- public static function canReshareCheckbox($sharedWithName) {
- // forThe()->checkbox("Can reshare") can not be used here; that would
- // return the checkbox itself, but the element that the user interacts
- // with is the label.
- return Locator::forThe()->xpath("//label[normalize-space() = 'Allow resharing']")->
+ public static function permissionCheckboxFor($sharedWithName, $itemText) {
+ // forThe()->checkbox($itemText) can not be used here; that would return
+ // the checkbox itself, but the element that the user interacts with is
+ // the label.
+ return Locator::forThe()->xpath("//label[normalize-space() = '$itemText']")->
descendantOf(self::shareWithMenu($sharedWithName))->
- describedAs("Allow resharing checkbox in the share with $sharedWithName menu in the details view in Files app");
+ describedAs("$itemText checkbox in the share with $sharedWithName menu in the details view in Files app");
}
/**
* @return Locator
*/
- public static function canReshareCheckboxInput($sharedWithName) {
- return Locator::forThe()->checkbox("Allow resharing")->
+ public static function permissionCheckboxInputFor($sharedWithName, $itemText) {
+ return Locator::forThe()->checkbox($itemText)->
descendantOf(self::shareWithMenu($sharedWithName))->
- describedAs("Allow resharing checkbox input in the share with $sharedWithName menu in the details view in Files app");
+ describedAs("$itemText checkbox input in the share with $sharedWithName menu in the details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function canEditCheckbox($sharedWithName) {
+ return self::permissionCheckboxFor($sharedWithName, 'Allow editing');
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function canEditCheckboxInput($sharedWithName) {
+ return self::permissionCheckboxInputFor($sharedWithName, 'Allow editing');
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function canCreateCheckbox($sharedWithName) {
+ return self::permissionCheckboxFor($sharedWithName, 'Allow creating');
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function canCreateCheckboxInput($sharedWithName) {
+ return self::permissionCheckboxInputFor($sharedWithName, 'Allow creating');
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function canReshareCheckbox($sharedWithName) {
+ return self::permissionCheckboxFor($sharedWithName, 'Allow resharing');
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function canReshareCheckboxInput($sharedWithName) {
+ return self::permissionCheckboxInputFor($sharedWithName, 'Allow resharing');
}
/**
@@ -359,6 +401,28 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
}
/**
+ * @When I set the share with :shareWithName as not editable
+ */
+ public function iSetTheShareWithAsNotEditable($shareWithName) {
+ $this->showShareWithMenuIfNeeded($shareWithName);
+
+ $this->iSeeThatCanEditTheShare($shareWithName);
+
+ $this->actor->find(self::canEditCheckbox($shareWithName), 2)->click();
+ }
+
+ /**
+ * @When I set the share with :shareWithName as not creatable
+ */
+ public function iSetTheShareWithAsNotCreatable($shareWithName) {
+ $this->showShareWithMenuIfNeeded($shareWithName);
+
+ $this->iSeeThatCanCreateInTheShare($shareWithName);
+
+ $this->actor->find(self::canCreateCheckbox($shareWithName), 2)->click();
+ }
+
+ /**
* @When I set the share with :shareWithName as not reshareable
*/
public function iSetTheShareWithAsNotReshareable($shareWithName) {
@@ -396,6 +460,66 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
}
/**
+ * @Then I see that :sharedWithName can not be allowed to edit the share
+ */
+ public function iSeeThatCanNotBeAllowedToEditTheShare($sharedWithName) {
+ $this->showShareWithMenuIfNeeded($sharedWithName);
+
+ PHPUnit_Framework_Assert::assertEquals(
+ $this->actor->find(self::canEditCheckboxInput($sharedWithName), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
+ }
+
+ /**
+ * @Then I see that :sharedWithName can edit the share
+ */
+ public function iSeeThatCanEditTheShare($sharedWithName) {
+ $this->showShareWithMenuIfNeeded($sharedWithName);
+
+ PHPUnit_Framework_Assert::assertTrue(
+ $this->actor->find(self::canEditCheckboxInput($sharedWithName), 10)->isChecked());
+ }
+
+ /**
+ * @Then I see that :sharedWithName can not edit the share
+ */
+ public function iSeeThatCanNotEditTheShare($sharedWithName) {
+ $this->showShareWithMenuIfNeeded($sharedWithName);
+
+ PHPUnit_Framework_Assert::assertFalse(
+ $this->actor->find(self::canEditCheckboxInput($sharedWithName), 10)->isChecked());
+ }
+
+ /**
+ * @Then I see that :sharedWithName can not be allowed to create in the share
+ */
+ public function iSeeThatCanNotBeAllowedToCreateInTheShare($sharedWithName) {
+ $this->showShareWithMenuIfNeeded($sharedWithName);
+
+ PHPUnit_Framework_Assert::assertEquals(
+ $this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
+ }
+
+ /**
+ * @Then I see that :sharedWithName can create in the share
+ */
+ public function iSeeThatCanCreateInTheShare($sharedWithName) {
+ $this->showShareWithMenuIfNeeded($sharedWithName);
+
+ PHPUnit_Framework_Assert::assertTrue(
+ $this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->isChecked());
+ }
+
+ /**
+ * @Then I see that :sharedWithName can not create in the share
+ */
+ public function iSeeThatCanNotCreateInTheShare($sharedWithName) {
+ $this->showShareWithMenuIfNeeded($sharedWithName);
+
+ PHPUnit_Framework_Assert::assertFalse(
+ $this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->isChecked());
+ }
+
+ /**
* @Then I see that :sharedWithName can reshare the share
*/
public function iSeeThatCanReshareTheShare($sharedWithName) {
diff --git a/tests/acceptance/run-local.sh b/tests/acceptance/run-local.sh
index cd63f287096..4da31e35e6c 100755
--- a/tests/acceptance/run-local.sh
+++ b/tests/acceptance/run-local.sh
@@ -64,6 +64,7 @@ if [ "$1" = "--acceptance-tests-dir" ]; then
fi
ACCEPTANCE_TESTS_CONFIG_DIR="../../$ACCEPTANCE_TESTS_DIR/config"
+DEV_BRANCH="master"
# "--timeout-multiplier N" option can be provided to set the timeout multiplier
# to be used in ActorContext.
@@ -195,7 +196,7 @@ ln --symbolic $(pwd) /var/www/html
# Add Notifications app to the "apps" directory (unless it is already there).
if [ ! -e "apps/notifications" ]; then
- (cd apps && git clone --depth 1 https://github.com/nextcloud/notifications)
+ (cd apps && git clone --depth 1 --branch ${DEV_BRANCH} https://github.com/nextcloud/notifications)
fi
INSTALL_AND_CONFIGURE_SERVER_PARAMETERS=""
diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php
index 2e04f22760e..199bcd4b59b 100644
--- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php
+++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php
@@ -550,7 +550,7 @@ abstract class FetcherBase extends TestCase {
->with(
$this->equalTo($this->endpoint),
$this->equalTo([
- 'timeout' => 10,
+ 'timeout' => 60,
'headers' => [
'If-None-Match' => '"myETag"'
]
@@ -622,7 +622,7 @@ abstract class FetcherBase extends TestCase {
->with(
$this->equalTo($this->endpoint),
$this->equalTo([
- 'timeout' => 10,
+ 'timeout' => 60,
'headers' => [
'If-None-Match' => '"myETag"',
]
@@ -709,7 +709,7 @@ abstract class FetcherBase extends TestCase {
->with(
$this->equalTo($this->endpoint),
$this->equalTo([
- 'timeout' => 10,
+ 'timeout' => 60,
])
)
->willReturn($response);
diff --git a/tests/lib/AppFramework/Bootstrap/BootContextTest.php b/tests/lib/AppFramework/Bootstrap/BootContextTest.php
new file mode 100644
index 00000000000..219c6d7e782
--- /dev/null
+++ b/tests/lib/AppFramework/Bootstrap/BootContextTest.php
@@ -0,0 +1,67 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @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 lib\AppFramework\Bootstrap;
+
+use OC\AppFramework\Bootstrap\BootContext;
+use OCP\AppFramework\IAppContainer;
+use OCP\IServerContainer;
+use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
+
+class BootContextTest extends TestCase {
+
+ /** @var IAppContainer|MockObject */
+ private $appContainer;
+
+ /** @var BootContext */
+ private $context;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->appContainer = $this->createMock(IAppContainer::class);
+
+ $this->context = new BootContext(
+ $this->appContainer
+ );
+ }
+
+ public function testGetAppContainer(): void {
+ $container = $this->context->getAppContainer();
+
+ $this->assertSame($this->appContainer, $container);
+ }
+
+ public function testGetServerContainer(): void {
+ $serverContainer = $this->createMock(IServerContainer::class);
+ $this->appContainer->method('getServer')
+ ->willReturn($serverContainer);
+
+ $container = $this->context->getServerContainer();
+
+ $this->assertSame($serverContainer, $container);
+ }
+}
diff --git a/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php
new file mode 100644
index 00000000000..6909ad94e7f
--- /dev/null
+++ b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php
@@ -0,0 +1,128 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @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 lib\AppFramework\Bootstrap;
+
+use OC\AppFramework\Bootstrap\Coordinator;
+use OC\Search\SearchComposer;
+use OC\Support\CrashReport\Registry;
+use OCP\App\IAppManager;
+use OCP\AppFramework\App;
+use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\AppFramework\Bootstrap\IBootstrap;
+use OCP\AppFramework\Bootstrap\IRegistrationContext;
+use OCP\AppFramework\QueryException;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\ILogger;
+use OCP\IServerContainer;
+use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
+
+class CoordinatorTest extends TestCase {
+
+ /** @var IAppManager|MockObject */
+ private $appManager;
+
+ /** @var IServerContainer|MockObject */
+ private $serverContainer;
+
+ /** @var Registry|MockObject */
+ private $crashReporterRegistry;
+
+ /** @var IEventDispatcher|MockObject */
+ private $eventDispatcher;
+
+ /** @var SearchComposer|MockObject */
+ private $searchComposer;
+
+ /** @var ILogger|MockObject */
+ private $logger;
+
+ /** @var Coordinator */
+ private $coordinator;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->appManager = $this->createMock(IAppManager::class);
+ $this->serverContainer = $this->createMock(IServerContainer::class);
+ $this->crashReporterRegistry = $this->createMock(Registry::class);
+ $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
+ $this->searchComposer = $this->createMock(SearchComposer::class);
+ $this->logger = $this->createMock(ILogger::class);
+
+ $this->coordinator = new Coordinator(
+ $this->serverContainer,
+ $this->crashReporterRegistry,
+ $this->eventDispatcher,
+ $this->searchComposer,
+ $this->logger
+ );
+ }
+
+ public function testBootAppNotLoadable(): void {
+ $appId = 'settings';
+ $this->serverContainer->expects($this->once())
+ ->method('query')
+ ->with(\OCA\Settings\AppInfo\Application::class)
+ ->willThrowException(new QueryException(""));
+ $this->logger->expects($this->once())
+ ->method('logException');
+
+ $this->coordinator->bootApp($appId);
+ }
+
+ public function testBootAppNotBootable(): void {
+ $appId = 'settings';
+ $mockApp = $this->createMock(\OCA\Settings\AppInfo\Application::class);
+ $this->serverContainer->expects($this->once())
+ ->method('query')
+ ->with(\OCA\Settings\AppInfo\Application::class)
+ ->willReturn($mockApp);
+
+ $this->coordinator->bootApp($appId);
+ }
+
+ public function testBootApp(): void {
+ $appId = 'settings';
+ $mockApp = new class extends App implements IBootstrap {
+ public function __construct() {
+ parent::__construct('test', []);
+ }
+
+ public function register(IRegistrationContext $context): void {
+ }
+
+ public function boot(IBootContext $context): void {
+ }
+ };
+ $this->serverContainer->expects($this->once())
+ ->method('query')
+ ->with(\OCA\Settings\AppInfo\Application::class)
+ ->willReturn($mockApp);
+
+ $this->coordinator->bootApp($appId);
+ }
+}
diff --git a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
new file mode 100644
index 00000000000..8441b6e983d
--- /dev/null
+++ b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
@@ -0,0 +1,162 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @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 lib\AppFramework\Bootstrap;
+
+use OC\AppFramework\Bootstrap\RegistrationContext;
+use OCP\AppFramework\App;
+use OCP\AppFramework\IAppContainer;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\ILogger;
+use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
+
+class RegistrationContextTest extends TestCase {
+
+ /** @var ILogger|MockObject */
+ private $logger;
+
+ /** @var RegistrationContext */
+ private $context;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->logger = $this->createMock(ILogger::class);
+
+ $this->context = new RegistrationContext(
+ $this->logger
+ );
+ }
+
+ public function testRegisterCapability(): void {
+ $app = $this->createMock(App::class);
+ $name = 'abc';
+ $container = $this->createMock(IAppContainer::class);
+ $app->method('getContainer')
+ ->willReturn($container);
+ $container->expects($this->once())
+ ->method('registerCapability')
+ ->with($name);
+ $this->logger->expects($this->never())
+ ->method('logException');
+
+ $this->context->for('myapp')->registerCapability($name);
+ $this->context->delegateCapabilityRegistrations([
+ 'myapp' => $app,
+ ]);
+ }
+
+ public function testRegisterEventListener(): void {
+ $event = 'abc';
+ $service = 'def';
+ $dispatcher = $this->createMock(IEventDispatcher::class);
+ $dispatcher->expects($this->once())
+ ->method('addServiceListener')
+ ->with($event, $service, 0);
+ $this->logger->expects($this->never())
+ ->method('logException');
+
+ $this->context->for('myapp')->registerEventListener($event, $service);
+ $this->context->delegateEventListenerRegistrations($dispatcher);
+ }
+
+ public function testRegisterService(): void {
+ $app = $this->createMock(App::class);
+ $service = 'abc';
+ $factory = function () {
+ return 'def';
+ };
+ $container = $this->createMock(IAppContainer::class);
+ $app->method('getContainer')
+ ->willReturn($container);
+ $container->expects($this->once())
+ ->method('registerService')
+ ->with($service, $factory, true);
+ $this->logger->expects($this->never())
+ ->method('logException');
+
+ $this->context->for('myapp')->registerService($service, $factory);
+ $this->context->delegateContainerRegistrations([
+ 'myapp' => $app,
+ ]);
+ }
+
+ public function testRegisterServiceAlias(): void {
+ $app = $this->createMock(App::class);
+ $alias = 'abc';
+ $target = 'def';
+ $container = $this->createMock(IAppContainer::class);
+ $app->method('getContainer')
+ ->willReturn($container);
+ $container->expects($this->once())
+ ->method('registerAlias')
+ ->with($alias, $target);
+ $this->logger->expects($this->never())
+ ->method('logException');
+
+ $this->context->for('myapp')->registerServiceAlias($alias, $target);
+ $this->context->delegateContainerRegistrations([
+ 'myapp' => $app,
+ ]);
+ }
+
+ public function testRegisterParameter(): void {
+ $app = $this->createMock(App::class);
+ $name = 'abc';
+ $value = 'def';
+ $container = $this->createMock(IAppContainer::class);
+ $app->method('getContainer')
+ ->willReturn($container);
+ $container->expects($this->once())
+ ->method('registerParameter')
+ ->with($name, $value);
+ $this->logger->expects($this->never())
+ ->method('logException');
+
+ $this->context->for('myapp')->registerParameter($name, $value);
+ $this->context->delegateContainerRegistrations([
+ 'myapp' => $app,
+ ]);
+ }
+
+ public function testRegisterMiddleware(): void {
+ $app = $this->createMock(App::class);
+ $name = 'abc';
+ $container = $this->createMock(IAppContainer::class);
+ $app->method('getContainer')
+ ->willReturn($container);
+ $container->expects($this->once())
+ ->method('registerMiddleware')
+ ->with($name);
+ $this->logger->expects($this->never())
+ ->method('logException');
+
+ $this->context->for('myapp')->registerMiddleware($name);
+ $this->context->delegateMiddlewareRegistrations([
+ 'myapp' => $app,
+ ]);
+ }
+}
diff --git a/tests/lib/AppFramework/Controller/ControllerTest.php b/tests/lib/AppFramework/Controller/ControllerTest.php
index e07089e0c82..7c5b1931512 100644
--- a/tests/lib/AppFramework/Controller/ControllerTest.php
+++ b/tests/lib/AppFramework/Controller/ControllerTest.php
@@ -92,7 +92,7 @@ class ControllerTest extends \Test\TestCase {
$this->controller = new ChildController($this->app, $request);
}
-
+
public function testFormatResonseInvalidFormat() {
$this->expectException(\DomainException::class);
@@ -114,6 +114,7 @@ class ControllerTest extends \Test\TestCase {
'Content-Type' => 'application/json; charset=utf-8',
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'",
'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'",
+ 'X-Robots-Tag' => 'none',
];
$response = $this->controller->customDataResponse(['hi']);
diff --git a/tests/lib/AppFramework/Http/DataResponseTest.php b/tests/lib/AppFramework/Http/DataResponseTest.php
index e7624c92d7e..a02cee67d31 100644
--- a/tests/lib/AppFramework/Http/DataResponseTest.php
+++ b/tests/lib/AppFramework/Http/DataResponseTest.php
@@ -67,6 +67,7 @@ class DataResponseTest extends \Test\TestCase {
'Cache-Control' => 'no-cache, no-store, must-revalidate',
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'",
'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'",
+ 'X-Robots-Tag' => 'none',
];
$expectedHeaders = array_merge($expectedHeaders, $headers);
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php
index a8e2f2248c6..7260b31b27e 100644
--- a/tests/lib/AppFramework/Http/RequestTest.php
+++ b/tests/lib/AppFramework/Http/RequestTest.php
@@ -632,6 +632,34 @@ class RequestTest extends \Test\TestCase {
$this->assertSame('192.168.3.99', $request->getRemoteAddress());
}
+ public function testGetRemoteAddressWithXForwardedForIPv6() {
+ $this->config
+ ->expects($this->at(0))
+ ->method('getSystemValue')
+ ->with('trusted_proxies')
+ ->willReturn(['192.168.2.0/24']);
+ $this->config
+ ->expects($this->at(1))
+ ->method('getSystemValue')
+ ->with('forwarded_for_headers')
+ ->willReturn(['HTTP_X_FORWARDED_FOR']);
+
+ $request = new Request(
+ [
+ 'server' => [
+ 'REMOTE_ADDR' => '192.168.2.99',
+ 'HTTP_X_FORWARDED_FOR' => '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
+ ],
+ ],
+ $this->secureRandom,
+ $this->config,
+ $this->csrfTokenManager,
+ $this->stream
+ );
+
+ $this->assertSame('2001:db8:85a3:8d3:1319:8a2e:370:7348', $request->getRemoteAddress());
+ }
+
/**
* @return array
*/
diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php
index f33d0a0089d..7a064908869 100644
--- a/tests/lib/AppFramework/Http/ResponseTest.php
+++ b/tests/lib/AppFramework/Http/ResponseTest.php
@@ -51,7 +51,8 @@ class ResponseTest extends \Test\TestCase {
$expected = [
'Last-Modified' => 1,
'ETag' => 3,
- 'Something-Else' => 'hi'
+ 'Something-Else' => 'hi',
+ 'X-Robots-Tag' => 'none',
];
$this->childResponse->setHeaders($expected);
@@ -90,7 +91,7 @@ class ResponseTest extends \Test\TestCase {
public function testAddHeaderValueNullDeletesIt() {
$this->childResponse->addHeader('hello', 'world');
$this->childResponse->addHeader('hello', null);
- $this->assertEquals(3, count($this->childResponse->getHeaders()));
+ $this->assertEquals(4, count($this->childResponse->getHeaders()));
}
@@ -108,10 +109,12 @@ class ResponseTest extends \Test\TestCase {
'foo' => [
'value' => 'bar',
'expireDate' => null,
+ 'sameSite' => 'Lax',
],
'bar' => [
'value' => 'foo',
- 'expireDate' => new \DateTime('1970-01-01')
+ 'expireDate' => new \DateTime('1970-01-01'),
+ 'sameSite' => 'Lax',
]
];
$this->assertEquals($expectedResponse, $this->childResponse->getCookies());
@@ -143,7 +146,8 @@ class ResponseTest extends \Test\TestCase {
$expected = [
'foo' => [
'value' => 'expired',
- 'expireDate' => new \DateTime('1971-01-01')
+ 'expireDate' => new \DateTime('1971-01-01'),
+ 'sameSite' => 'Lax',
]
];
@@ -159,11 +163,13 @@ class ResponseTest extends \Test\TestCase {
$expected = [
'foo' => [
'value' => 'bar',
- 'expireDate' => null
+ 'expireDate' => null,
+ 'sameSite' => 'Lax',
],
'bar' => [
'value' => 'foo',
- 'expireDate' => null
+ 'expireDate' => null,
+ 'sameSite' => 'Lax',
]
];
$cookies = $this->childResponse->getCookies();
@@ -173,11 +179,13 @@ class ResponseTest extends \Test\TestCase {
$expected = [
'foo' => [
'value' => 'expired',
- 'expireDate' => new \DateTime('1971-01-01')
+ 'expireDate' => new \DateTime('1971-01-01'),
+ 'sameSite' => 'Lax',
],
'bar' => [
'value' => 'expired',
- 'expireDate' => new \DateTime('1971-01-01')
+ 'expireDate' => new \DateTime('1971-01-01'),
+ 'sameSite' => 'Lax',
]
];
@@ -229,15 +237,15 @@ class ResponseTest extends \Test\TestCase {
public function testCacheSeconds() {
$time = $this->createMock(ITimeFactory::class);
$time->method('getTime')
- ->willReturn('1234567');
+ ->willReturn(1234567);
$this->overwriteService(ITimeFactory::class, $time);
$this->childResponse->cacheFor(33);
$headers = $this->childResponse->getHeaders();
- $this->assertEquals('max-age=33, must-revalidate', $headers['Cache-Control']);
- $this->assertEquals('public', $headers['Pragma']);
+ $this->assertEquals('private, max-age=33, must-revalidate', $headers['Cache-Control']);
+ $this->assertEquals('private', $headers['Pragma']);
$this->assertEquals('Thu, 15 Jan 1970 06:56:40 +0000', $headers['Expires']);
}
diff --git a/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php b/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php
new file mode 100644
index 00000000000..672a044ce01
--- /dev/null
+++ b/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php
@@ -0,0 +1,117 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @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 Test\Authentication\Listeners;
+
+use Exception;
+use OC\Authentication\Listeners\UserDeletedTokenCleanupListener;
+use OC\Authentication\Token\IToken;
+use OC\Authentication\Token\Manager;
+use OCP\EventDispatcher\Event;
+use OCP\ILogger;
+use OCP\IUser;
+use OCP\User\Events\UserDeletedEvent;
+use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
+
+class UserDeletedTokenCleanupListenerTest extends TestCase {
+
+
+ /** @var Manager|MockObject */
+ private $manager;
+
+ /** @var ILogger|MockObject */
+ private $logger;
+
+ /** @var UserDeletedTokenCleanupListener */
+ private $listener;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->manager = $this->createMock(Manager::class);
+ $this->logger = $this->createMock(ILogger::class);
+
+ $this->listener = new UserDeletedTokenCleanupListener(
+ $this->manager,
+ $this->logger
+ );
+ }
+
+ public function testHandleUnrelated(): void {
+ $event = new Event();
+ $this->manager->expects($this->never())->method('getTokenByUser');
+ $this->logger->expects($this->never())->method('logException');
+
+ $this->listener->handle($event);
+ }
+
+ public function testHandleWithErrors(): void {
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')->willReturn('user123');
+ $event = new UserDeletedEvent($user);
+ $exception = new Exception('nope');
+ $this->manager->expects($this->once())
+ ->method('getTokenByUser')
+ ->with('user123')
+ ->willThrowException($exception);
+ $this->logger->expects($this->once())
+ ->method('logException')
+ ->with($exception, $this->anything());
+
+ $this->listener->handle($event);
+ }
+
+ public function testHandle(): void {
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')->willReturn('user123');
+ $event = new UserDeletedEvent($user);
+ $token1 = $this->createMock(IToken::class);
+ $token1->method('getId')->willReturn(1);
+ $token2 = $this->createMock(IToken::class);
+ $token2->method('getId')->willReturn(2);
+ $token3 = $this->createMock(IToken::class);
+ $token3->method('getId')->willReturn(3);
+ $this->manager->expects($this->once())
+ ->method('getTokenByUser')
+ ->with('user123')
+ ->willReturn([
+ $token1,
+ $token2,
+ $token3,
+ ]);
+ $this->manager->expects($this->exactly(3))
+ ->method('invalidateTokenById')
+ ->withConsecutive(
+ ['user123', 1],
+ ['user123', 2],
+ ['user123', 3]
+ );
+ $this->logger->expects($this->never())
+ ->method('logException');
+
+ $this->listener->handle($event);
+ }
+}
diff --git a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
index 909a11596a3..3f9e0900d15 100644
--- a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
@@ -31,7 +31,7 @@ use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class GroupPluginTest extends TestCase {
@@ -135,7 +135,7 @@ class GroupPluginTest extends TestCase {
[$this->getGroupMock('test1')],
[],
[],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
true,
false,
],
@@ -145,7 +145,7 @@ class GroupPluginTest extends TestCase {
[$this->getGroupMock('test1', 'Test One')],
[],
[],
- [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
true,
false,
],
@@ -155,7 +155,7 @@ class GroupPluginTest extends TestCase {
[$this->getGroupMock('test1', 'Test One')],
[],
[],
- [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
true,
false,
],
@@ -164,7 +164,7 @@ class GroupPluginTest extends TestCase {
'Test One', false, true,
[$this->getGroupMock('test1', 'Test One')],
[],
- [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
[],
true,
false,
@@ -185,8 +185,8 @@ class GroupPluginTest extends TestCase {
$this->getGroupMock('test1'),
],
[],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
false,
false,
],
@@ -197,7 +197,7 @@ class GroupPluginTest extends TestCase {
$this->getGroupMock('test1'),
],
[],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
[],
true,
false,
@@ -211,8 +211,8 @@ class GroupPluginTest extends TestCase {
[],
[],
[
- ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']],
- ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']],
+ ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']],
+ ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']],
],
false,
null,
@@ -237,11 +237,11 @@ class GroupPluginTest extends TestCase {
],
[],
[
- ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']],
],
[
- ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']],
- ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']],
+ ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']],
+ ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']],
],
false,
$this->getGroupMock('test'),
@@ -254,7 +254,7 @@ class GroupPluginTest extends TestCase {
],
[],
[
- ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']],
],
[],
true,
@@ -270,7 +270,7 @@ class GroupPluginTest extends TestCase {
],
[$this->getGroupMock('test1')],
[],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
false,
false,
],
@@ -293,7 +293,7 @@ class GroupPluginTest extends TestCase {
$this->getGroupMock('test1'),
],
[$this->getGroupMock('test')],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
[],
false,
false,
@@ -305,7 +305,7 @@ class GroupPluginTest extends TestCase {
$this->getGroupMock('test1'),
],
[$this->getGroupMock('test')],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
[],
true,
false,
@@ -318,7 +318,7 @@ class GroupPluginTest extends TestCase {
],
[$this->getGroupMock('test1')],
[],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
false,
false,
],
@@ -341,8 +341,8 @@ class GroupPluginTest extends TestCase {
$this->getGroupMock('test1'),
],
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
false,
false,
],
@@ -353,7 +353,7 @@ class GroupPluginTest extends TestCase {
$this->getGroupMock('test1'),
],
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
[],
true,
false,
@@ -367,8 +367,8 @@ class GroupPluginTest extends TestCase {
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
[],
[
- ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']],
- ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']],
+ ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']],
+ ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']],
],
false,
null,
@@ -393,11 +393,11 @@ class GroupPluginTest extends TestCase {
],
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
[
- ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']],
],
[
- ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']],
- ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']],
+ ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']],
+ ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']],
],
false,
$this->getGroupMock('test'),
@@ -410,7 +410,7 @@ class GroupPluginTest extends TestCase {
],
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
[
- ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']],
],
[],
true,
diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
index eb26443a269..383dd0c39a2 100644
--- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
@@ -36,7 +36,7 @@ use OCP\IConfig;
use OCP\ILogger;
use OCP\IUser;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class LookupPluginTest extends TestCase {
@@ -301,7 +301,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
@@ -309,7 +309,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
@@ -317,7 +317,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
@@ -340,7 +340,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
@@ -348,7 +348,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
@@ -356,7 +356,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
@@ -379,7 +379,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
@@ -387,7 +387,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
@@ -395,7 +395,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
@@ -418,7 +418,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
@@ -426,7 +426,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
@@ -434,7 +434,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
@@ -469,7 +469,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
@@ -477,7 +477,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
@@ -485,7 +485,7 @@ class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index 613208d27b1..6e859b55358 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -33,7 +33,7 @@ use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class MailPluginTest extends TestCase {
@@ -126,7 +126,7 @@ class MailPluginTest extends TestCase {
'test@remote.com',
[],
true,
- ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
false,
],
@@ -144,7 +144,7 @@ class MailPluginTest extends TestCase {
'test@remote.com',
[],
false,
- ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
false,
],
@@ -171,7 +171,7 @@ class MailPluginTest extends TestCase {
],
],
true,
- ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]],
+ ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]],
false,
false,
],
@@ -225,7 +225,7 @@ class MailPluginTest extends TestCase {
],
],
true,
- ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
+ ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
false,
],
@@ -252,7 +252,7 @@ class MailPluginTest extends TestCase {
],
],
false,
- ['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
false,
],
@@ -279,7 +279,7 @@ class MailPluginTest extends TestCase {
],
],
true,
- ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
true,
false,
],
@@ -306,7 +306,7 @@ class MailPluginTest extends TestCase {
],
],
false,
- ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
true,
false,
],
@@ -334,7 +334,7 @@ class MailPluginTest extends TestCase {
],
],
false,
- ['emails' => [], 'exact' => ['emails' => [['name' => 'User Name @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'user name@localhost']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['name' => 'User Name @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'user name@localhost']]]]],
true,
false,
],
@@ -380,7 +380,7 @@ class MailPluginTest extends TestCase {
]
],
false,
- ['users' => [], 'exact' => ['users' => [['uuid' => 'uid1', 'name' => 'User', 'label' => 'User (test@example.com)','value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test'],]]]],
+ ['users' => [], 'exact' => ['users' => [['uuid' => 'uid1', 'name' => 'User', 'label' => 'User (test@example.com)','value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test'],]]]],
true,
false,
],
@@ -438,8 +438,8 @@ class MailPluginTest extends TestCase {
],
true,
['users' => [
- ['uuid' => 'uid1', 'name' => 'User1', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['uuid' => 'uid2', 'name' => 'User2', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['uuid' => 'uid1', 'name' => 'User1', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['uuid' => 'uid2', 'name' => 'User2', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
], 'emails' => [], 'exact' => ['users' => [], 'emails' => []]],
false,
true,
@@ -476,8 +476,8 @@ class MailPluginTest extends TestCase {
],
true,
['emails' => [
- ['uuid' => 'uid1', 'name' => 'User1', 'type' => '', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.com']],
- ['uuid' => 'uid2', 'name' => 'User2', 'type' => '', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.de']],
+ ['uuid' => 'uid1', 'name' => 'User1', 'type' => '', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@example.com']],
+ ['uuid' => 'uid2', 'name' => 'User2', 'type' => '', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@example.de']],
], 'exact' => ['emails' => []]],
false,
true,
@@ -509,8 +509,8 @@ class MailPluginTest extends TestCase {
false,
['emails' => [
], 'exact' => ['emails' => [
- ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'HOME', 'label' => 'User Name (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']],
- ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'WORK', 'label' => 'User Name (username@other)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@other']]
+ ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'HOME', 'label' => 'User Name (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']],
+ ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'WORK', 'label' => 'User Name (username@other)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@other']]
]]],
false,
false,
diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
index a651d4ec1d4..531a8447bd2 100644
--- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
@@ -33,7 +33,7 @@ use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class RemotePluginTest extends TestCase {
@@ -150,7 +150,7 @@ class RemotePluginTest extends TestCase {
'test@remote',
[],
true,
- ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
false,
true,
],
@@ -158,7 +158,7 @@ class RemotePluginTest extends TestCase {
'test@remote',
[],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
false,
true,
],
@@ -184,7 +184,7 @@ class RemotePluginTest extends TestCase {
],
],
true,
- ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => []]],
+ ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => []]],
false,
true,
],
@@ -236,7 +236,7 @@ class RemotePluginTest extends TestCase {
],
],
true,
- ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
+ ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
false,
true,
],
@@ -262,7 +262,7 @@ class RemotePluginTest extends TestCase {
],
],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
false,
true,
],
@@ -288,7 +288,7 @@ class RemotePluginTest extends TestCase {
],
],
true,
- ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]],
true,
true,
],
@@ -314,7 +314,7 @@ class RemotePluginTest extends TestCase {
],
],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]],
true,
true,
],
@@ -341,7 +341,7 @@ class RemotePluginTest extends TestCase {
],
],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User Name @ Localhost', 'label' => 'User Name @ Localhost (user name@localhost)', 'uuid' => 'uid3', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user name@localhost', 'server' => 'localhost']]]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User Name @ Localhost', 'label' => 'User Name @ Localhost (user name@localhost)', 'uuid' => 'uid3', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'user name@localhost', 'server' => 'localhost']]]]],
true,
true,
],
@@ -368,7 +368,7 @@ class RemotePluginTest extends TestCase {
],
],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user space@remote', 'server' => 'remote'], 'uuid' => 'user space', 'name' => 'user space']]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'user space@remote', 'server' => 'remote'], 'uuid' => 'user space', 'name' => 'user space']]]],
false,
true,
],
diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php
index 1b68e8eacc1..ab731c05c21 100644
--- a/tests/lib/Collaboration/Collaborators/SearchTest.php
+++ b/tests/lib/Collaboration/Collaborators/SearchTest.php
@@ -29,7 +29,7 @@ use OCP\Collaboration\Collaborators\ISearch;
use OCP\Collaboration\Collaborators\ISearchPlugin;
use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\IContainer;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class SearchTest extends TestCase {
@@ -132,7 +132,7 @@ class SearchTest extends TestCase {
public function dataSearchSharees() {
return [
[
- 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
+ 'test', [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => []],
'users' => [],
@@ -141,7 +141,7 @@ class SearchTest extends TestCase {
], false
],
[
- 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
+ 'test', [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => []],
'users' => [],
@@ -150,66 +150,66 @@ class SearchTest extends TestCase {
], false
],
[
- 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ 'test', [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE], 1, 2, [
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
], [
- ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']],
+ ['label' => 'testgroup1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'testgroup1']],
], [
- 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false,
+ 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false,
],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => []],
'users' => [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
'groups' => [
- ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']],
+ ['label' => 'testgroup1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'testgroup1']],
],
'remotes' => [
- ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
+ ['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']],
],
], true,
],
// No groups requested
[
- 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_REMOTE], 1, 2, [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ 'test', [IShare::TYPE_USER, IShare::TYPE_REMOTE], 1, 2, [
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
], [], [
- 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false
+ 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false
],
[
'exact' => ['users' => [], 'remotes' => []],
'users' => [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
'remotes' => [
- ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
+ ['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']],
],
], false,
],
// Share type restricted to user - Only one user
[
- 'test', [Share::SHARE_TYPE_USER], 1, 2, [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ 'test', [IShare::TYPE_USER], 1, 2, [
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
], [], [],
[
'exact' => ['users' => []],
'users' => [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
], false,
],
// Share type restricted to user - Multipage result
[
- 'test', [Share::SHARE_TYPE_USER], 1, 2, [
- ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ 'test', [IShare::TYPE_USER], 1, 2, [
+ ['label' => 'test 1', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test 2', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
], [], [],
[
'exact' => ['users' => []],
'users' => [
- ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'test 1', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test 2', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
], true,
],
diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
index 07bcce93529..8ca612f6069 100644
--- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
@@ -32,7 +32,7 @@ use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class UserPluginTest extends TestCase {
@@ -144,13 +144,13 @@ class UserPluginTest extends TestCase {
[
'test', false, true, [], [],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test'),
],
[
'test', false, false, [], [],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test'),
],
[
@@ -164,13 +164,13 @@ class UserPluginTest extends TestCase {
[
'test', true, true, ['test-group'], [['test-group', 'test', 2, 0, []]],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test'),
],
[
'test', true, false, ['test-group'], [['test-group', 'test', 2, 0, []]],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test'),
],
[
@@ -183,7 +183,7 @@ class UserPluginTest extends TestCase {
],
[],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
true,
false,
@@ -212,8 +212,8 @@ class UserPluginTest extends TestCase {
],
[],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
@@ -243,11 +243,11 @@ class UserPluginTest extends TestCase {
$this->getUserMock('test2', 'Test Two'),
],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test0']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test0']],
],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
@@ -263,7 +263,7 @@ class UserPluginTest extends TestCase {
$this->getUserMock('test2', 'Test Two'),
],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test0']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test0']],
],
[],
true,
@@ -275,15 +275,16 @@ class UserPluginTest extends TestCase {
true,
['abc', 'xyz'],
[
- ['abc', 'test', 2, 0, [$this->getUserMock('test1', 'Test One')]],
+ ['abc', 'test', 2, 0, ['test1' => 'Test One']],
['xyz', 'test', 2, 0, []],
],
[],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
true,
false,
+ [['test1', $this->getUserMock('test1', 'Test One')]],
],
[
'test',
@@ -291,13 +292,14 @@ class UserPluginTest extends TestCase {
false,
['abc', 'xyz'],
[
- ['abc', 'test', 2, 0, [$this->getUserMock('test1', 'Test One')]],
+ ['abc', 'test', 2, 0, ['test1' => 'Test One']],
['xyz', 'test', 2, 0, []],
],
[],
[],
true,
false,
+ [['test1', $this->getUserMock('test1', 'Test One')]],
],
[
'test',
@@ -306,21 +308,25 @@ class UserPluginTest extends TestCase {
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
- $this->getUserMock('test1', 'Test One'),
- $this->getUserMock('test2', 'Test Two'),
+ 'test1' => 'Test One',
+ 'test2' => 'Test Two',
]],
['xyz', 'test', 2, 0, [
- $this->getUserMock('test1', 'Test One'),
- $this->getUserMock('test2', 'Test Two'),
+ 'test1' => 'Test One',
+ 'test2' => 'Test Two',
]],
],
[],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
+ [
+ ['test1', $this->getUserMock('test1', 'Test One')],
+ ['test2', $this->getUserMock('test2', 'Test Two')],
+ ],
],
[
'test',
@@ -329,18 +335,22 @@ class UserPluginTest extends TestCase {
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
- $this->getUserMock('test1', 'Test One'),
- $this->getUserMock('test2', 'Test Two'),
+ 'test1' => 'Test One',
+ 'test2' => 'Test Two',
]],
['xyz', 'test', 2, 0, [
- $this->getUserMock('test1', 'Test One'),
- $this->getUserMock('test2', 'Test Two'),
+ 'test1' => 'Test One',
+ 'test2' => 'Test Two',
]],
],
[],
[],
true,
false,
+ [
+ ['test1', $this->getUserMock('test1', 'Test One')],
+ ['test2', $this->getUserMock('test2', 'Test Two')],
+ ],
],
[
'test',
@@ -349,20 +359,24 @@ class UserPluginTest extends TestCase {
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
- $this->getUserMock('test', 'Test One'),
+ 'test' => 'Test One',
]],
['xyz', 'test', 2, 0, [
- $this->getUserMock('test2', 'Test Two'),
+ 'test2' => 'Test Two',
]],
],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
],
[
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
+ [
+ ['test', $this->getUserMock('test', 'Test One')],
+ ['test2', $this->getUserMock('test2', 'Test Two')],
+ ],
],
[
'test',
@@ -371,18 +385,22 @@ class UserPluginTest extends TestCase {
['abc', 'xyz'],
[
['abc', 'test', 2, 0, [
- $this->getUserMock('test', 'Test One'),
+ 'test' => 'Test One',
]],
['xyz', 'test', 2, 0, [
- $this->getUserMock('test2', 'Test Two'),
+ 'test2' => 'Test Two',
]],
],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
],
[],
true,
false,
+ [
+ ['test', $this->getUserMock('test', 'Test One')],
+ ['test2', $this->getUserMock('test2', 'Test Two')],
+ ],
],
];
}
@@ -399,6 +417,7 @@ class UserPluginTest extends TestCase {
* @param array $expected
* @param bool $reachedEnd
* @param bool|IUser $singleUser
+ * @param array $users
*/
public function testSearch(
$searchTerm,
@@ -409,7 +428,8 @@ class UserPluginTest extends TestCase {
array $exactExpected,
array $expected,
$reachedEnd,
- $singleUser
+ $singleUser,
+ array $users = []
) {
$this->mockConfig($shareWithGroupOnly, $shareeEnumeration, false);
$this->instantiatePlugin();
@@ -424,39 +444,29 @@ class UserPluginTest extends TestCase {
->with($searchTerm, $this->limit, $this->offset)
->willReturn($userResponse);
} else {
- $groups = array_combine($groupResponse, array_map(function ($gid) {
- return $this->getGroupMock($gid);
- }, $groupResponse));
- if ($singleUser !== false) {
- $this->groupManager->method('getUserGroups')
- ->with($this->user)
- ->willReturn($groups);
+ $this->groupManager->method('getUserGroupIds')
+ ->with($this->user)
+ ->willReturn($groupResponse);
+ if ($singleUser !== false) {
$this->groupManager->method('getUserGroupIds')
->with($singleUser)
->willReturn($groupResponse);
- } else {
- $this->groupManager->expects($this->once())
- ->method('getUserGroups')
- ->with($this->user)
- ->willReturn($groups);
}
- foreach ($userResponse as $groupDefinition) {
- [$gid, $search, $limit, $offset, $users] = $groupDefinition;
- $groups[$gid]->method('searchDisplayName')
- ->with($search, $limit, $offset)
- ->willReturn($users);
- }
+ $this->groupManager->method('displayNamesInGroup')
+ ->willReturnMap($userResponse);
}
if ($singleUser !== false) {
- $this->userManager->expects($this->once())
- ->method('get')
- ->with($searchTerm)
- ->willReturn($singleUser);
+ $users[] = [$searchTerm, $singleUser];
}
+ if (!empty($users)) {
+ $this->userManager->expects($this->atLeastOnce())
+ ->method('get')
+ ->willReturnMap($users);
+ }
$moreResults = $this->plugin->search($searchTerm, $this->limit, $this->offset, $this->searchResult);
$result = $this->searchResult->asArray();
@@ -522,7 +532,16 @@ class UserPluginTest extends TestCase {
['uid' => 'test1', 'groups' => ['groupA']],
['uid' => 'test2', 'groups' => ['groupB']],
],
- ['test1'],
+ ['exact' => [], 'wide' => ['test1']],
+ ],
+ [
+ 'test1',
+ ['groupA'],
+ [
+ ['uid' => 'test1', 'groups' => ['groupA']],
+ ['uid' => 'test2', 'groups' => ['groupB']],
+ ],
+ ['exact' => ['test1'], 'wide' => []],
],
[
'test',
@@ -531,7 +550,7 @@ class UserPluginTest extends TestCase {
['uid' => 'test1', 'groups' => ['groupA']],
['uid' => 'test2', 'groups' => ['groupB', 'groupA']],
],
- ['test1', 'test2'],
+ ['exact' => [], 'wide' => ['test1', 'test2']],
],
[
'test',
@@ -540,7 +559,7 @@ class UserPluginTest extends TestCase {
['uid' => 'test1', 'groups' => ['groupA', 'groupC']],
['uid' => 'test2', 'groups' => ['groupB', 'groupA']],
],
- ['test1', 'test2'],
+ ['exact' => [], 'wide' => ['test1', 'test2']],
],
[
'test',
@@ -549,7 +568,7 @@ class UserPluginTest extends TestCase {
['uid' => 'test1', 'groups' => ['groupA', 'groupC']],
['uid' => 'test2', 'groups' => ['groupB', 'groupA']],
],
- ['test1', 'test2'],
+ ['exact' => [], 'wide' => ['test1', 'test2']],
],
[
'test',
@@ -558,7 +577,7 @@ class UserPluginTest extends TestCase {
['uid' => 'test1', 'groups' => ['groupA']],
['uid' => 'test2', 'groups' => ['groupB', 'groupA']],
],
- [],
+ ['exact' => [], 'wide' => []],
],
[
'test',
@@ -567,7 +586,16 @@ class UserPluginTest extends TestCase {
['uid' => 'test1', 'groups' => []],
['uid' => 'test2', 'groups' => []],
],
- [],
+ ['exact' => [], 'wide' => []],
+ ],
+ [
+ 'test',
+ ['groupC', 'groupB'],
+ [
+ ['uid' => 'test1', 'groups' => []],
+ ['uid' => 'test2', 'groups' => []],
+ ],
+ ['exact' => [], 'wide' => []],
],
];
}
@@ -582,9 +610,12 @@ class UserPluginTest extends TestCase {
return $this->getUserMock($user['uid'], $user['uid']);
}, $matchingUsers);
- $mappedResult = array_map(function ($user) {
+ $mappedResultExact = array_map(function ($user) {
+ return ['label' => $user, 'value' => ['shareType' => 0, 'shareWith' => $user]];
+ }, $result['exact']);
+ $mappedResultWide = array_map(function ($user) {
return ['label' => $user, 'value' => ['shareType' => 0, 'shareWith' => $user]];
- }, $result);
+ }, $result['wide']);
$this->userManager->expects($this->once())
->method('searchDisplayName')
@@ -615,7 +646,7 @@ class UserPluginTest extends TestCase {
$this->plugin->search($search, $this->limit, $this->offset, $this->searchResult);
$result = $this->searchResult->asArray();
- $this->assertEquals([], $result['exact']['users']);
- $this->assertEquals($mappedResult, $result['users']);
+ $this->assertEquals($mappedResultExact, $result['exact']['users']);
+ $this->assertEquals($mappedResultWide, $result['users']);
}
}
diff --git a/tests/lib/Command/Integrity/SignAppTest.php b/tests/lib/Command/Integrity/SignAppTest.php
index 594d17168d6..6802542914f 100644
--- a/tests/lib/Command/Integrity/SignAppTest.php
+++ b/tests/lib/Command/Integrity/SignAppTest.php
@@ -76,7 +76,7 @@ class SignAppTest extends TestCase {
->method('writeln')
->with('This command requires the --path, --privateKey and --certificate.');
- $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
+ $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
public function testExecuteWithMissingPrivateKey() {
@@ -104,7 +104,7 @@ class SignAppTest extends TestCase {
->method('writeln')
->with('This command requires the --path, --privateKey and --certificate.');
- $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
+ $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
public function testExecuteWithMissingCertificate() {
@@ -132,7 +132,7 @@ class SignAppTest extends TestCase {
->method('writeln')
->with('This command requires the --path, --privateKey and --certificate.');
- $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
+ $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
public function testExecuteWithNotExistingPrivateKey() {
@@ -166,7 +166,7 @@ class SignAppTest extends TestCase {
->method('writeln')
->with('Private key "privateKey" does not exists.');
- $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
+ $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
public function testExecuteWithNotExistingCertificate() {
@@ -205,7 +205,7 @@ class SignAppTest extends TestCase {
->method('writeln')
->with('Certificate "certificate" does not exists.');
- $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
+ $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
public function testExecuteWithException() {
diff --git a/tests/lib/Command/Integrity/SignCoreTest.php b/tests/lib/Command/Integrity/SignCoreTest.php
index 36376ef0e7d..27e4f66c242 100644
--- a/tests/lib/Command/Integrity/SignCoreTest.php
+++ b/tests/lib/Command/Integrity/SignCoreTest.php
@@ -66,7 +66,7 @@ class SignCoreTest extends TestCase {
->method('writeln')
->with('--privateKey, --certificate and --path are required.');
- $this->assertNull(self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
+ $this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
public function testExecuteWithMissingCertificate() {
@@ -89,7 +89,7 @@ class SignCoreTest extends TestCase {
->method('writeln')
->with('--privateKey, --certificate and --path are required.');
- $this->assertNull(self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
+ $this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
public function testExecuteWithNotExistingPrivateKey() {
@@ -123,7 +123,7 @@ class SignCoreTest extends TestCase {
->method('writeln')
->with('Private key "privateKey" does not exists.');
- $this->assertNull(self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
+ $this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
public function testExecuteWithNotExistingCertificate() {
@@ -162,7 +162,7 @@ class SignCoreTest extends TestCase {
->method('writeln')
->with('Certificate "certificate" does not exists.');
- $this->assertNull(self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
+ $this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
public function testExecuteWithException() {
diff --git a/tests/lib/DB/OCPostgreSqlPlatformTest.php b/tests/lib/DB/OCPostgreSqlPlatformTest.php
index 0821a988eb5..62a2fc34712 100644
--- a/tests/lib/DB/OCPostgreSqlPlatformTest.php
+++ b/tests/lib/DB/OCPostgreSqlPlatformTest.php
@@ -24,7 +24,7 @@ namespace Test\DB;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Schema;
-use Doctrine\DBAL\Types\Type;
+use Doctrine\DBAL\Types\Types;
/**
* Class OCPostgreSqlPlatformTest
@@ -42,8 +42,8 @@ class OCPostgreSqlPlatformTest extends \Test\TestCase {
$sourceSchema = new Schema();
$targetSchema = new Schema();
- $this->createTableAndColumn($sourceSchema, Type::INTEGER);
- $this->createTableAndColumn($targetSchema, Type::BIGINT);
+ $this->createTableAndColumn($sourceSchema, Types::INTEGER);
+ $this->createTableAndColumn($targetSchema, Types::BIGINT);
$comparator = new Comparator();
$diff = $comparator->compare($sourceSchema, $targetSchema);
diff --git a/tests/lib/DB/schemDiffData/core.xml b/tests/lib/DB/schemDiffData/core.xml
index 3775eb6cb37..d7edc7dc73e 100644
--- a/tests/lib/DB/schemDiffData/core.xml
+++ b/tests/lib/DB/schemDiffData/core.xml
@@ -526,7 +526,7 @@
<length>4</length>
</field>
- <!-- Constant OCP\Share::SHARE_TYPE_* -->
+ <!-- Constant OCP\Share\IShare::TYPE_* -->
<field>
<name>share_type</name>
<type>integer</type>
diff --git a/tests/lib/Files/Node/HookConnectorTest.php b/tests/lib/Files/Node/HookConnectorTest.php
index 004b74e755c..a5e73f18365 100644
--- a/tests/lib/Files/Node/HookConnectorTest.php
+++ b/tests/lib/Files/Node/HookConnectorTest.php
@@ -13,7 +13,6 @@ use OC\Files\Node\HookConnector;
use OC\Files\Node\Root;
use OC\Files\Storage\Temporary;
use OC\Files\View;
-use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\GenericEvent as APIGenericEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\Node\AbstractNodeEvent;
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 9dbe2a4e10e..036fc038a60 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -21,7 +21,7 @@ use OCP\Files\FileInfo;
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
-use OCP\Share;
+use OCP\Share\IShare;
use OCP\Util;
use Test\HookHelper;
use Test\TestMoveableMountPoint;
@@ -243,7 +243,7 @@ class ViewTest extends \Test\TestCase {
$this->assertEquals('/foo.txt', $folderView->getPath($id2));
}
-
+
public function testGetPathNotExisting() {
$this->expectException(\OCP\Files\NotFoundException::class);
@@ -1290,7 +1290,7 @@ class ViewTest extends \Test\TestCase {
$this->assertNull($view->getRelativePath(null));
}
-
+
public function testNullAsRoot() {
$this->expectException(\InvalidArgumentException::class);
@@ -1678,7 +1678,7 @@ class ViewTest extends \Test\TestCase {
$share = $shareManager->newShare();
$share->setSharedWith('test2')
->setSharedBy($this->user)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($shareDir);
$shareManager->createShare($share);
@@ -1687,7 +1687,7 @@ class ViewTest extends \Test\TestCase {
$this->assertFalse($view->rename('mount1', 'shareddir/sub'), 'Cannot move mount point into shared folder');
$this->assertFalse($view->rename('mount1', 'shareddir/sub/sub2'), 'Cannot move mount point into shared subfolder');
- $this->assertTrue(\OC\Share\Share::unshare('folder', $fileId, Share::SHARE_TYPE_USER, 'test2'));
+ $this->assertTrue(\OC\Share\Share::unshare('folder', $fileId, IShare::TYPE_USER, 'test2'));
$userObject->delete();
}
diff --git a/tests/lib/Repair/OldGroupMembershipSharesTest.php b/tests/lib/Repair/OldGroupMembershipSharesTest.php
index 331a86d01d0..dda23e8d3ab 100644
--- a/tests/lib/Repair/OldGroupMembershipSharesTest.php
+++ b/tests/lib/Repair/OldGroupMembershipSharesTest.php
@@ -9,8 +9,8 @@
namespace Test\Repair;
use OC\Repair\OldGroupMembershipShares;
-use OC\Share\Constants;
use OCP\Migration\IOutput;
+use OCP\Share\IShare;
/**
* Class OldGroupMembershipSharesTest
@@ -66,9 +66,9 @@ class OldGroupMembershipSharesTest extends \Test\TestCase {
['not-a-member', 'group', false],
]);
- $parent = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group', null);
- $group2 = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group2', $parent);
- $user1 = $this->createShare(Constants::SHARE_TYPE_USER, 'user1', $parent);
+ $parent = $this->createShare(IShare::TYPE_GROUP, 'group', null);
+ $group2 = $this->createShare(IShare::TYPE_GROUP, 'group2', $parent);
+ $user1 = $this->createShare(IShare::TYPE_USER, 'user1', $parent);
// \OC\Share\Constant::$shareTypeGroupUserUnique === 2
$member = $this->createShare(2, 'member', $parent);
diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php
index 23e6b2dad5f..748ca7a6048 100644
--- a/tests/lib/Repair/RepairInvalidSharesTest.php
+++ b/tests/lib/Repair/RepairInvalidSharesTest.php
@@ -9,10 +9,10 @@
namespace Test\Repair;
use OC\Repair\RepairInvalidShares;
-use OC\Share\Constants;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
+use OCP\Share\IShare;
use Test\TestCase;
/**
@@ -65,7 +65,7 @@ class RepairInvalidSharesTest extends TestCase {
public function testSharesNonExistingParent() {
$qb = $this->connection->getQueryBuilder();
$shareValues = [
- 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('recipientuser1'),
'uid_owner' => $qb->expr()->literal('user1'),
'item_type' => $qb->expr()->literal('folder'),
@@ -159,7 +159,7 @@ class RepairInvalidSharesTest extends TestCase {
$qb = $this->connection->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'uid_owner' => $qb->expr()->literal('user1'),
'item_type' => $qb->expr()->literal($itemType),
'item_source' => $qb->expr()->literal(123),
diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php
index fce963ec43a..85cb188cbb3 100644
--- a/tests/lib/Share/ShareTest.php
+++ b/tests/lib/Share/ShareTest.php
@@ -21,11 +21,11 @@
namespace Test\Share;
-use OC\Share\Share;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\Share\IShare;
/**
* Class Test_Share
@@ -140,15 +140,15 @@ class ShareTest extends \Test\TestCase {
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` ('
.' `item_type`, `item_source`, `item_target`, `share_type`,'
.' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)');
- $args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), $this->user1->getUID()];
+ $args = ['test', 99, 'target1', IShare::TYPE_USER, $this->user2->getUID(), $this->user1->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), $this->user1->getUID()];
+ $args = ['test', 99, 'target2', IShare::TYPE_USER, $this->user4->getUID(), $this->user1->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user2->getUID()];
+ $args = ['test', 99, 'target3', IShare::TYPE_USER, $this->user3->getUID(), $this->user2->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user4->getUID()];
+ $args = ['test', 99, 'target4', IShare::TYPE_USER, $this->user3->getUID(), $this->user4->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user6->getUID(), $this->user4->getUID()];
+ $args = ['test', 99, 'target4', IShare::TYPE_USER, $this->user6->getUID(), $this->user4->getUID()];
$query->execute($args);
@@ -180,13 +180,13 @@ class ShareTest extends \Test\TestCase {
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` ('
.' `item_type`, `item_source`, `item_target`, `share_type`,'
.' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)');
- $args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()];
+ $args = ['test', 99, 'target1', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()];
+ $args = ['test', 99, 'target2', IShare::TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()];
+ $args = ['test', 99, 'target3', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()];
+ $args = ['test', 99, 'target4', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()];
$query->execute($args);
// user2 is in group1 and group2
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index 6f8a96fab19..b3de9d05a52 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -28,6 +28,7 @@ use OCP\Defaults;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
+use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroup;
use OCP\IGroupManager;
@@ -35,8 +36,10 @@ use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\Share\IShare;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* Class DefaultShareProviderTest
@@ -64,6 +67,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject|IMailer */
protected $mailer;
+ /** @var IFactory|MockObject */
+ protected $l10nFactory;
+
/** @var \PHPUnit_Framework_MockObject_MockObject|IL10N */
protected $l10n;
@@ -73,15 +79,20 @@ class DefaultShareProviderTest extends \Test\TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject|IURLGenerator */
protected $urlGenerator;
+ /** @var IConfig|MockObject */
+ protected $config;
+
protected function setUp(): void {
$this->dbConn = \OC::$server->getDatabaseConnection();
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->rootFolder = $this->createMock(IRootFolder::class);
$this->mailer = $this->createMock(IMailer::class);
+ $this->l10nFactory = $this->createMock(IFactory::class);
$this->l10n = $this->createMock(IL10N::class);
$this->defaults = $this->getMockBuilder(Defaults::class)->disableOriginalConstructor()->getMock();
$this->urlGenerator = $this->createMock(IURLGenerator::class);
+ $this->config = $this->createMock(IConfig::class);
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
@@ -95,8 +106,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder,
$this->mailer,
$this->defaults,
- $this->l10n,
- $this->urlGenerator
+ $this->l10nFactory,
+ $this->urlGenerator,
+ $this->config
);
}
@@ -177,7 +189,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -208,7 +220,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
@@ -224,7 +236,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -244,7 +256,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
// We do not fetch the node so the rootfolder is never called.
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
@@ -259,7 +271,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -287,7 +299,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
// We fetch the node so the root folder is eventually called
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
@@ -303,7 +315,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -330,7 +342,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
@@ -342,7 +354,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
}
public function testGetShareByIdUserGroupShare() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user0', 'user0', 'file', 42, 'myTarget', 31, null, null);
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user0', 'user0', 'file', 42, 'myTarget', 31, null, null);
$this->addShareToDB(2, 'user1', 'user0', 'user0', 'file', 42, 'userTarget', 0, null, null, $id);
$user0 = $this->createMock(IUser::class);
@@ -368,7 +380,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id, 'user1');
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
$this->assertSame('group0', $share->getSharedWith());
$this->assertSame('user0', $share->getSharedBy());
$this->assertSame('user0', $share->getShareOwner());
@@ -384,7 +396,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'password' => $qb->expr()->literal('password'),
'password_by_talk' => $qb->expr()->literal(true),
'uid_owner' => $qb->expr()->literal('shareOwner'),
@@ -413,7 +425,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_LINK, $share->getShareType());
$this->assertNull($share->getSharedWith());
$this->assertEquals('password', $share->getPassword());
$this->assertEquals(true, $share->getSendPasswordByTalk());
@@ -430,7 +442,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
'item_type' => $qb->expr()->literal('file'),
@@ -454,8 +466,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder,
$this->mailer,
$this->defaults,
- $this->l10n,
- $this->urlGenerator
+ $this->l10nFactory,
+ $this->urlGenerator,
+ $this->config
])
->setMethods(['getShareById'])
->getMock();
@@ -477,7 +490,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -510,7 +523,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
'item_type' => $qb->expr()->literal('file'),
@@ -537,7 +550,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->createMock(IShare::class);
$share->method('getId')->willReturn($id);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->method('getShareType')->willReturn(IShare::TYPE_GROUP);
/** @var DefaultShareProvider $provider */
$provider = $this->getMockBuilder(DefaultShareProvider::class)
@@ -548,8 +561,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder,
$this->mailer,
$this->defaults,
- $this->l10n,
- $this->urlGenerator
+ $this->l10nFactory,
+ $this->urlGenerator,
+ $this->config
])
->setMethods(['getShareById'])
->getMock();
@@ -571,7 +585,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -588,7 +602,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('user1'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('user2'),
@@ -603,7 +617,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group1'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('user3'),
@@ -633,7 +647,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertCount(2, $children);
//Child1
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $children[0]->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $children[0]->getShareType());
$this->assertEquals('user1', $children[0]->getSharedWith());
$this->assertEquals('user2', $children[0]->getSharedBy());
$this->assertEquals('shareOwner', $children[0]->getShareOwner());
@@ -644,7 +658,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals('myTarget1', $children[0]->getTarget());
//Child2
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $children[1]->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $children[1]->getShareType());
$this->assertEquals('group1', $children[1]->getSharedWith());
$this->assertEquals('user3', $children[1]->getSharedBy());
$this->assertEquals('shareOwner', $children[1]->getShareOwner());
@@ -681,7 +695,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->with(100)
->willReturn([$path]);
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER);
+ $share->setShareType(IShare::TYPE_USER);
$share->setSharedWith('sharedWith');
$share->setSharedBy('sharedBy');
$share->setShareOwner('shareOwner');
@@ -695,7 +709,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertNotNull($share2->getId());
$this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share2->getShareType());
+ $this->assertSame(IShare::TYPE_USER, $share2->getShareType());
$this->assertSame('sharedWith', $share2->getSharedWith());
$this->assertSame('sharedBy', $share2->getSharedBy());
$this->assertSame('shareOwner', $share2->getShareOwner());
@@ -737,7 +751,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->with(100)
->willReturn([$path]);
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->setShareType(IShare::TYPE_GROUP);
$share->setSharedWith('sharedWith');
$share->setSharedBy('sharedBy');
$share->setShareOwner('shareOwner');
@@ -751,7 +765,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertNotNull($share2->getId());
$this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share2->getShareType());
+ $this->assertSame(IShare::TYPE_GROUP, $share2->getShareType());
$this->assertSame('sharedWith', $share2->getSharedWith());
$this->assertSame('sharedBy', $share2->getSharedBy());
$this->assertSame('shareOwner', $share2->getShareOwner());
@@ -793,7 +807,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->with(100)
->willReturn([$path]);
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK);
+ $share->setShareType(IShare::TYPE_LINK);
$share->setSharedBy('sharedBy');
$share->setShareOwner('shareOwner');
$share->setNode($path);
@@ -809,7 +823,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertNotNull($share2->getId());
$this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_LINK, $share2->getShareType());
+ $this->assertSame(IShare::TYPE_LINK, $share2->getShareType());
$this->assertSame('sharedBy', $share2->getSharedBy());
$this->assertSame('shareOwner', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
@@ -827,7 +841,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'password' => $qb->expr()->literal('password'),
'password_by_talk' => $qb->expr()->literal(true),
'uid_owner' => $qb->expr()->literal('shareOwner'),
@@ -907,7 +921,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -922,7 +936,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith2'),
'uid_owner' => $qb->expr()->literal('shareOwner2'),
'uid_initiator' => $qb->expr()->literal('sharedBy2'),
@@ -937,7 +951,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId)->willReturn([$file]);
- $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_USER, null, 1 , 0);
+ $share = $this->provider->getSharedWith('sharedWith', IShare::TYPE_USER, null, 1 , 0);
$this->assertCount(1, $share);
$share = $share[0];
@@ -945,7 +959,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
}
/**
@@ -958,7 +972,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner2'),
'uid_initiator' => $qb->expr()->literal('sharedBy2'),
@@ -972,7 +986,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -1009,7 +1023,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId)->willReturn([$file]);
- $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_GROUP, null, 20 , 1);
+ $share = $this->provider->getSharedWith('sharedWith', IShare::TYPE_GROUP, null, 20 , 1);
$this->assertCount(1, $share);
$share = $share[0];
@@ -1017,7 +1031,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
}
/**
@@ -1029,7 +1043,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -1097,7 +1111,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId)->willReturn([$file]);
- $share = $this->provider->getSharedWith('user', \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0);
+ $share = $this->provider->getSharedWith('user', IShare::TYPE_GROUP, null, -1, 0);
$this->assertCount(1, $share);
$share = $share[0];
@@ -1105,7 +1119,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('sharedWith', $share->getSharedWith());
$this->assertSame('shareOwner', $share->getShareOwner());
$this->assertSame('sharedBy', $share->getSharedBy());
- $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertSame(IShare::TYPE_GROUP, $share->getShareType());
$this->assertSame(0, $share->getPermissions());
$this->assertSame('userTarget', $share->getTarget());
}
@@ -1117,9 +1131,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$storageId = $this->createTestStorageEntry($storageStringId);
$fileId = $this->createTestFileEntry($fileName1, $storageId);
$fileId2 = $this->createTestFileEntry($fileName2, $storageId);
- $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1',
+ $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user1',
'file', $fileId, 'myTarget', 31, null, null, null);
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1',
+ $id = $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user1',
'file', $fileId2, 'myTarget', 31, null, null, null);
$user0 = $this->createMock(IUser::class);
@@ -1140,7 +1154,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId2)->willReturn([$file]);
- $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_USER, $file, -1, 0);
+ $share = $this->provider->getSharedWith('user0', IShare::TYPE_USER, $file, -1, 0);
$this->assertCount(1, $share);
$share = $share[0];
@@ -1149,7 +1163,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('user1', $share->getShareOwner());
$this->assertSame('user1', $share->getSharedBy());
$this->assertSame($file, $share->getNode());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
}
/**
@@ -1159,9 +1173,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$storageId = $this->createTestStorageEntry($storageStringId);
$fileId = $this->createTestFileEntry($fileName1, $storageId);
$fileId2 = $this->createTestFileEntry($fileName2, $storageId);
- $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1',
+ $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user1',
'file', $fileId, 'myTarget', 31, null, null, null);
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1',
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user1',
'file', $fileId2, 'myTarget', 31, null, null, null);
$user0 = $this->createMock(IUser::class);
@@ -1181,7 +1195,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId2)->willReturn([$node]);
- $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
+ $share = $this->provider->getSharedWith('user0', IShare::TYPE_GROUP, $node, -1, 0);
$this->assertCount(1, $share);
$share = $share[0];
@@ -1190,15 +1204,15 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('user1', $share->getShareOwner());
$this->assertSame('user1', $share->getSharedBy());
$this->assertSame($node, $share->getNode());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
}
public function shareTypesProvider() {
return [
- [\OCP\Share::SHARE_TYPE_USER, false],
- [\OCP\Share::SHARE_TYPE_GROUP, false],
- [\OCP\Share::SHARE_TYPE_USER, true],
- [\OCP\Share::SHARE_TYPE_GROUP, true],
+ [IShare::TYPE_USER, false],
+ [IShare::TYPE_GROUP, false],
+ [IShare::TYPE_USER, true],
+ [IShare::TYPE_GROUP, true],
];
}
@@ -1261,7 +1275,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -1276,7 +1290,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy2'),
@@ -1292,7 +1306,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0);
+ $share = $this->provider->getSharesBy('sharedBy', IShare::TYPE_USER, null, false, 1, 0);
$this->assertCount(1, $share);
/** @var IShare $share */
@@ -1301,7 +1315,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('myTarget', $share->getTarget());
}
@@ -1310,7 +1324,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -1325,7 +1339,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -1342,7 +1356,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0);
+ $share = $this->provider->getSharesBy('sharedBy', IShare::TYPE_USER, $file, false, 1, 0);
$this->assertCount(1, $share);
/** @var IShare $share */
@@ -1351,7 +1365,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('myTarget', $share->getTarget());
}
@@ -1360,7 +1374,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('shareOwner'),
@@ -1375,7 +1389,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
@@ -1392,7 +1406,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0);
+ $shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_USER, null, true, -1, 0);
$this->assertCount(2, $shares);
/** @var IShare $share */
@@ -1401,7 +1415,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('sharedWith', $share->getSharedWith());
$this->assertSame('shareOwner', $share->getShareOwner());
$this->assertSame('shareOwner', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('myTarget', $share->getTarget());
@@ -1410,7 +1424,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('sharedWith', $share->getSharedWith());
$this->assertSame('shareOwner', $share->getShareOwner());
$this->assertSame('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals(0, $share->getPermissions());
$this->assertEquals('userTarget', $share->getTarget());
}
@@ -1419,7 +1433,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
@@ -1475,7 +1489,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
@@ -1550,7 +1564,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
@@ -1595,7 +1609,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
@@ -1633,7 +1647,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('user2'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
@@ -1686,7 +1700,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('user2'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
@@ -1729,7 +1743,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
'item_type' => $qb->expr()->literal('file'),
@@ -1759,7 +1773,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
}
public function testUpdateUser() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$users = [];
@@ -1817,7 +1831,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
}
public function testUpdateLink() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_LINK, null, 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_LINK, null, 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$users = [];
@@ -1877,7 +1891,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
}
public function testUpdateLinkRemovePassword() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_LINK, 'foo', 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_LINK, 'foo', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$qb = $this->dbConn->getQueryBuilder();
@@ -1940,7 +1954,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
}
public function testUpdateGroupNoSub() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$users = [];
@@ -2012,7 +2026,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
}
public function testUpdateGroupSubShares() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$id2 = $this->addShareToDB(2, 'user0', 'user1', 'user2',
@@ -2112,7 +2126,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
}
public function testMoveUserShare() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1', 'file',
+ $id = $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user1', 'file',
42, 'mytaret', 31, null, null);
$user0 = $this->createMock(IUser::class);
@@ -2143,7 +2157,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
}
public function testMoveGroupShare() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1', 'file',
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user1', 'file',
42, 'mytaret', 31, null, null);
$user0 = $this->createMock(IUser::class);
@@ -2185,20 +2199,20 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function dataDeleteUser() {
return [
- [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'a', true],
- [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'b', false],
- [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'c', true],
- [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'd', false],
- [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'a', true],
- [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'b', false],
+ [IShare::TYPE_USER, 'a', 'b', 'c', 'a', true],
+ [IShare::TYPE_USER, 'a', 'b', 'c', 'b', false],
+ [IShare::TYPE_USER, 'a', 'b', 'c', 'c', true],
+ [IShare::TYPE_USER, 'a', 'b', 'c', 'd', false],
+ [IShare::TYPE_GROUP, 'a', 'b', 'c', 'a', true],
+ [IShare::TYPE_GROUP, 'a', 'b', 'c', 'b', false],
// The group c is still valid but user c is deleted so group share stays
- [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'c', false],
- [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'd', false],
- [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'a', true],
+ [IShare::TYPE_GROUP, 'a', 'b', 'c', 'c', false],
+ [IShare::TYPE_GROUP, 'a', 'b', 'c', 'd', false],
+ [IShare::TYPE_LINK, 'a', 'b', 'c', 'a', true],
// To avoid invisible link shares delete initiated link shares as well (see #22327)
- [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'b', true],
- [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'c', false],
- [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'd', false],
+ [IShare::TYPE_LINK, 'a', 'b', 'c', 'b', true],
+ [IShare::TYPE_LINK, 'a', 'b', 'c', 'c', false],
+ [IShare::TYPE_LINK, 'a', 'b', 'c', 'd', false],
];
}
@@ -2263,7 +2277,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testDeleteUserGroup($owner, $initiator, $recipient, $deletedUser, $groupShareDeleted, $userGroupShareDeleted) {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
- ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))
+ ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))
->setValue('uid_owner', $qb->createNamedParameter($owner))
->setValue('uid_initiator', $qb->createNamedParameter($initiator))
->setValue('share_with', $qb->createNamedParameter('group'))
@@ -2285,7 +2299,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->execute();
$userGroupId = $qb->getLastInsertId();
- $this->provider->userDeleted($deletedUser, \OCP\Share::SHARE_TYPE_GROUP);
+ $this->provider->userDeleted($deletedUser, IShare::TYPE_GROUP);
$qb = $this->dbConn->getQueryBuilder();
$qb->select('*')
@@ -2314,28 +2328,28 @@ class DefaultShareProviderTest extends \Test\TestCase {
return [
[
[
- 'type' => \OCP\Share::SHARE_TYPE_USER,
+ 'type' => IShare::TYPE_USER,
'recipient' => 'user',
'children' => []
], 'group', false
],
[
[
- 'type' => \OCP\Share::SHARE_TYPE_USER,
+ 'type' => IShare::TYPE_USER,
'recipient' => 'user',
'children' => []
], 'user', false
],
[
[
- 'type' => \OCP\Share::SHARE_TYPE_LINK,
+ 'type' => IShare::TYPE_LINK,
'recipient' => 'user',
'children' => []
], 'group', false
],
[
[
- 'type' => \OCP\Share::SHARE_TYPE_GROUP,
+ 'type' => IShare::TYPE_GROUP,
'recipient' => 'group1',
'children' => [
'foo',
@@ -2345,7 +2359,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
],
[
[
- 'type' => \OCP\Share::SHARE_TYPE_GROUP,
+ 'type' => IShare::TYPE_GROUP,
'recipient' => 'group1',
'children' => [
'foo',
@@ -2426,7 +2440,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testUserDeletedFromGroup($group, $user, $toDelete) {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
- ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))
+ ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))
->setValue('uid_owner', $qb->createNamedParameter('owner'))
->setValue('uid_initiator', $qb->createNamedParameter('initiator'))
->setValue('share_with', $qb->createNamedParameter('group1'))
@@ -2474,8 +2488,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$rootFolder,
$this->mailer,
$this->defaults,
- $this->l10n,
- $this->urlGenerator
+ $this->l10nFactory,
+ $this->urlGenerator,
+ $this->config
);
$password = md5(time());
@@ -2497,7 +2512,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->setSharedBy($u1->getUID())
->setSharedWith($u2->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share1 = $this->provider->create($share1);
@@ -2506,7 +2521,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->setSharedBy($u2->getUID())
->setSharedWith($u3->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share2 = $this->provider->create($share2);
@@ -2514,7 +2529,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share3->setNode($folder2)
->setSharedBy($u2->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share3 = $this->provider->create($share3);
@@ -2523,7 +2538,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->setSharedBy($u1->getUID())
->setSharedWith($g1->getGID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share4 = $this->provider->create($share4);
@@ -2539,14 +2554,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file_shares = $result[$file1->getId()];
$this->assertCount(1, $file_shares);
$this->assertSame($file1->getId(), $file_shares[0]->getNodeId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $file_shares[0]->getShareType());
+ $this->assertSame(IShare::TYPE_USER, $file_shares[0]->getShareType());
$folder_shares = $result[$folder2->getId()];
$this->assertCount(2, $folder_shares);
$this->assertSame($folder2->getId(), $folder_shares[0]->getNodeId());
$this->assertSame($folder2->getId(), $folder_shares[1]->getNodeId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_LINK, $folder_shares[0]->getShareType());
- $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $folder_shares[1]->getShareType());
+ $this->assertSame(IShare::TYPE_LINK, $folder_shares[0]->getShareType());
+ $this->assertSame(IShare::TYPE_GROUP, $folder_shares[1]->getShareType());
$provider->delete($share1);
$provider->delete($share2);
@@ -2571,8 +2586,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$rootFolder,
$this->mailer,
$this->defaults,
- $this->l10n,
- $this->urlGenerator
+ $this->l10nFactory,
+ $this->urlGenerator,
+ $this->config
);
$u1 = $userManager->createUser('testShare1', 'test');
@@ -2600,7 +2616,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->setSharedBy($u1->getUID())
->setSharedWith($u2->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share1 = $this->provider->create($share1);
@@ -2609,7 +2625,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->setSharedBy($u2->getUID())
->setSharedWith($g1->getGID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share2 = $this->provider->create($share2);
@@ -2619,7 +2635,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share3->setNode($file1)
->setSharedBy($u3->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share3 = $this->provider->create($share3);
@@ -2628,7 +2644,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->setSharedBy($u3->getUID())
->setSharedWith($u5->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share4 = $this->provider->create($share4);
@@ -2666,8 +2682,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$rootFolder,
$this->mailer,
$this->defaults,
- $this->l10n,
- $this->urlGenerator
+ $this->l10nFactory,
+ $this->urlGenerator,
+ $this->config
);
$u1 = $userManager->createUser('testShare1', 'test');
@@ -2695,7 +2712,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->setSharedBy($u1->getUID())
->setSharedWith($u2->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share1 = $this->provider->create($share1);
@@ -2704,7 +2721,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->setSharedBy($u2->getUID())
->setSharedWith($g1->getGID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share2 = $this->provider->create($share2);
@@ -2714,7 +2731,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share3->setNode($file1)
->setSharedBy($u3->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share3 = $this->provider->create($share3);
@@ -2723,7 +2740,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
->setSharedBy($u3->getUID())
->setSharedWith($u5->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share4 = $this->provider->create($share4);
@@ -2753,7 +2770,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith1'),
'uid_owner' => $qb->expr()->literal('shareOwner1'),
'uid_initiator' => $qb->expr()->literal('sharedBy1'),
@@ -2768,7 +2785,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith2'),
'uid_owner' => $qb->expr()->literal('shareOwner2'),
'uid_initiator' => $qb->expr()->literal('sharedBy2'),
@@ -2783,7 +2800,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'token' => $qb->expr()->literal('token3'),
'uid_owner' => $qb->expr()->literal('shareOwner3'),
'uid_initiator' => $qb->expr()->literal('sharedBy3'),
@@ -2798,7 +2815,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_EMAIL),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_EMAIL),
'share_with' => $qb->expr()->literal('shareOwner4'),
'token' => $qb->expr()->literal('token4'),
'uid_owner' => $qb->expr()->literal('shareOwner4'),
@@ -2814,7 +2831,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'token' => $qb->expr()->literal('token5'),
'uid_owner' => $qb->expr()->literal('shareOwner5'),
'uid_initiator' => $qb->expr()->literal('sharedBy5'),
@@ -2867,7 +2884,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
// We fetch the node so the root folder is eventually called
$this->assertEquals($id1, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals('sharedWith1', $share->getSharedWith());
$this->assertEquals('sharedBy1', $share->getSharedBy());
$this->assertEquals('shareOwner1', $share->getShareOwner());
@@ -2879,7 +2896,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $shares[1];
$this->assertEquals($id2, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
$this->assertEquals('sharedWith2', $share->getSharedWith());
$this->assertEquals('sharedBy2', $share->getSharedBy());
$this->assertEquals('shareOwner2', $share->getShareOwner());
@@ -2891,7 +2908,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $shares[2];
$this->assertEquals($id3, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_LINK, $share->getShareType());
$this->assertEquals(null, $share->getSharedWith());
$this->assertEquals('sharedBy3', $share->getSharedBy());
$this->assertEquals('shareOwner3', $share->getShareOwner());
@@ -2903,7 +2920,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $shares[3];
$this->assertEquals($id5, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_LINK, $share->getShareType());
$this->assertEquals(null, $share->getSharedWith());
$this->assertEquals('sharedBy5', $share->getSharedBy());
$this->assertEquals('shareOwner5', $share->getShareOwner());
diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php
index 2b062e592ba..66dbafe7691 100644
--- a/tests/lib/Share20/LegacyHooksTest.php
+++ b/tests/lib/Share20/LegacyHooksTest.php
@@ -27,6 +27,7 @@ use OC\Share20\LegacyHooks;
use OC\Share20\Manager;
use OCP\Constants;
use OCP\Files\File;
+use OCP\Share\IShare;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\GenericEvent;
use Test\TestCase;
@@ -57,7 +58,7 @@ class LegacyHooksTest extends TestCase {
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
@@ -70,7 +71,7 @@ class LegacyHooksTest extends TestCase {
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
@@ -94,7 +95,7 @@ class LegacyHooksTest extends TestCase {
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
@@ -107,7 +108,7 @@ class LegacyHooksTest extends TestCase {
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
@@ -118,7 +119,7 @@ class LegacyHooksTest extends TestCase {
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
@@ -145,7 +146,7 @@ class LegacyHooksTest extends TestCase {
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
@@ -158,7 +159,7 @@ class LegacyHooksTest extends TestCase {
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
@@ -170,7 +171,7 @@ class LegacyHooksTest extends TestCase {
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
@@ -197,7 +198,7 @@ class LegacyHooksTest extends TestCase {
$date = new \DateTime();
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
@@ -217,7 +218,7 @@ class LegacyHooksTest extends TestCase {
$expected = [
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
+ 'shareType' => IShare::TYPE_LINK,
'shareWith' => 'awesomeUser',
'uidOwner' => 'sharedBy',
'fileSource' => 1,
@@ -245,7 +246,7 @@ class LegacyHooksTest extends TestCase {
$date = new \DateTime();
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
@@ -265,7 +266,7 @@ class LegacyHooksTest extends TestCase {
$expected = [
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
+ 'shareType' => IShare::TYPE_LINK,
'shareWith' => 'awesomeUser',
'uidOwner' => 'sharedBy',
'fileSource' => 1,
@@ -301,7 +302,7 @@ class LegacyHooksTest extends TestCase {
$share = $this->manager->newShare();
$share->setId(42)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
@@ -319,7 +320,7 @@ class LegacyHooksTest extends TestCase {
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
+ 'shareType' => IShare::TYPE_LINK,
'shareWith' => 'awesomeUser',
'uidOwner' => 'sharedBy',
'fileSource' => 1,
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index e66ac51aeea..65a5ff8946d 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -194,10 +194,10 @@ class ManagerTest extends \Test\TestCase {
$group->method('getGID')->willReturn('sharedWithGroup');
return [
- [\OCP\Share::SHARE_TYPE_USER, 'sharedWithUser'],
- [\OCP\Share::SHARE_TYPE_GROUP, 'sharedWithGroup'],
- [\OCP\Share::SHARE_TYPE_LINK, ''],
- [\OCP\Share::SHARE_TYPE_REMOTE, 'foo@bar.com'],
+ [IShare::TYPE_USER, 'sharedWithUser'],
+ [IShare::TYPE_GROUP, 'sharedWithGroup'],
+ [IShare::TYPE_LINK, ''],
+ [IShare::TYPE_REMOTE, 'foo@bar.com'],
];
}
@@ -257,7 +257,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('sharedWith')
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
@@ -306,7 +306,7 @@ class ManagerTest extends \Test\TestCase {
$share1 = $this->manager->newShare();
$share1->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('sharedWith1')
->setSharedBy('sharedBy1')
->setNode($path)
@@ -315,7 +315,7 @@ class ManagerTest extends \Test\TestCase {
$share2 = $this->manager->newShare();
$share2->setId(43)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('sharedWith2')
->setSharedBy('sharedBy2')
->setNode($path)
@@ -325,7 +325,7 @@ class ManagerTest extends \Test\TestCase {
$share3 = $this->manager->newShare();
$share3->setId(44)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setSharedBy('sharedBy3')
->setNode($path)
->setTarget('myTarget3')
@@ -373,7 +373,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('sharedWith')
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
@@ -404,14 +404,14 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $share->method('getShareType')->willReturn(IShare::TYPE_USER);
$child1 = $this->createMock(IShare::class);
- $child1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $child1->method('getShareType')->willReturn(IShare::TYPE_USER);
$child2 = $this->createMock(IShare::class);
- $child2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $child2->method('getShareType')->willReturn(IShare::TYPE_USER);
$child3 = $this->createMock(IShare::class);
- $child3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $child3->method('getShareType')->willReturn(IShare::TYPE_USER);
$shares = [
$child1,
@@ -463,7 +463,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setExpirationDate($date)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK);
+ ->setShareType(IShare::TYPE_LINK);
$this->defaultProvider->expects($this->once())
->method('getShareById')
@@ -572,30 +572,30 @@ class ManagerTest extends \Test\TestCase {
->willReturn($storage);
$data = [
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
[$this->createShare(null, -1, $file, null, $user0, $user0, 31, null, null), 'unknown share type', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, null, null, $user0, 31, null, null), 'SharedBy should be set', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $file, null, null, $user0, 31, null, null), 'SharedBy should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user0, $user0, $user0, 31, null, null), 'Can’t share with yourself', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, $user0, $user0, $user0, 31, null, null), 'Can’t share with yourself', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, null, $user2, $user0, $user0, 31, null, null), 'Path should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, null, $group0, $user0, $user0, 31, null, null), 'Path should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, null, null, $user0, $user0, 31, null, null), 'Path should be set', true],
+ [$this->createShare(null, IShare::TYPE_USER, null, $user2, $user0, $user0, 31, null, null), 'Path should be set', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, null, $group0, $user0, $user0, 31, null, null), 'Path should be set', true],
+ [$this->createShare(null, IShare::TYPE_LINK, null, null, $user0, $user0, 31, null, null), 'Path should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $node, $user2, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $node, $group0, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $node, null, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
+ [$this->createShare(null, IShare::TYPE_USER, $node, $user2, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $node, $group0, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $node, null, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
];
$nonShareAble = $this->createMock(Folder::class);
@@ -606,9 +606,9 @@ class ManagerTest extends \Test\TestCase {
$nonShareAble->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
$limitedPermssions = $this->createMock(File::class);
$limitedPermssions->method('isShareable')->willReturn(true);
@@ -619,17 +619,17 @@ class ManagerTest extends \Test\TestCase {
$limitedPermssions->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, null, null, null), 'A share requires permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, null, null, null), 'A share requires permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, null, null, null), 'A share requires permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $limitedPermssions, $user2, $user0, $user0, null, null, null), 'A share requires permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, null, null, null), 'A share requires permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, null, null, null), 'A share requires permissions', true];
$mount = $this->createMock(MoveableMount::class);
$limitedPermssions->method('getMountPoint')->willReturn($mount);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Can’t increase permissions of path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Can’t increase permissions of path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $limitedPermssions, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Can’t increase permissions of path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Can’t increase permissions of path', true];
$nonMoveableMountPermssions = $this->createMock(Folder::class);
$nonMoveableMountPermssions->method('isShareable')->willReturn(true);
@@ -640,17 +640,17 @@ class ManagerTest extends \Test\TestCase {
$nonMoveableMountPermssions->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false];
$rootFolder = $this->createMock(Folder::class);
$rootFolder->method('isShareable')->willReturn(true);
$rootFolder->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL);
$rootFolder->method('getId')->willReturn(42);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $rootFolder, $user2, $user0, $user0, 30, null, null), 'You can’t share your root folder', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $rootFolder, $group0, $user0, $user0, 2, null, null), 'You can’t share your root folder', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $rootFolder, null, $user0, $user0, 16, null, null), 'You can’t share your root folder', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $rootFolder, $user2, $user0, $user0, 30, null, null), 'You can’t share your root folder', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $rootFolder, $group0, $user0, $user0, 2, null, null), 'You can’t share your root folder', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $rootFolder, null, $user0, $user0, 16, null, null), 'You can’t share your root folder', true];
$allPermssions = $this->createMock(Folder::class);
$allPermssions->method('isShareable')->willReturn(true);
@@ -660,12 +660,12 @@ class ManagerTest extends \Test\TestCase {
$allPermssions->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 30, null, null), 'Shares need at least read permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 2, null, null), 'Shares need at least read permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $allPermssions, $user2, $user0, $user0, 30, null, null), 'Shares need at least read permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 2, null, null), 'Shares need at least read permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 31, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 3, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $allPermssions, $user2, $user0, $user0, 31, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 3, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false];
$remoteStorage = $this->createMock(Storage\IStorage::class);
@@ -679,9 +679,9 @@ class ManagerTest extends \Test\TestCase {
->willReturn($owner);
$remoteFile->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 1, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 3, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of ', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 1, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 3, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of ', true];
return $data;
}
@@ -747,7 +747,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $share->setShareType(IShare::TYPE_USER)
->setSharedWith('user0')
->setSharedBy('user1')
->setNode($userFolder);
@@ -1118,7 +1118,7 @@ class ManagerTest extends \Test\TestCase {
->setId('bar');
$share2 = $this->manager->newShare();
- $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share2->setShareType(IShare::TYPE_GROUP)
->setShareOwner('shareOwner2')
->setProviderId('foo')
->setId('baz')
@@ -1156,7 +1156,7 @@ class ManagerTest extends \Test\TestCase {
->setId('bar');
$share2 = $this->manager->newShare();
- $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share2->setShareType(IShare::TYPE_GROUP)
->setShareOwner('shareOwner2')
->setProviderId('foo')
->setId('baz')
@@ -1185,7 +1185,7 @@ class ManagerTest extends \Test\TestCase {
$this->userManager->method('get')->with('sharedWith')->willReturn($sharedWith);
$share2 = $this->manager->newShare();
- $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share2->setShareType(IShare::TYPE_GROUP)
->setShareOwner('shareOwner2')
->setProviderId('foo')
->setId('baz');
@@ -1598,7 +1598,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->createShare(
null,
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$path,
'sharedWith',
'sharedBy',
@@ -1653,7 +1653,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->createShare(
null,
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
$path,
'sharedWith',
'sharedBy',
@@ -1718,7 +1718,7 @@ class ManagerTest extends \Test\TestCase {
$date = new \DateTime();
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setNode($path)
->setSharedBy('sharedBy')
->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -1776,7 +1776,7 @@ class ManagerTest extends \Test\TestCase {
/** @var IShare $share */
$share = $e->getSubject();
- return $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ return $share->getShareType() === IShare::TYPE_LINK &&
$share->getNode() === $path &&
$share->getSharedBy() === 'sharedBy' &&
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
@@ -1795,7 +1795,7 @@ class ManagerTest extends \Test\TestCase {
/** @var IShare $share */
$share = $e->getSubject();
- return $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ return $share->getShareType() === IShare::TYPE_LINK &&
$share->getNode() === $path &&
$share->getSharedBy() === 'sharedBy' &&
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
@@ -1841,7 +1841,7 @@ class ManagerTest extends \Test\TestCase {
$path->method('getStorage')->willReturn($storage);
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $share->setShareType(IShare::TYPE_EMAIL)
->setNode($path)
->setSharedBy('sharedBy')
->setPermissions(\OCP\Constants::PERMISSION_ALL);
@@ -1886,7 +1886,7 @@ class ManagerTest extends \Test\TestCase {
/** @var IShare $share */
$share = $e->getSubject();
- return $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL &&
+ return $share->getShareType() === IShare::TYPE_EMAIL &&
$share->getNode() === $path &&
$share->getSharedBy() === 'sharedBy' &&
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
@@ -1905,7 +1905,7 @@ class ManagerTest extends \Test\TestCase {
/** @var IShare $share */
$share = $e->getSubject();
- return $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL &&
+ return $share->getShareType() === IShare::TYPE_EMAIL &&
$share->getNode() === $path &&
$share->getSharedBy() === 'sharedBy' &&
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
@@ -1950,7 +1950,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->createShare(
null,
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$path,
'sharedWith',
'sharedBy',
@@ -2030,7 +2030,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->createShare(
null,
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$path,
'sharedWith',
'sharedBy',
@@ -2078,14 +2078,14 @@ class ManagerTest extends \Test\TestCase {
->method('getSharesBy')
->with(
$this->equalTo('user'),
- $this->equalTo(\OCP\Share::SHARE_TYPE_USER),
+ $this->equalTo(IShare::TYPE_USER),
$this->equalTo($node),
$this->equalTo(true),
$this->equalTo(1),
$this->equalTo(1)
)->willReturn([$share]);
- $shares = $this->manager->getSharesBy('user', \OCP\Share::SHARE_TYPE_USER, $node, true, 1, 1);
+ $shares = $this->manager->getSharesBy('user', IShare::TYPE_USER, $node, true, 1, 1);
$this->assertCount(1, $shares);
$this->assertSame($share, $shares[0]);
@@ -2157,7 +2157,7 @@ class ManagerTest extends \Test\TestCase {
}
});
- $res = $manager->getSharesBy('user', \OCP\Share::SHARE_TYPE_LINK, $node, true, 3, 0);
+ $res = $manager->getSharesBy('user', IShare::TYPE_LINK, $node, true, 3, 0);
$this->assertCount(3, $res);
$this->assertEquals($shares[0]->getId(), $res[0]->getId());
@@ -2204,7 +2204,7 @@ class ManagerTest extends \Test\TestCase {
$factory->expects($this->once())
->method('getProviderForType')
- ->with(\OCP\Share::SHARE_TYPE_LINK)
+ ->with(IShare::TYPE_LINK)
->willReturn($this->defaultProvider);
$this->defaultProvider->expects($this->once())
@@ -2251,7 +2251,7 @@ class ManagerTest extends \Test\TestCase {
$factory->expects($this->any())
->method('getProviderForType')
->willReturnCallback(function ($shareType) use ($roomShareProvider) {
- if ($shareType !== \OCP\Share::SHARE_TYPE_ROOM) {
+ if ($shareType !== IShare::TYPE_ROOM) {
throw new Exception\ProviderException();
}
@@ -2299,11 +2299,11 @@ class ManagerTest extends \Test\TestCase {
$factory->expects($this->at(0))
->method('getProviderForType')
- ->with(\OCP\Share::SHARE_TYPE_LINK)
+ ->with(IShare::TYPE_LINK)
->willReturn($this->defaultProvider);
$factory->expects($this->at(1))
->method('getProviderForType')
- ->with(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->with(IShare::TYPE_REMOTE)
->willReturn($this->defaultProvider);
$this->defaultProvider->expects($this->at(0))
@@ -2398,7 +2398,7 @@ class ManagerTest extends \Test\TestCase {
->willReturn('yes');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
$this->config
@@ -2420,13 +2420,13 @@ class ManagerTest extends \Test\TestCase {
public function testCheckPasswordNoLinkShare() {
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $share->method('getShareType')->willReturn(IShare::TYPE_USER);
$this->assertFalse($this->manager->checkPassword($share, 'password'));
}
public function testCheckPasswordNoPassword() {
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$this->assertFalse($this->manager->checkPassword($share, 'password'));
$share->method('getPassword')->willReturn('password');
@@ -2435,7 +2435,7 @@ class ManagerTest extends \Test\TestCase {
public function testCheckPasswordInvalidPassword() {
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$share->method('getPassword')->willReturn('password');
$this->hasher->method('verify')->with('invalidpassword', 'password', '')->willReturn(false);
@@ -2445,7 +2445,7 @@ class ManagerTest extends \Test\TestCase {
public function testCheckPasswordValidPassword() {
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$share->method('getPassword')->willReturn('passwordHash');
$this->hasher->method('verify')->with('password', 'passwordHash', '')->willReturn(true);
@@ -2455,7 +2455,7 @@ class ManagerTest extends \Test\TestCase {
public function testCheckPasswordUpdateShare() {
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setPassword('passwordHash');
$this->hasher->method('verify')->with('password', 'passwordHash', '')
@@ -2487,7 +2487,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
+ $originalShare->setShareType(IShare::TYPE_GROUP);
$manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@@ -2495,7 +2495,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER);
+ ->setShareType(IShare::TYPE_USER);
$manager->updateShare($share);
}
@@ -2513,7 +2513,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $originalShare->setShareType(IShare::TYPE_GROUP)
->setSharedWith('origGroup');
$manager->expects($this->once())->method('canShare')->willReturn(true);
@@ -2522,7 +2522,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('newGroup');
$manager->updateShare($share);
@@ -2541,7 +2541,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $originalShare->setShareType(IShare::TYPE_USER)
->setSharedWith('sharedWith');
$manager->expects($this->once())->method('canShare')->willReturn(true);
@@ -2550,7 +2550,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('newUser')
->setShareOwner('newUser');
@@ -2571,7 +2571,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $originalShare->setShareType(IShare::TYPE_USER)
->setSharedWith('origUser')
->setPermissions(1);
@@ -2585,7 +2585,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('origUser')
->setShareOwner('newUser')
->setSharedBy('sharer')
@@ -2609,7 +2609,7 @@ class ManagerTest extends \Test\TestCase {
$hookListner2->expects($this->once())->method('post')->with([
'itemType' => 'file',
'itemSource' => 100,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'origUser',
'uidOwner' => 'sharer',
'permissions' => 31,
@@ -2631,7 +2631,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $originalShare->setShareType(IShare::TYPE_GROUP)
->setSharedWith('origUser')
->setPermissions(31);
@@ -2643,7 +2643,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('origUser')
->setShareOwner('owner')
->setNode($node)
@@ -2679,7 +2679,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $originalShare->setShareType(IShare::TYPE_LINK)
->setPermissions(15);
$tomorrow = new \DateTime();
@@ -2692,7 +2692,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -2760,7 +2760,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $originalShare->setShareType(IShare::TYPE_LINK)
->setPermissions(15);
$tomorrow = new \DateTime();
@@ -2773,7 +2773,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -2826,7 +2826,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$tomorrow = new \DateTime();
@@ -2839,7 +2839,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -2901,7 +2901,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword(null)
->setSendPasswordByTalk(false);
@@ -2916,7 +2916,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -2979,7 +2979,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('anotherPasswordHash')
->setSendPasswordByTalk(false);
@@ -2994,7 +2994,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -3065,7 +3065,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword(null)
->setSendPasswordByTalk(false);
@@ -3080,7 +3080,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -3137,7 +3137,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(false);
@@ -3152,7 +3152,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -3209,7 +3209,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(false);
@@ -3224,7 +3224,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -3281,7 +3281,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(false);
@@ -3296,7 +3296,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -3357,7 +3357,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(true);
@@ -3372,7 +3372,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -3433,7 +3433,7 @@ class ManagerTest extends \Test\TestCase {
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(true);
@@ -3448,7 +3448,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
@@ -3495,7 +3495,7 @@ class ManagerTest extends \Test\TestCase {
$this->expectExceptionMessage('Can’t change target of link share');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK);
+ $share->setShareType(IShare::TYPE_LINK);
$recipient = $this->createMock(IUser::class);
@@ -3508,7 +3508,7 @@ class ManagerTest extends \Test\TestCase {
$this->expectExceptionMessage('Invalid recipient');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER);
+ $share->setShareType(IShare::TYPE_USER);
$share->setSharedWith('sharedWith');
@@ -3517,7 +3517,7 @@ class ManagerTest extends \Test\TestCase {
public function testMoveShareUser() {
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $share->setShareType(IShare::TYPE_USER)
->setId('42')
->setProviderId('foo');
@@ -3535,7 +3535,7 @@ class ManagerTest extends \Test\TestCase {
$this->expectExceptionMessage('Invalid recipient');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->setShareType(IShare::TYPE_GROUP);
$sharedWith = $this->createMock(IGroup::class);
$share->setSharedWith('shareWith');
@@ -3555,7 +3555,7 @@ class ManagerTest extends \Test\TestCase {
$this->expectExceptionMessage('Group "shareWith" does not exist');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->setShareType(IShare::TYPE_GROUP);
$share->setSharedWith('shareWith');
$recipient = $this->createMock(IUser::class);
@@ -3568,7 +3568,7 @@ class ManagerTest extends \Test\TestCase {
public function testMoveShareGroup() {
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share->setShareType(IShare::TYPE_GROUP)
->setId('42')
->setProviderId('foo');
@@ -3594,7 +3594,7 @@ class ManagerTest extends \Test\TestCase {
$factory = $this->getMockBuilder('OCP\Share\IProviderFactory')->getMock();
$factory->expects($this->any())->method('getProviderForType')
->willReturnCallback(function ($id) {
- if ($id === \OCP\Share::SHARE_TYPE_USER) {
+ if ($id === IShare::TYPE_USER) {
return true;
}
throw new Exception\ProviderException();
@@ -3625,7 +3625,7 @@ class ManagerTest extends \Test\TestCase {
public function dataTestShareProviderExists() {
return [
- [\OCP\Share::SHARE_TYPE_USER, true],
+ [IShare::TYPE_USER, true],
[42, false],
];
}
diff --git a/tests/lib/Support/CrashReport/RegistryTest.php b/tests/lib/Support/CrashReport/RegistryTest.php
index d85b006509e..f88902d7065 100644
--- a/tests/lib/Support/CrashReport/RegistryTest.php
+++ b/tests/lib/Support/CrashReport/RegistryTest.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
*
@@ -26,6 +28,8 @@ namespace Test\Support\CrashReport;
use Exception;
use OC\Support\CrashReport\Registry;
+use OCP\AppFramework\QueryException;
+use OCP\IServerContainer;
use OCP\Support\CrashReport\ICollectBreadcrumbs;
use OCP\Support\CrashReport\IMessageReporter;
use OCP\Support\CrashReport\IReporter;
@@ -33,26 +37,60 @@ use Test\TestCase;
class RegistryTest extends TestCase {
+ /** @var IServerContainer|\PHPUnit\Framework\MockObject\MockObject */
+ private $serverContainer;
+
/** @var Registry */
private $registry;
protected function setUp(): void {
parent::setUp();
- $this->registry = new Registry();
+ $this->serverContainer = $this->createMock(IServerContainer::class);
+
+ $this->registry = new Registry(
+ $this->serverContainer
+ );
}
/**
* Doesn't assert anything, just checks whether anything "explodes"
*/
- public function testDelegateToNone() {
+ public function testDelegateToNone(): void {
$exception = new Exception('test');
$this->registry->delegateReport($exception);
$this->addToAssertionCount(1);
}
- public function testDelegateBreadcrumbCollection() {
+ public function testRegisterLazyCantLoad(): void {
+ $reporterClass = '\OCA\MyApp\Reporter';
+ $reporter = $this->createMock(IReporter::class);
+ $this->serverContainer->expects($this->once())
+ ->method('query')
+ ->with($reporterClass)
+ ->willReturn($reporter);
+ $reporter->expects($this->once())
+ ->method('report');
+ $exception = new Exception('test');
+
+ $this->registry->registerLazy($reporterClass);
+ $this->registry->delegateReport($exception);
+ }
+
+ public function testRegisterLazy(): void {
+ $reporterClass = '\OCA\MyApp\Reporter';
+ $this->serverContainer->expects($this->once())
+ ->method('query')
+ ->with($reporterClass)
+ ->willThrowException(new QueryException());
+ $exception = new Exception('test');
+
+ $this->registry->registerLazy($reporterClass);
+ $this->registry->delegateReport($exception);
+ }
+
+ public function testDelegateBreadcrumbCollection(): void {
$reporter1 = $this->createMock(IReporter::class);
$reporter2 = $this->createMock(ICollectBreadcrumbs::class);
$message = 'hello';
@@ -66,7 +104,7 @@ class RegistryTest extends TestCase {
$this->registry->delegateBreadcrumb($message, $category);
}
- public function testDelegateToAll() {
+ public function testDelegateToAll(): void {
$reporter1 = $this->createMock(IReporter::class);
$reporter2 = $this->createMock(IReporter::class);
$exception = new Exception('test');
@@ -82,7 +120,7 @@ class RegistryTest extends TestCase {
$this->registry->delegateReport($exception);
}
- public function testDelegateMessage() {
+ public function testDelegateMessage(): void {
$reporter1 = $this->createMock(IReporter::class);
$reporter2 = $this->createMock(IMessageReporter::class);
$message = 'hello';
diff --git a/tests/lib/TagsTest.php b/tests/lib/TagsTest.php
index fd6283d2f27..38d3d611bb8 100644
--- a/tests/lib/TagsTest.php
+++ b/tests/lib/TagsTest.php
@@ -24,6 +24,7 @@ namespace Test;
use OCP\IUser;
use OCP\IUserSession;
+use OCP\Share\IShare;
/**
* Class TagsTest
@@ -314,7 +315,7 @@ class TagsTest extends \Test\TestCase {
\OC_User::setUserId($this->user->getUID());
// TODO new sharing
- \OC\Share\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
+ \OC\Share\Share::shareItem('test', 1, IShare::TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
\OC_User::setUserId($otherUserId);
$otherTagger = $otherTagMgr->load('test', [], true); // Update tags, load shared ones.