aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2022-05-13 20:14:31 +0200
committerGitHub <noreply@github.com>2022-05-13 20:14:31 +0200
commit85758a4f7011cf6ec3c24d4f500129504b910767 (patch)
treecd7bd5e6c943110affeaddbf5f96655f4479fb19 /tests
parent20a648ed95bb6e7e795d2c87caffaa37554b0d8f (diff)
parent232322fe062031d5fe5b5297ca60b22bc1da1d30 (diff)
downloadnextcloud-server-85758a4f7011cf6ec3c24d4f500129504b910767.tar.gz
nextcloud-server-85758a4f7011cf6ec3c24d4f500129504b910767.zip
Merge pull request #31662 from nextcloud/modernize-contactmenu
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Controller/ContactsMenuControllerTest.php15
-rw-r--r--tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php4
-rw-r--r--tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php31
-rw-r--r--tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php6
-rw-r--r--tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php287
-rw-r--r--tests/lib/Contacts/ContactsMenu/EntryTest.php4
-rw-r--r--tests/lib/Contacts/ContactsMenu/ManagerTest.php53
-rw-r--r--tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php9
8 files changed, 192 insertions, 217 deletions
diff --git a/tests/Core/Controller/ContactsMenuControllerTest.php b/tests/Core/Controller/ContactsMenuControllerTest.php
index a702a155860..0bed7b8e7a1 100644
--- a/tests/Core/Controller/ContactsMenuControllerTest.php
+++ b/tests/Core/Controller/ContactsMenuControllerTest.php
@@ -30,30 +30,27 @@ use OCP\Contacts\ContactsMenu\IEntry;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class ContactsMenuControllerTest extends TestCase {
- /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
- private $request;
-
- /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUserSession|MockObject */
private $userSession;
- /** @var Manager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var Manager|MockObject */
private $contactsManager;
- /** @var ContactsMenuController */
- private $controller;
+ private ContactsMenuController $controller;
protected function setUp(): void {
parent::setUp();
- $this->request = $this->createMock(IRequest::class);
+ $request = $this->createMock(IRequest::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->contactsManager = $this->createMock(Manager::class);
- $this->controller = new ContactsMenuController($this->request, $this->userSession, $this->contactsManager);
+ $this->controller = new ContactsMenuController($request, $this->userSession, $this->contactsManager);
}
public function testIndex() {
diff --git a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php
index d858eab4d11..7102ed80129 100644
--- a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php
@@ -29,9 +29,7 @@ use OCP\Contacts\ContactsMenu\IAction;
use Test\TestCase;
class ActionFactoryTest extends TestCase {
-
- /** @var ActionFactory */
- private $actionFactory;
+ private ActionFactory $actionFactory;
protected function setUp(): void {
parent::setUp();
diff --git a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
index a3557d7cda6..67f84042996 100644
--- a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
@@ -33,31 +33,28 @@ use OCP\AppFramework\QueryException;
use OCP\Contacts\ContactsMenu\IProvider;
use OCP\IServerContainer;
use OCP\IUser;
+use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
class ActionProviderStoreTest extends TestCase {
- /** @var IServerContainer|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IServerContainer|MockObject */
private $serverContainer;
- /** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IAppManager|MockObject */
private $appManager;
- /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
- private $logger;
-
- /** @var ActionProviderStore */
- private $actionProviderStore;
+ private ActionProviderStore $actionProviderStore;
protected function setUp(): void {
parent::setUp();
$this->serverContainer = $this->createMock(IServerContainer::class);
$this->appManager = $this->createMock(AppManager::class);
- $this->logger = $this->createMock(LoggerInterface::class);
+ $logger = $this->createMock(LoggerInterface::class);
- $this->actionProviderStore = new ActionProviderStore($this->serverContainer, $this->appManager, $this->logger);
+ $this->actionProviderStore = new ActionProviderStore($this->serverContainer, $this->appManager, $logger);
}
public function testGetProviders() {
@@ -79,11 +76,11 @@ class ActionProviderStoreTest extends TestCase {
],
]);
$this->serverContainer->expects($this->exactly(3))
- ->method('query')
+ ->method('get')
->willReturnMap([
- [ProfileProvider::class, true, $provider1],
- [EMailProvider::class, true, $provider2],
- ['OCA\Contacts\Provider1', true, $provider3]
+ [ProfileProvider::class, $provider1],
+ [EMailProvider::class, $provider2],
+ ['OCA\Contacts\Provider1', $provider3]
]);
$providers = $this->actionProviderStore->getProviders($user);
@@ -107,10 +104,10 @@ class ActionProviderStoreTest extends TestCase {
->with('contacts')
->willReturn([/* Empty info.xml */]);
$this->serverContainer->expects($this->exactly(2))
- ->method('query')
+ ->method('get')
->willReturnMap([
- [ProfileProvider::class, true, $provider1],
- [EMailProvider::class, true, $provider2],
+ [ProfileProvider::class, $provider1],
+ [EMailProvider::class, $provider2],
]);
$providers = $this->actionProviderStore->getProviders($user);
@@ -130,7 +127,7 @@ class ActionProviderStoreTest extends TestCase {
->with($user)
->willReturn([]);
$this->serverContainer->expects($this->once())
- ->method('query')
+ ->method('get')
->willThrowException(new QueryException());
$this->actionProviderStore->getProviders($user);
diff --git a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php
index 1f5d37e7483..497cf992e95 100644
--- a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php
+++ b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php
@@ -28,7 +28,7 @@ use OC\Contacts\ContactsMenu\Actions\LinkAction;
use Test\TestCase;
class LinkActionTest extends TestCase {
- private $action;
+ private LinkAction $action;
protected function setUp(): void {
parent::setUp();
@@ -49,7 +49,7 @@ class LinkActionTest extends TestCase {
public function testGetSetName() {
$name = 'Jane Doe';
- $this->assertNull($this->action->getName());
+ $this->assertEmpty($this->action->getName());
$this->action->setName($name);
$this->assertEquals($name, $this->action->getName());
}
@@ -67,7 +67,7 @@ class LinkActionTest extends TestCase {
$json = $this->action->jsonSerialize();
$this->assertArrayHasKey('hyperlink', $json);
- $this->assertEquals($json['hyperlink'], '/some/url');
+ $this->assertEquals('/some/url', $json['hyperlink']);
}
public function testJsonSerialize() {
diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
index bd82c203ff5..aa609aedbb9 100644
--- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
@@ -39,19 +39,18 @@ use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class ContactsStoreTest extends TestCase {
- /** @var ContactsStore */
- private $contactsStore;
- /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
+ private ContactsStore $contactsStore;
+ /** @var IManager|MockObject */
private $contactsManager;
/** @var ProfileManager */
private $profileManager;
- /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUserManager|MockObject */
private $userManager;
/** @var IURLGenerator */
private $urlGenerator;
- /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IGroupManager|MockObject */
private $groupManager;
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|MockObject */
private $config;
/** @var KnownUserService|MockObject */
private $knownUserService;
@@ -82,7 +81,7 @@ class ContactsStoreTest extends TestCase {
}
public function testGetContactsWithoutFilter() {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->contactsManager->expects($this->once())
->method('search')
@@ -112,7 +111,7 @@ class ContactsStoreTest extends TestCase {
}
public function testGetContactsHidesOwnEntry() {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->contactsManager->expects($this->once())
->method('search')
@@ -139,7 +138,7 @@ class ContactsStoreTest extends TestCase {
}
public function testGetContactsWithoutBinaryImage() {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->contactsManager->expects($this->once())
->method('search')
@@ -168,7 +167,7 @@ class ContactsStoreTest extends TestCase {
}
public function testGetContactsWithoutAvatarURI() {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->contactsManager->expects($this->once())
->method('search')
@@ -208,7 +207,7 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_exclude_groups_list', '', '["group1", "group5", "group6"]'],
]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
+ /** @var IUser|MockObject $currentUser */
$currentUser = $this->createMock(IUser::class);
$currentUser->expects($this->exactly(2))
->method('getUID')
@@ -251,44 +250,39 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
+ /** @var IUser|MockObject $currentUser */
$currentUser = $this->createMock(IUser::class);
$currentUser->expects($this->exactly(2))
->method('getUID')
->willReturn('user001');
- $this->groupManager->expects($this->at(0))
- ->method('getUserGroupIds')
- ->with($this->equalTo($currentUser))
- ->willReturn(['group1', 'group2', 'group3']);
-
$user1 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(0))
- ->method('get')
- ->with('user1')
- ->willReturn($user1);
- $this->groupManager->expects($this->at(1))
- ->method('getUserGroupIds')
- ->with($this->equalTo($user1))
- ->willReturn(['group1']);
$user2 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(1))
- ->method('get')
- ->with('user2')
- ->willReturn($user2);
- $this->groupManager->expects($this->at(2))
- ->method('getUserGroupIds')
- ->with($this->equalTo($user2))
- ->willReturn(['group2', 'group3']);
$user3 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(2))
- ->method('get')
- ->with('user3')
- ->willReturn($user3);
- $this->groupManager->expects($this->at(3))
+
+ $this->groupManager->expects($this->exactly(4))
->method('getUserGroupIds')
- ->with($this->equalTo($user3))
- ->willReturn(['group8', 'group9']);
+ ->withConsecutive(
+ [$this->equalTo($currentUser)],
+ [$this->equalTo($user1)],
+ [$this->equalTo($user2)],
+ [$this->equalTo($user3)]
+ )
+ ->willReturnOnConsecutiveCalls(
+ ['group1', 'group2', 'group3'],
+ ['group1'],
+ ['group2', 'group3'],
+ ['group8', 'group9']
+ );
+
+ $this->userManager->expects($this->exactly(3))
+ ->method('get')
+ ->withConsecutive(
+ ['user1'],
+ ['user2'],
+ ['user3']
+ )
+ ->willReturnOnConsecutiveCalls($user1, $user2, $user3);
$this->contactsManager->expects($this->once())
->method('search')
@@ -330,44 +324,39 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
+ /** @var IUser|MockObject $currentUser */
$currentUser = $this->createMock(IUser::class);
$currentUser->expects($this->exactly(2))
->method('getUID')
->willReturn('user001');
- $this->groupManager->expects($this->at(0))
- ->method('getUserGroupIds')
- ->with($this->equalTo($currentUser))
- ->willReturn(['group1', 'group2', 'group3']);
-
$user1 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(0))
- ->method('get')
- ->with('user1')
- ->willReturn($user1);
- $this->groupManager->expects($this->at(1))
- ->method('getUserGroupIds')
- ->with($this->equalTo($user1))
- ->willReturn(['group1']);
$user2 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(1))
- ->method('get')
- ->with('user2')
- ->willReturn($user2);
- $this->groupManager->expects($this->at(2))
- ->method('getUserGroupIds')
- ->with($this->equalTo($user2))
- ->willReturn(['group2', 'group3']);
$user3 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(2))
- ->method('get')
- ->with('user3')
- ->willReturn($user3);
- $this->groupManager->expects($this->at(3))
+
+ $this->groupManager->expects($this->exactly(4))
->method('getUserGroupIds')
- ->with($this->equalTo($user3))
- ->willReturn(['group8', 'group9']);
+ ->withConsecutive(
+ [$this->equalTo($currentUser)],
+ [$this->equalTo($user1)],
+ [$this->equalTo($user2)],
+ [$this->equalTo($user3)]
+ )
+ ->willReturnOnConsecutiveCalls(
+ ['group1', 'group2', 'group3'],
+ ['group1'],
+ ['group2', 'group3'],
+ ['group8', 'group9']
+ );
+
+ $this->userManager->expects($this->exactly(3))
+ ->method('get')
+ ->withConsecutive(
+ ['user1'],
+ ['user2'],
+ ['user3']
+ )
+ ->willReturn($user1, $user2, $user3);
$this->contactsManager->expects($this->once())
->method('search')
@@ -409,13 +398,13 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_only_share_with_group_members', 'no', 'no'],
]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
+ /** @var IUser|MockObject $currentUser */
$currentUser = $this->createMock(IUser::class);
$currentUser->expects($this->exactly(2))
->method('getUID')
->willReturn('user001');
- $this->groupManager->expects($this->at(0))
+ $this->groupManager->expects($this->once())
->method('getUserGroupIds')
->with($this->equalTo($currentUser))
->willReturn(['group1', 'group2', 'group3']);
@@ -467,44 +456,39 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
+ /** @var IUser|MockObject $currentUser */
$currentUser = $this->createMock(IUser::class);
$currentUser->expects($this->exactly(2))
->method('getUID')
->willReturn('user001');
- $this->groupManager->expects($this->at(0))
- ->method('getUserGroupIds')
- ->with($this->equalTo($currentUser))
- ->willReturn(['group1', 'group2', 'group3']);
-
$user1 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(0))
- ->method('get')
- ->with('user1')
- ->willReturn($user1);
- $this->groupManager->expects($this->at(1))
- ->method('getUserGroupIds')
- ->with($this->equalTo($user1))
- ->willReturn(['group1']);
$user2 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(1))
- ->method('get')
- ->with('user2')
- ->willReturn($user2);
- $this->groupManager->expects($this->at(2))
- ->method('getUserGroupIds')
- ->with($this->equalTo($user2))
- ->willReturn(['group2', 'group3']);
$user3 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(2))
- ->method('get')
- ->with('user3')
- ->willReturn($user3);
- $this->groupManager->expects($this->at(3))
+
+ $this->groupManager->expects($this->exactly(4))
->method('getUserGroupIds')
- ->with($this->equalTo($user3))
- ->willReturn(['group8', 'group9']);
+ ->withConsecutive(
+ [$this->equalTo($currentUser)],
+ [$this->equalTo($user1)],
+ [$this->equalTo($user2)],
+ [$this->equalTo($user3)]
+ )
+ ->willReturnOnConsecutiveCalls(
+ ['group1', 'group2', 'group3'],
+ ['group1'],
+ ['group2', 'group3'],
+ ['group8', 'group9']
+ );
+
+ $this->userManager->expects($this->exactly(3))
+ ->method('get')
+ ->withConsecutive(
+ ['user1'],
+ ['user2'],
+ ['user3']
+ )
+ ->willReturnOnConsecutiveCalls($user1, $user2, $user3);
$this->knownUserService->method('isKnownToUser')
->willReturnMap([
@@ -553,26 +537,29 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_only_share_with_group_members', 'no', 'no'],
]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
+ /** @var IUser|MockObject $currentUser */
$currentUser = $this->createMock(IUser::class);
$currentUser->expects($this->exactly(2))
->method('getUID')
->willReturn('user001');
- $this->groupManager->expects($this->at(0))
- ->method('getUserGroupIds')
- ->with($this->equalTo($currentUser))
- ->willReturn(['group1', 'group2', 'group3']);
-
$user1 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(0))
+
+ $this->groupManager->expects($this->exactly(2))
+ ->method('getUserGroupIds')
+ ->withConsecutive(
+ [$this->equalTo($currentUser)],
+ [$this->equalTo($user1)]
+ )
+ ->willReturnOnConsecutiveCalls(
+ ['group1', 'group2', 'group3'],
+ ['group1']
+ );
+
+ $this->userManager->expects($this->once())
->method('get')
->with('user1')
->willReturn($user1);
- $this->groupManager->expects($this->at(1))
- ->method('getUserGroupIds')
- ->with($this->equalTo($user1))
- ->willReturn(['group1']);
$this->knownUserService->method('isKnownToUser')
->willReturnMap([
@@ -622,44 +609,39 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
+ /** @var IUser|MockObject $currentUser */
$currentUser = $this->createMock(IUser::class);
$currentUser->expects($this->exactly(2))
->method('getUID')
->willReturn('user001');
- $this->groupManager->expects($this->at(0))
- ->method('getUserGroupIds')
- ->with($this->equalTo($currentUser))
- ->willReturn(['group1', 'group2', 'group3']);
-
$user1 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(0))
- ->method('get')
- ->with('user1')
- ->willReturn($user1);
- $this->groupManager->expects($this->at(1))
- ->method('getUserGroupIds')
- ->with($this->equalTo($user1))
- ->willReturn(['group1']);
$user2 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(1))
- ->method('get')
- ->with('user2')
- ->willReturn($user2);
- $this->groupManager->expects($this->at(2))
- ->method('getUserGroupIds')
- ->with($this->equalTo($user2))
- ->willReturn(['group2', 'group3']);
$user3 = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(2))
- ->method('get')
- ->with('user3')
- ->willReturn($user3);
- $this->groupManager->expects($this->at(3))
+
+ $this->groupManager->expects($this->exactly(4))
->method('getUserGroupIds')
- ->with($this->equalTo($user3))
- ->willReturn(['group8', 'group9']);
+ ->withConsecutive(
+ [$this->equalTo($currentUser)],
+ [$this->equalTo($user1)],
+ [$this->equalTo($user2)],
+ [$this->equalTo($user3)]
+ )
+ ->willReturnOnConsecutiveCalls(
+ ['group1', 'group2', 'group3'],
+ ['group1'],
+ ['group2', 'group3'],
+ ['group8', 'group9']
+ );
+
+ $this->userManager->expects($this->exactly(3))
+ ->method('get')
+ ->withConsecutive(
+ ['user1'],
+ ['user2'],
+ ['user3']
+ )
+ ->willReturnOnConsecutiveCalls($user1, $user2, $user3);
$this->knownUserService->method('isKnownToUser')
->willReturnMap([
@@ -705,7 +687,7 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_restrict_user_enumeration_full_match', 'yes', 'yes'],
]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->contactsManager->expects($this->any())
->method('search')
@@ -792,7 +774,7 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_restrict_user_enumeration_full_match', 'yes', 'no'],
]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->contactsManager->expects($this->any())
->method('search')
@@ -869,11 +851,18 @@ class ContactsStoreTest extends TestCase {
}
public function testFindOneUser() {
- $this->config->expects($this->at(0))->method('getAppValue')
- ->with($this->equalTo('core'), $this->equalTo('shareapi_allow_share_dialog_user_enumeration'), $this->equalTo('yes'))
- ->willReturn('yes');
+ $this->config
+ ->method('getAppValue')
+ ->willReturnMap([
+ ['core', 'shareapi_allow_share_dialog_user_enumeration', 'yes', 'yes'],
+ ['core', 'shareapi_restrict_user_enumeration_to_group', 'no', 'no'],
+ ['core', 'shareapi_restrict_user_enumeration_to_phone', 'no', 'no'],
+ ['core', 'shareapi_restrict_user_enumeration_full_match', 'yes', 'yes'],
+ ['core', 'shareapi_exclude_groups', 'no', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members', 'no', 'no'],
+ ]);
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->contactsManager->expects($this->once())
->method('search')
@@ -904,7 +893,7 @@ class ContactsStoreTest extends TestCase {
}
public function testFindOneEMail() {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->contactsManager->expects($this->once())
->method('search')
@@ -935,7 +924,7 @@ class ContactsStoreTest extends TestCase {
}
public function testFindOneNotSupportedType() {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$entry = $this->contactsStore->findOne($user, 42, 'darren@roner.au');
@@ -944,7 +933,7 @@ class ContactsStoreTest extends TestCase {
}
public function testFindOneNoMatches() {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
+ /** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
$this->contactsManager->expects($this->once())
->method('search')
diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php
index 561afcf5dde..684edd9f25e 100644
--- a/tests/lib/Contacts/ContactsMenu/EntryTest.php
+++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php
@@ -29,9 +29,7 @@ use OC\Contacts\ContactsMenu\Entry;
use Test\TestCase;
class EntryTest extends TestCase {
-
- /** @var Entry */
- private $entry;
+ private Entry $entry;
protected function setUp(): void {
parent::setUp();
diff --git a/tests/lib/Contacts/ContactsMenu/ManagerTest.php b/tests/lib/Contacts/ContactsMenu/ManagerTest.php
index 2f5acf61644..ecd925faffa 100644
--- a/tests/lib/Contacts/ContactsMenu/ManagerTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ManagerTest.php
@@ -33,24 +33,24 @@ use OCP\Contacts\ContactsMenu\IEntry;
use OCP\Contacts\ContactsMenu\IProvider;
use OCP\IConfig;
use OCP\IUser;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class ManagerTest extends TestCase {
- /** @var ContactsStore|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var ContactsStore|MockObject */
private $contactsStore;
- /** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IAppManager|MockObject */
private $appManager;
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|MockObject */
private $config;
- /** @var ActionProviderStore|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var ActionProviderStore|MockObject */
private $actionProviderStore;
- /** @var Manager */
- private $manager;
+ private Manager $manager;
protected function setUp(): void {
parent::setUp();
@@ -63,7 +63,7 @@ class ManagerTest extends TestCase {
$this->manager = new Manager($this->contactsStore, $this->actionProviderStore, $this->appManager, $this->config);
}
- private function generateTestEntries() {
+ private function generateTestEntries(): array {
$entries = [];
foreach (range('Z', 'A') as $char) {
$entry = $this->createMock(IEntry::class);
@@ -81,14 +81,13 @@ class ManagerTest extends TestCase {
$entries = $this->generateTestEntries();
$provider = $this->createMock(IProvider::class);
- $this->config->expects($this->at(0))
+ $this->config->expects($this->exactly(2))
->method('getSystemValueInt')
- ->with('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT)
- ->willReturn(25);
- $this->config->expects($this->at(1))
- ->method('getSystemValueInt')
- ->with('sharing.minSearchStringLength', 0)
- ->willReturn(0);
+ ->withConsecutive(
+ ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT],
+ ['sharing.minSearchStringLength', 0]
+ )
+ ->willReturnOnConsecutiveCalls(25, 0);
$this->contactsStore->expects($this->once())
->method('getContacts')
->with($user, $filter)
@@ -119,14 +118,13 @@ class ManagerTest extends TestCase {
$entries = $this->generateTestEntries();
$provider = $this->createMock(IProvider::class);
- $this->config->expects($this->at(0))
- ->method('getSystemValueInt')
- ->with('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT)
- ->willReturn(3);
- $this->config->expects($this->at(1))
+ $this->config->expects($this->exactly(2))
->method('getSystemValueInt')
- ->with('sharing.minSearchStringLength', 0)
- ->willReturn(0);
+ ->withConsecutive(
+ ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT],
+ ['sharing.minSearchStringLength', 0]
+ )
+ ->willReturnOnConsecutiveCalls(3, 0);
$this->contactsStore->expects($this->once())
->method('getContacts')
->with($user, $filter)
@@ -156,14 +154,13 @@ class ManagerTest extends TestCase {
$user = $this->createMock(IUser::class);
$provider = $this->createMock(IProvider::class);
- $this->config->expects($this->at(0))
- ->method('getSystemValueInt')
- ->with('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT)
- ->willReturn(3);
- $this->config->expects($this->at(1))
+ $this->config->expects($this->exactly(2))
->method('getSystemValueInt')
- ->with('sharing.minSearchStringLength', 0)
- ->willReturn(4);
+ ->withConsecutive(
+ ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT],
+ ['sharing.minSearchStringLength', 0]
+ )
+ ->willReturnOnConsecutiveCalls(3, 4);
$this->appManager->expects($this->once())
->method('isEnabledForUser')
->with($this->equalTo('contacts'), $user)
diff --git a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
index c0052469aba..39deeeaecc9 100644
--- a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
+++ b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
@@ -29,18 +29,18 @@ use OCP\Contacts\ContactsMenu\IActionFactory;
use OCP\Contacts\ContactsMenu\IEntry;
use OCP\Contacts\ContactsMenu\ILinkAction;
use OCP\IURLGenerator;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class EMailproviderTest extends TestCase {
- /** @var IActionFactory|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IActionFactory|MockObject */
private $actionFactory;
- /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IURLGenerator|MockObject */
private $urlGenerator;
- /** @var EMailProvider */
- private $provider;
+ private EMailProvider $provider;
protected function setUp(): void {
parent::setUp();
@@ -80,7 +80,6 @@ class EMailproviderTest extends TestCase {
public function testProcessEmptyAddress() {
$entry = $this->createMock(IEntry::class);
- $action = $this->createMock(ILinkAction::class);
$iconUrl = 'https://example.com/img/actions/icon.svg';
$this->urlGenerator->expects($this->once())
->method('imagePath')