summaryrefslogtreecommitdiffstats
path: root/tests/lib/Contacts
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2021-10-14 08:19:40 +0000
committerChristopher Ng <chrng8@gmail.com>2021-10-19 04:59:35 +0000
commit309354852f12ae88d5eef05d311d6ebcba8ee762 (patch)
tree640c4e2394ba2a868d8d1cb6b5271fd1271bbdab /tests/lib/Contacts
parent7215148a242815a5064ce5d00a387c634dc936f3 (diff)
downloadnextcloud-server-309354852f12ae88d5eef05d311d6ebcba8ee762.tar.gz
nextcloud-server-309354852f12ae88d5eef05d311d6ebcba8ee762.zip
Profile backend
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'tests/lib/Contacts')
-rw-r--r--tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php31
-rw-r--r--tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php17
-rw-r--r--tests/lib/Contacts/ContactsMenu/EntryTest.php4
3 files changed, 38 insertions, 14 deletions
diff --git a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
index 301c55518f6..a3557d7cda6 100644
--- a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
@@ -27,6 +27,7 @@ namespace Tests\Contacts\ContactsMenu;
use OC\App\AppManager;
use OC\Contacts\ContactsMenu\ActionProviderStore;
use OC\Contacts\ContactsMenu\Providers\EMailProvider;
+use OC\Contacts\ContactsMenu\Providers\ProfileProvider;
use OCP\App\IAppManager;
use OCP\AppFramework\QueryException;
use OCP\Contacts\ContactsMenu\IProvider;
@@ -61,8 +62,9 @@ class ActionProviderStoreTest extends TestCase {
public function testGetProviders() {
$user = $this->createMock(IUser::class);
- $provider1 = $this->createMock(EMailProvider::class);
- $provider2 = $this->createMock(IProvider::class);
+ $provider1 = $this->createMock(ProfileProvider::class);
+ $provider2 = $this->createMock(EMailProvider::class);
+ $provider3 = $this->createMock(IProvider::class);
$this->appManager->expects($this->once())
->method('getEnabledAppsForUser')
@@ -76,22 +78,25 @@ class ActionProviderStoreTest extends TestCase {
'OCA\Contacts\Provider1',
],
]);
- $this->serverContainer->expects($this->exactly(2))
+ $this->serverContainer->expects($this->exactly(3))
->method('query')
->willReturnMap([
- [EMailProvider::class, true, $provider1],
- ['OCA\Contacts\Provider1', true, $provider2]
+ [ProfileProvider::class, true, $provider1],
+ [EMailProvider::class, true, $provider2],
+ ['OCA\Contacts\Provider1', true, $provider3]
]);
$providers = $this->actionProviderStore->getProviders($user);
- $this->assertCount(2, $providers);
- $this->assertInstanceOf(EMailProvider::class, $providers[0]);
+ $this->assertCount(3, $providers);
+ $this->assertInstanceOf(ProfileProvider::class, $providers[0]);
+ $this->assertInstanceOf(EMailProvider::class, $providers[1]);
}
public function testGetProvidersOfAppWithIncompleInfo() {
$user = $this->createMock(IUser::class);
- $provider1 = $this->createMock(EMailProvider::class);
+ $provider1 = $this->createMock(ProfileProvider::class);
+ $provider2 = $this->createMock(EMailProvider::class);
$this->appManager->expects($this->once())
->method('getEnabledAppsForUser')
@@ -101,16 +106,18 @@ class ActionProviderStoreTest extends TestCase {
->method('getAppInfo')
->with('contacts')
->willReturn([/* Empty info.xml */]);
- $this->serverContainer->expects($this->once())
+ $this->serverContainer->expects($this->exactly(2))
->method('query')
->willReturnMap([
- [EMailProvider::class, true, $provider1],
+ [ProfileProvider::class, true, $provider1],
+ [EMailProvider::class, true, $provider2],
]);
$providers = $this->actionProviderStore->getProviders($user);
- $this->assertCount(1, $providers);
- $this->assertInstanceOf(EMailProvider::class, $providers[0]);
+ $this->assertCount(2, $providers);
+ $this->assertInstanceOf(ProfileProvider::class, $providers[0]);
+ $this->assertInstanceOf(EMailProvider::class, $providers[1]);
}
diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
index ad201d86a2a..13cc7575f43 100644
--- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
@@ -27,42 +27,57 @@ namespace Tests\Contacts\ContactsMenu;
use OC\Contacts\ContactsMenu\ContactsStore;
use OC\KnownUser\KnownUserService;
+use OCP\Accounts\IAccountManager;
use OCP\Contacts\IManager;
use OCP\IConfig;
use OCP\IGroupManager;
+use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\L10N\IFactory as IL10NFactory;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class ContactsStoreTest extends TestCase {
+ /** @var IAccountManager */
+ private $accountManager;
/** @var ContactsStore */
private $contactsStore;
/** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
private $contactsManager;
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
private $userManager;
+ /** @var IURLGenerator */
+ private $urlGenerator;
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
private $groupManager;
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
private $config;
/** @var KnownUserService|MockObject */
private $knownUserService;
+ /** @var IL10NFactory */
+ private $l10nFactory;
protected function setUp(): void {
parent::setUp();
+ $this->accountManager = $this->createMock(IAccountManager::class);
$this->contactsManager = $this->createMock(IManager::class);
$this->userManager = $this->createMock(IUserManager::class);
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->config = $this->createMock(IConfig::class);
$this->knownUserService = $this->createMock(KnownUserService::class);
+ $this->l10nFactory = $this->createMock(IL10NFactory::class);
$this->contactsStore = new ContactsStore(
+ $this->accountManager,
$this->contactsManager,
$this->config,
$this->userManager,
+ $this->urlGenerator,
$this->groupManager,
- $this->knownUserService
+ $this->knownUserService,
+ $this->l10nFactory
);
}
diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php
index bce1865f94a..561afcf5dde 100644
--- a/tests/lib/Contacts/ContactsMenu/EntryTest.php
+++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php
@@ -102,7 +102,9 @@ class EntryTest extends TestCase {
'actions' => [],
'lastMessage' => '',
'avatar' => null,
- 'emailAddresses' => ['user@example.com']
+ 'emailAddresses' => ['user@example.com'],
+ 'profileTitle' => null,
+ 'profileUrl' => null,
];
$this->entry->setId(123);