aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Collaboration
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Collaboration')
-rw-r--r--tests/lib/Collaboration/Collaborators/GroupPluginTest.php40
-rw-r--r--tests/lib/Collaboration/Collaborators/LookupPluginTest.php157
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php122
-rw-r--r--tests/lib/Collaboration/Collaborators/RemotePluginTest.php60
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchResultTest.php38
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchTest.php36
-rw-r--r--tests/lib/Collaboration/Collaborators/UserPluginTest.php88
-rw-r--r--tests/lib/Collaboration/Resources/ManagerTest.php30
-rw-r--r--tests/lib/Collaboration/Resources/ProviderManagerTest.php34
9 files changed, 226 insertions, 379 deletions
diff --git a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
index 1cbaa178445..a4ecd598562 100644
--- a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
@@ -35,19 +19,19 @@ use OCP\Share\IShare;
use Test\TestCase;
class GroupPluginTest extends TestCase {
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
protected $config;
- /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
protected $groupManager;
- /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
protected $session;
- /** @var ISearchResult */
+ /** @var ISearchResult */
protected $searchResult;
- /** @var GroupPlugin */
+ /** @var GroupPlugin */
protected $plugin;
/** @var int */
@@ -56,7 +40,7 @@ class GroupPluginTest extends TestCase {
/** @var int */
protected $offset = 0;
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
protected $user;
protected function setUp(): void {
@@ -434,7 +418,6 @@ class GroupPluginTest extends TestCase {
}
/**
- * @dataProvider dataGetGroups
*
* @param string $searchTerm
* @param bool $shareWithGroupOnly
@@ -447,6 +430,7 @@ class GroupPluginTest extends TestCase {
* @param bool $reachedEnd
* @param bool|IGroup $singleGroup
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetGroups')]
public function testSearch(
string $searchTerm,
bool $shareWithGroupOnly,
@@ -457,8 +441,8 @@ class GroupPluginTest extends TestCase {
array $exactExpected,
array $expected,
bool $reachedEnd,
- $singleGroup
- ) {
+ $singleGroup,
+ ): void {
$this->config->expects($this->any())
->method('getAppValue')
->willReturnCallback(
diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
index 462497c637b..ac9b196ea1e 100644
--- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
@@ -41,15 +25,15 @@ use Psr\Log\LoggerInterface;
use Test\TestCase;
class LookupPluginTest extends TestCase {
- /** @var IConfig|MockObject */
+ /** @var IConfig|MockObject */
protected $config;
- /** @var IClientService|MockObject */
+ /** @var IClientService|MockObject */
protected $clientService;
/** @var IUserSession|MockObject */
protected $userSession;
/** @var ICloudIdManager|MockObject */
protected $cloudIdManager;
- /** @var LookupPlugin */
+ /** @var LookupPlugin */
protected $plugin;
/** @var LoggerInterface|MockObject */
protected $logger;
@@ -86,25 +70,22 @@ class LookupPluginTest extends TestCase {
);
}
- public function testSearchNoLookupServerURI() {
+ public function testSearchNoLookupServerURI(): void {
$this->config->expects($this->once())
->method('getAppValue')
- ->with('files_sharing', 'lookupServerEnabled', 'yes')
+ ->with('files_sharing', 'lookupServerEnabled', 'no')
->willReturn('yes');
$this->config->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['gs.enabled', false],
- ['lookup_server', 'https://lookup.nextcloud.com'],
- )->willReturnOnConsecutiveCalls(
- false,
- '',
- );
+ ->method('getSystemValueBool')
+ ->willReturnMap([
+ ['gs.enabled', false, true],
+ ['has_internet_connection', true, true],
+ ]);
$this->config->expects($this->once())
- ->method('getSystemValueBool')
- ->with('has_internet_connection', true)
- ->willReturn(true);
+ ->method('getSystemValueString')
+ ->with('lookup_server', 'https://lookup.nextcloud.com')
+ ->willReturn('');
$this->clientService->expects($this->never())
->method('newClient');
@@ -115,20 +96,17 @@ class LookupPluginTest extends TestCase {
$this->plugin->search('foobar', 10, 0, $searchResult);
}
- public function testSearchNoInternet() {
+ public function testSearchNoInternet(): void {
$this->config->expects($this->once())
->method('getAppValue')
- ->with('files_sharing', 'lookupServerEnabled', 'yes')
+ ->with('files_sharing', 'lookupServerEnabled', 'no')
->willReturn('yes');
- $this->config->expects($this->once())
- ->method('getSystemValue')
- ->with('gs.enabled', false)
- ->willReturn(false);
-
- $this->config->expects($this->once())
+ $this->config->expects($this->exactly(2))
->method('getSystemValueBool')
- ->with('has_internet_connection', true)
- ->willReturn(false);
+ ->willReturnMap([
+ ['gs.enabled', false, false],
+ ['has_internet_connection', true, false],
+ ]);
$this->clientService->expects($this->never())
->method('newClient');
@@ -140,10 +118,10 @@ class LookupPluginTest extends TestCase {
}
/**
- * @dataProvider searchDataProvider
* @param array $searchParams
*/
- public function testSearch(array $searchParams) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('searchDataProvider')]
+ public function testSearch(array $searchParams): void {
$type = new SearchResultType('lookup');
/** @var ISearchResult|MockObject $searchResult */
@@ -154,22 +132,19 @@ class LookupPluginTest extends TestCase {
$this->config->expects($this->once())
->method('getAppValue')
- ->with('files_sharing', 'lookupServerEnabled', 'yes')
+ ->with('files_sharing', 'lookupServerEnabled', 'no')
->willReturn('yes');
$this->config->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['gs.enabled', false],
- ['lookup_server', 'https://lookup.nextcloud.com'],
- )->willReturnOnConsecutiveCalls(
- false,
- $searchParams['server'],
- );
+ ->method('getSystemValueBool')
+ ->willReturnMap([
+ ['gs.enabled', false, true],
+ ['has_internet_connection', true, true],
+ ]);
$this->config->expects($this->once())
- ->method('getSystemValueBool')
- ->with('has_internet_connection', true)
- ->willReturn(true);
+ ->method('getSystemValueString')
+ ->with('lookup_server', 'https://lookup.nextcloud.com')
+ ->willReturn($searchParams['server']);
$response = $this->createMock(IResponse::class);
$response->expects($this->once())
@@ -201,12 +176,12 @@ class LookupPluginTest extends TestCase {
/**
- * @dataProvider dataSearchEnableDisableLookupServer
* @param array $searchParams
* @param bool $GSEnabled
* @param bool $LookupEnabled
*/
- public function testSearchEnableDisableLookupServer(array $searchParams, $GSEnabled, $LookupEnabled) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchEnableDisableLookupServer')]
+ public function testSearchEnableDisableLookupServer(array $searchParams, $GSEnabled, $LookupEnabled): void {
$type = new SearchResultType('lookup');
/** @var ISearchResult|MockObject $searchResult */
@@ -214,26 +189,23 @@ class LookupPluginTest extends TestCase {
$this->config->expects($this->once())
->method('getAppValue')
- ->with('files_sharing', 'lookupServerEnabled', 'yes')
+ ->with('files_sharing', 'lookupServerEnabled', 'no')
->willReturn($LookupEnabled ? 'yes' : 'no');
- if ($GSEnabled || $LookupEnabled) {
+ if ($GSEnabled) {
$searchResult->expects($this->once())
->method('addResultSet')
->with($type, $searchParams['expectedResult'], []);
- $this->config->expects($this->once())
- ->method('getSystemValueBool')
- ->with('has_internet_connection', true)
- ->willReturn(true);
$this->config->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['gs.enabled', false],
- ['lookup_server', 'https://lookup.nextcloud.com'],
- )->willReturnOnConsecutiveCalls(
- $GSEnabled,
- $searchParams['server'],
- );
+ ->method('getSystemValueBool')
+ ->willReturnMap([
+ ['gs.enabled', false, $GSEnabled],
+ ['has_internet_connection', true, true],
+ ]);
+ $this->config->expects($this->once())
+ ->method('getSystemValueString')
+ ->with('lookup_server', 'https://lookup.nextcloud.com')
+ ->willReturn($searchParams['server']);
$response = $this->createMock(IResponse::class);
$response->expects($this->once())
@@ -254,10 +226,12 @@ class LookupPluginTest extends TestCase {
->willReturn($client);
} else {
$searchResult->expects($this->never())->method('addResultSet');
- $this->config->expects($this->once())
- ->method('getSystemValue')
- ->with('gs.enabled', false)
- ->willReturn($GSEnabled);
+ $this->config->expects($this->exactly(2))
+ ->method('getSystemValueBool')
+ ->willReturnMap([
+ ['gs.enabled', false, $GSEnabled],
+ ['has_internet_connection', true, true],
+ ]);
}
$moreResults = $this->plugin->search(
$searchParams['search'],
@@ -270,11 +244,13 @@ class LookupPluginTest extends TestCase {
}
- public function testSearchLookupServerDisabled() {
- $this->config->expects($this->once())
- ->method('getAppValue')
- ->with('files_sharing', 'lookupServerEnabled', 'yes')
- ->willReturn('no');
+ public function testSearchGSDisabled(): void {
+ $this->config->expects($this->atLeastOnce())
+ ->method('getSystemValueBool')
+ ->willReturnMap([
+ ['has_internet_connection', true, true],
+ ['gs.enabled', false, false],
+ ]);
/** @var ISearchResult|MockObject $searchResult */
$searchResult = $this->createMock(ISearchResult::class);
@@ -286,7 +262,7 @@ class LookupPluginTest extends TestCase {
$this->assertFalse($this->plugin->search('irr', 10, 0, $searchResult));
}
- public function dataSearchEnableDisableLookupServer() {
+ public static function dataSearchEnableDisableLookupServer(): array {
$fedIDs = [
'foo@enceladus.moon',
'foobar@enceladus.moon',
@@ -393,7 +369,6 @@ class LookupPluginTest extends TestCase {
'label' => $fedIDs[0],
'value' => [
'shareType' => IShare::TYPE_REMOTE,
- 'globalScale' => false,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
@@ -402,7 +377,6 @@ class LookupPluginTest extends TestCase {
'label' => $fedIDs[1],
'value' => [
'shareType' => IShare::TYPE_REMOTE,
- 'globalScale' => false,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
@@ -411,7 +385,6 @@ class LookupPluginTest extends TestCase {
'label' => $fedIDs[2],
'value' => [
'shareType' => IShare::TYPE_REMOTE,
- 'globalScale' => false,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
@@ -462,7 +435,7 @@ class LookupPluginTest extends TestCase {
];
}
- public function searchDataProvider() {
+ public static function searchDataProvider(): array {
$fedIDs = [
'foo@enceladus.moon',
'foobar@enceladus.moon',
@@ -486,7 +459,7 @@ class LookupPluginTest extends TestCase {
'label' => $fedIDs[0],
'value' => [
'shareType' => IShare::TYPE_REMOTE,
- 'globalScale' => false,
+ 'globalScale' => true,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
@@ -495,7 +468,7 @@ class LookupPluginTest extends TestCase {
'label' => $fedIDs[1],
'value' => [
'shareType' => IShare::TYPE_REMOTE,
- 'globalScale' => false,
+ 'globalScale' => true,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
@@ -504,7 +477,7 @@ class LookupPluginTest extends TestCase {
'label' => $fedIDs[2],
'value' => [
'shareType' => IShare::TYPE_REMOTE,
- 'globalScale' => false,
+ 'globalScale' => true,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index 3cf76c562a1..b38b961a512 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
@@ -38,33 +22,33 @@ use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
-use OCP\Share\IShare;
use OCP\Mail\IMailer;
+use OCP\Share\IShare;
use Test\TestCase;
class MailPluginTest extends TestCase {
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
protected $config;
- /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
protected $contactsManager;
- /** @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject */
protected $cloudIdManager;
- /** @var MailPlugin */
+ /** @var MailPlugin */
protected $plugin;
- /** @var SearchResult */
+ /** @var SearchResult */
protected $searchResult;
- /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
protected $groupManager;
- /** @var KnownUserService|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var KnownUserService|\PHPUnit\Framework\MockObject\MockObject */
protected $knownUserService;
- /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
protected $userSession;
/** @var IMailer|\PHPUnit\Framework\MockObject\MockObject */
@@ -80,11 +64,11 @@ class MailPluginTest extends TestCase {
$this->userSession = $this->createMock(IUserSession::class);
$this->mailer = $this->createMock(IMailer::class);
$this->cloudIdManager = new CloudIdManager(
+ $this->createMock(ICacheFactory::class),
+ $this->createMock(IEventDispatcher::class),
$this->contactsManager,
$this->createMock(IURLGenerator::class),
$this->createMock(IUserManager::class),
- $this->createMock(ICacheFactory::class),
- $this->createMock(IEventDispatcher::class)
);
$this->searchResult = new SearchResult();
@@ -103,7 +87,6 @@ class MailPluginTest extends TestCase {
}
/**
- * @dataProvider dataGetEmail
*
* @param string $searchTerm
* @param array $contacts
@@ -111,7 +94,8 @@ class MailPluginTest extends TestCase {
* @param array $expected
* @param bool $reachedEnd
*/
- public function testSearch($searchTerm, $contacts, $shareeEnumeration, $expected, $exactIdMatch, $reachedEnd, $validEmail) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetEmail')]
+ public function testSearch($searchTerm, $contacts, $shareeEnumeration, $expected, $exactIdMatch, $reachedEnd, $validEmail): void {
$this->config->expects($this->any())
->method('getAppValue')
->willReturnCallback(
@@ -151,7 +135,7 @@ class MailPluginTest extends TestCase {
$this->assertSame($reachedEnd, $moreResults);
}
- public function dataGetEmail() {
+ public static function dataGetEmail(): array {
return [
// data set 0
['test', [], true, ['emails' => [], 'exact' => ['emails' => []]], false, false, false],
@@ -205,12 +189,12 @@ class MailPluginTest extends TestCase {
'UID' => 'uid1',
'FN' => 'User @ Localhost',
'EMAIL' => [
- 'username@localhost',
+ 'username@example.com',
],
],
],
true,
- ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]],
+ ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@example.com']]], 'exact' => ['emails' => []]],
false,
false,
false,
@@ -250,24 +234,24 @@ class MailPluginTest extends TestCase {
[
[
'UID' => 'uid3',
- 'FN' => 'User3 @ Localhost',
+ 'FN' => 'User3 @ example.com',
],
[
'UID' => 'uid2',
- 'FN' => 'User2 @ Localhost',
+ 'FN' => 'User2 @ example.com',
'EMAIL' => [
],
],
[
'UID' => 'uid1',
- 'FN' => 'User @ Localhost',
+ 'FN' => 'User @ example.com',
'EMAIL' => [
- 'username@localhost',
+ 'username@example.com',
],
],
],
true,
- ['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']]]]],
+ ['emails' => [['uuid' => 'uid1', 'name' => 'User @ example.com', 'type' => '', 'label' => 'User @ example.com (username@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@example.com']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
false,
true,
@@ -303,56 +287,56 @@ class MailPluginTest extends TestCase {
],
// data set 9
[
- 'username@localhost',
+ 'username@example.com',
[
[
'UID' => 'uid3',
- 'FN' => 'User3 @ Localhost',
+ 'FN' => 'User3 @ example.com',
],
[
'UID' => 'uid2',
- 'FN' => 'User2 @ Localhost',
+ 'FN' => 'User2 @ example.com',
'EMAIL' => [
],
],
[
'UID' => 'uid1',
- 'FN' => 'User @ Localhost',
+ 'FN' => 'User @ example.com',
'EMAIL' => [
- 'username@localhost',
+ 'username@example.com',
],
],
],
true,
- ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ example.com', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ example.com (username@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@example.com']]]]],
true,
false,
false,
],
// data set 10
[
- 'username@localhost',
+ 'username@example.com',
[
[
'UID' => 'uid1',
- 'FN' => 'User3 @ Localhost',
+ 'FN' => 'User3 @ example.com',
],
[
'UID' => 'uid2',
- 'FN' => 'User2 @ Localhost',
+ 'FN' => 'User2 @ example.com',
'EMAIL' => [
],
],
[
'UID' => 'uid1',
- 'FN' => 'User @ Localhost',
+ 'FN' => 'User @ example.com',
'EMAIL' => [
- 'username@localhost',
+ 'username@example.com',
],
],
],
false,
- ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ example.com', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ example.com (username@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@example.com']]]]],
true,
false,
false,
@@ -381,8 +365,8 @@ class MailPluginTest extends TestCase {
],
],
false,
- ['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,
+ ['emails' => [], 'exact' => ['emails' => []]],
+ false,
false,
false,
],
@@ -555,16 +539,16 @@ class MailPluginTest extends TestCase {
'UID' => 'uid1',
'FN' => 'User Name',
'EMAIL' => [
- ['type' => 'HOME', 'value' => 'username@localhost'],
- ['type' => 'WORK', 'value' => 'username@other'],
+ ['type' => 'HOME', 'value' => 'username@example.com'],
+ ['type' => 'WORK', 'value' => 'other@example.com'],
],
],
],
false,
['emails' => [
], 'exact' => ['emails' => [
- ['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']]
+ ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'HOME', 'label' => 'User Name (username@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@example.com']],
+ ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'WORK', 'label' => 'User Name (other@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'other@example.com']]
]]],
false,
false,
@@ -585,7 +569,6 @@ class MailPluginTest extends TestCase {
}
/**
- * @dataProvider dataGetEmailGroupsOnly
*
* @param string $searchTerm
* @param array $contacts
@@ -594,7 +577,8 @@ class MailPluginTest extends TestCase {
* @param bool $reachedEnd
* @param array groups
*/
- public function testSearchGroupsOnly($searchTerm, $contacts, $expected, $exactIdMatch, $reachedEnd, $userToGroupMapping, $validEmail) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetEmailGroupsOnly')]
+ public function testSearchGroupsOnly($searchTerm, $contacts, $expected, $exactIdMatch, $reachedEnd, $userToGroupMapping, $validEmail): void {
$this->config->expects($this->any())
->method('getAppValue')
->willReturnCallback(
@@ -610,7 +594,7 @@ class MailPluginTest extends TestCase {
$this->instantiatePlugin();
- /** @var \OCP\IUser | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
$currentUser = $this->createMock('\OCP\IUser');
$currentUser->expects($this->any())
@@ -635,7 +619,7 @@ class MailPluginTest extends TestCase {
$this->groupManager->expects($this->any())
->method('getUserGroupIds')
- ->willReturnCallback(function (\OCP\IUser $user) use ($userToGroupMapping) {
+ ->willReturnCallback(function (IUser $user) use ($userToGroupMapping) {
return $userToGroupMapping[$user->getUID()];
});
@@ -653,7 +637,7 @@ class MailPluginTest extends TestCase {
$this->assertSame($reachedEnd, $moreResults);
}
- public function dataGetEmailGroupsOnly() {
+ public static function dataGetEmailGroupsOnly(): array {
return [
// The user `User` can share with the current user
[
@@ -671,8 +655,8 @@ class MailPluginTest extends TestCase {
false,
false,
[
- "currentUser" => ["group1"],
- "User" => ["group1"]
+ 'currentUser' => ['group1'],
+ 'User' => ['group1']
],
false,
],
@@ -692,8 +676,8 @@ class MailPluginTest extends TestCase {
false,
false,
[
- "currentUser" => ["group1"],
- "User" => ["group2"]
+ 'currentUser' => ['group1'],
+ 'User' => ['group2']
],
false,
],
@@ -713,8 +697,8 @@ class MailPluginTest extends TestCase {
false,
false,
[
- "currentUser" => ["group1"],
- "User" => ["group2"]
+ 'currentUser' => ['group1'],
+ 'User' => ['group2']
],
true,
]
diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
index 4fed1f179e7..a9a5e05dfe4 100644
--- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
@@ -43,19 +27,19 @@ class RemotePluginTest extends TestCase {
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
protected $userManager;
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
protected $config;
- /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
protected $contactsManager;
- /** @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject */
protected $cloudIdManager;
- /** @var RemotePlugin */
+ /** @var RemotePlugin */
protected $plugin;
- /** @var SearchResult */
+ /** @var SearchResult */
protected $searchResult;
protected function setUp(): void {
@@ -65,11 +49,11 @@ class RemotePluginTest extends TestCase {
$this->config = $this->createMock(IConfig::class);
$this->contactsManager = $this->createMock(IManager::class);
$this->cloudIdManager = new CloudIdManager(
+ $this->createMock(ICacheFactory::class),
+ $this->createMock(IEventDispatcher::class),
$this->contactsManager,
$this->createMock(IURLGenerator::class),
$this->createMock(IUserManager::class),
- $this->createMock(ICacheFactory::class),
- $this->createMock(IEventDispatcher::class)
);
$this->searchResult = new SearchResult();
}
@@ -87,7 +71,6 @@ class RemotePluginTest extends TestCase {
}
/**
- * @dataProvider dataGetRemote
*
* @param string $searchTerm
* @param array $contacts
@@ -96,7 +79,8 @@ class RemotePluginTest extends TestCase {
* @param bool $exactIdMatch
* @param bool $reachedEnd
*/
- public function testSearch($searchTerm, array $contacts, $shareeEnumeration, array $expected, $exactIdMatch, $reachedEnd) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetRemote')]
+ public function testSearch($searchTerm, array $contacts, $shareeEnumeration, array $expected, $exactIdMatch, $reachedEnd): void {
$this->config->expects($this->any())
->method('getAppValue')
->willReturnCallback(
@@ -128,13 +112,13 @@ class RemotePluginTest extends TestCase {
}
/**
- * @dataProvider dataTestSplitUserRemote
*
* @param string $remote
* @param string $expectedUser
* @param string $expectedUrl
*/
- public function testSplitUserRemote($remote, $expectedUser, $expectedUrl) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSplitUserRemote')]
+ public function testSplitUserRemote($remote, $expectedUser, $expectedUrl): void {
$this->instantiatePlugin();
$this->contactsManager->expects($this->any())
@@ -147,18 +131,17 @@ class RemotePluginTest extends TestCase {
}
/**
- * @dataProvider dataTestSplitUserRemoteError
- *
* @param string $id
*/
- public function testSplitUserRemoteError($id) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSplitUserRemoteError')]
+ public function testSplitUserRemoteError($id): void {
$this->expectException(\Exception::class);
$this->instantiatePlugin();
$this->plugin->splitUserRemote($id);
}
- public function dataGetRemote() {
+ public static function dataGetRemote() {
return [
['test', [], true, ['remotes' => [], 'exact' => ['remotes' => []]], false, true],
['test', [], false, ['remotes' => [], 'exact' => ['remotes' => []]], false, true],
@@ -391,7 +374,7 @@ class RemotePluginTest extends TestCase {
];
}
- public function dataTestSplitUserRemote() {
+ public static function dataTestSplitUserRemote(): array {
$userPrefix = ['user@name', 'username'];
$protocols = ['', 'http://', 'https://'];
$remotes = [
@@ -412,6 +395,11 @@ class RemotePluginTest extends TestCase {
foreach ($protocols as $protocol) {
$baseUrl = $user . '@' . $protocol . $remote;
+ if ($protocol === 'https://') {
+ // https:// protocol is not expected in the final result
+ $protocol = '';
+ }
+
$testCases[] = [$baseUrl, $user, $protocol . $remote];
$testCases[] = [$baseUrl . '/', $user, $protocol . $remote];
$testCases[] = [$baseUrl . '/index.php', $user, $protocol . $remote];
@@ -422,7 +410,7 @@ class RemotePluginTest extends TestCase {
return $testCases;
}
- public function dataTestSplitUserRemoteError() {
+ public static function dataTestSplitUserRemoteError(): array {
return [
// Invalid path
['user@'],
diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
index 98e454f2834..687901c47a6 100644
--- a/tests/lib/Collaboration/Collaborators/SearchResultTest.php
+++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Joas Schilling
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
@@ -31,9 +15,9 @@ use OCP\IContainer;
use Test\TestCase;
class SearchResultTest extends TestCase {
- /** @var IContainer|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IContainer|\PHPUnit\Framework\MockObject\MockObject */
protected $container;
- /** @var ISearch */
+ /** @var ISearch */
protected $search;
protected function setUp(): void {
@@ -44,7 +28,7 @@ class SearchResultTest extends TestCase {
$this->search = new Search($this->container);
}
- public function dataAddResultSet() {
+ public static function dataAddResultSet(): array {
return [
[[], ['exact' => []]],
[['users' => ['exact' => null, 'loose' => []]], ['exact' => ['users' => []], 'users' => []]],
@@ -54,11 +38,11 @@ class SearchResultTest extends TestCase {
}
/**
- * @dataProvider dataAddResultSet
* @param array $toAdd
* @param array $expected
*/
- public function testAddResultSet(array $toAdd, array $expected) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataAddResultSet')]
+ public function testAddResultSet(array $toAdd, array $expected): void {
$result = new SearchResult();
foreach ($toAdd as $type => $results) {
@@ -68,7 +52,7 @@ class SearchResultTest extends TestCase {
$this->assertEquals($expected, $result->asArray());
}
- public function dataHasResult() {
+ public static function dataHasResult(): array {
$result = ['value' => ['shareWith' => 'l1']];
return [
[[],'users', 'n1', false],
@@ -83,13 +67,13 @@ class SearchResultTest extends TestCase {
}
/**
- * @dataProvider dataHasResult
* @param array $toAdd
* @param string $type
* @param string $id
* @param bool $expected
*/
- public function testHasResult(array $toAdd, $type, $id, $expected) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataHasResult')]
+ public function testHasResult(array $toAdd, $type, $id, $expected): void {
$result = new SearchResult();
foreach ($toAdd as $addType => $results) {
diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php
index 1d55ee6dd22..ade995ea526 100644
--- a/tests/lib/Collaboration/Collaborators/SearchTest.php
+++ b/tests/lib/Collaboration/Collaborators/SearchTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
@@ -33,9 +17,9 @@ use OCP\Share\IShare;
use Test\TestCase;
class SearchTest extends TestCase {
- /** @var IContainer|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IContainer|\PHPUnit\Framework\MockObject\MockObject */
protected $container;
- /** @var ISearch */
+ /** @var ISearch */
protected $search;
protected function setUp(): void {
@@ -46,9 +30,7 @@ class SearchTest extends TestCase {
$this->search = new Search($this->container);
}
- /**
- * @dataProvider dataSearchSharees
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchSharees')]
public function testSearch(
string $searchTerm,
array $shareTypes,
@@ -59,8 +41,8 @@ class SearchTest extends TestCase {
array $mockedRemotesResult,
array $mockedMailResult,
array $expected,
- bool $expectedMoreResults
- ) {
+ bool $expectedMoreResults,
+ ): void {
$searchResult = new SearchResult();
$userPlugin = $this->createMock(ISearchPlugin::class);
@@ -132,7 +114,7 @@ class SearchTest extends TestCase {
$this->assertSame($expectedMoreResults, $moreResults);
}
- public function dataSearchSharees() {
+ public static function dataSearchSharees(): array {
return [
// #0
[
diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
index 0d9d89c7f8b..cb4949fb86d 100644
--- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
@@ -1,28 +1,15 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
+use OC\Collaboration\Collaborators\SearchResult;
+use OC\Collaboration\Collaborators\UserPlugin;
+use OC\KnownUser\KnownUserService;
use OCP\Collaboration\Collaborators\ISearchResult;
use OCP\IConfig;
use OCP\IGroup;
@@ -32,42 +19,39 @@ use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\IShare;
use OCP\UserStatus\IManager as IUserStatusManager;
-use OC\Collaboration\Collaborators\SearchResult;
-use OC\Collaboration\Collaborators\UserPlugin;
-use OC\KnownUser\KnownUserService;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class UserPluginTest extends TestCase {
- /** @var IConfig|MockObject */
+ /** @var IConfig|MockObject */
protected $config;
- /** @var IUserManager|MockObject */
+ /** @var IUserManager|MockObject */
protected $userManager;
- /** @var IGroupManager|MockObject */
+ /** @var IGroupManager|MockObject */
protected $groupManager;
- /** @var IUserSession|MockObject */
+ /** @var IUserSession|MockObject */
protected $session;
- /** @var KnownUserService|MockObject */
+ /** @var KnownUserService|MockObject */
protected $knownUserService;
/** @var IUserStatusManager|MockObject */
protected $userStatusManager;
- /** @var UserPlugin */
+ /** @var UserPlugin */
protected $plugin;
- /** @var ISearchResult */
+ /** @var ISearchResult */
protected $searchResult;
protected int $limit = 2;
protected int $offset = 0;
- /** @var IUser|MockObject */
+ /** @var IUser|MockObject */
protected $user;
protected function setUp(): void {
@@ -141,7 +125,7 @@ class UserPluginTest extends TestCase {
return $group;
}
- public function dataGetUsers() {
+ public function dataGetUsers(): array {
return [
['test', false, true, [], [], [], [], true, false],
['test', false, false, [], [], [], [], true, false],
@@ -434,7 +418,6 @@ class UserPluginTest extends TestCase {
}
/**
- * @dataProvider dataGetUsers
*
* @param string $searchTerm
* @param bool $shareWithGroupOnly
@@ -447,6 +430,7 @@ class UserPluginTest extends TestCase {
* @param bool|IUser $singleUser
* @param array $users
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetUsers')]
public function testSearch(
$searchTerm,
$shareWithGroupOnly,
@@ -458,9 +442,9 @@ class UserPluginTest extends TestCase {
$reachedEnd,
$singleUser,
array $users = [],
- $shareeEnumerationPhone = false
- ) {
- $this->mockConfig(["core" => [
+ $shareeEnumerationPhone = false,
+ ): void {
+ $this->mockConfig(['core' => [
'shareapi_only_share_with_group_members' => $shareWithGroupOnly ? 'yes' : 'no',
'shareapi_allow_share_dialog_user_enumeration' => $shareeEnumeration? 'yes' : 'no',
'shareapi_restrict_user_enumeration_to_group' => false ? 'yes' : 'no',
@@ -525,7 +509,7 @@ class UserPluginTest extends TestCase {
$this->assertSame($reachedEnd, $moreResults);
}
- public function takeOutCurrentUserProvider() {
+ public static function takeOutCurrentUserProvider(): array {
$inputUsers = [
'alice' => 'Alice',
'bob' => 'Bob',
@@ -551,12 +535,12 @@ class UserPluginTest extends TestCase {
}
/**
- * @dataProvider takeOutCurrentUserProvider
* @param array $users
* @param array $expectedUIDs
* @param $currentUserId
*/
- public function testTakeOutCurrentUser(array $users, array $expectedUIDs, $currentUserId) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('takeOutCurrentUserProvider')]
+ public function testTakeOutCurrentUser(array $users, array $expectedUIDs, $currentUserId): void {
$this->instantiatePlugin();
$this->session->expects($this->once())
@@ -572,7 +556,7 @@ class UserPluginTest extends TestCase {
$this->assertSame($expectedUIDs, array_keys($users));
}
- public function dataSearchEnumeration() {
+ public static function dataSearchEnumeration(): array {
return [
[
'test',
@@ -733,10 +717,8 @@ class UserPluginTest extends TestCase {
];
}
- /**
- * @dataProvider dataSearchEnumeration
- */
- public function testSearchEnumerationLimit($search, $userGroups, $matchingUsers, $result, $mockedSettings) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchEnumeration')]
+ public function testSearchEnumerationLimit($search, $userGroups, $matchingUsers, $result, $mockedSettings): void {
$this->mockConfig($mockedSettings);
$userResults = [];
@@ -779,16 +761,16 @@ class UserPluginTest extends TestCase {
return null;
});
$this->userManager
- ->method('searchDisplayName')
- ->willReturnCallback(function ($search) use ($matchingUsers) {
- $users = array_filter(
- $matchingUsers,
- fn ($user) => str_contains(strtolower($user['displayName']), strtolower($search))
- );
- return array_map(
- fn ($user) => $this->getUserMock($user['uid'], $user['displayName']),
- $users);
- });
+ ->method('searchDisplayName')
+ ->willReturnCallback(function ($search) use ($matchingUsers) {
+ $users = array_filter(
+ $matchingUsers,
+ fn ($user) => str_contains(strtolower($user['displayName']), strtolower($search))
+ );
+ return array_map(
+ fn ($user) => $this->getUserMock($user['uid'], $user['displayName']),
+ $users);
+ });
$this->groupManager->method('displayNamesInGroup')
->willReturn($userResults);
diff --git a/tests/lib/Collaboration/Resources/ManagerTest.php b/tests/lib/Collaboration/Resources/ManagerTest.php
index 80b1ac464a6..0e4e42458e2 100644
--- a/tests/lib/Collaboration/Resources/ManagerTest.php
+++ b/tests/lib/Collaboration/Resources/ManagerTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019 Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Resources;
@@ -27,16 +12,15 @@ use OC\Collaboration\Resources\Manager;
use OCP\Collaboration\Resources\IManager;
use OCP\Collaboration\Resources\IProviderManager;
use OCP\IDBConnection;
+use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
class ManagerTest extends TestCase {
- /** @var LoggerInterface */
- protected $logger;
- /** @var IProviderManager */
- protected $providerManager;
- /** @var IManager */
- protected $manager;
+
+ protected LoggerInterface&MockObject $logger;
+ protected IProviderManager&MockObject $providerManager;
+ protected IManager $manager;
protected function setUp(): void {
parent::setUp();
diff --git a/tests/lib/Collaboration/Resources/ProviderManagerTest.php b/tests/lib/Collaboration/Resources/ProviderManagerTest.php
index 6c66422c9d3..b063d89f06e 100644
--- a/tests/lib/Collaboration/Resources/ProviderManagerTest.php
+++ b/tests/lib/Collaboration/Resources/ProviderManagerTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019 Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Resources;
@@ -92,13 +77,14 @@ class ProviderManagerTest extends TestCase {
public function testGetResourceProvidersValidAndInvalidProvider(): void {
$this->serverContainer->expects($this->exactly(2))
->method('query')
- ->withConsecutive(
- [$this->equalTo('InvalidResourceProvider')],
- [$this->equalTo(ResourceProvider::class)],
- )->willReturnOnConsecutiveCalls(
- $this->throwException(new QueryException('A meaningful error message')),
- $this->createMock(ResourceProvider::class),
- );
+ ->willReturnCallback(function (string $service) {
+ if ($service === 'InvalidResourceProvider') {
+ throw new QueryException('A meaningful error message');
+ }
+ if ($service === ResourceProvider::class) {
+ return $this->createMock(ResourceProvider::class);
+ }
+ });
$this->logger->expects($this->once())
->method('error');