1
0

ContactsManagerTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\DAV\Tests\unit\CardDAV;
  8. use OCA\DAV\CardDAV\CardDavBackend;
  9. use OCA\DAV\CardDAV\ContactsManager;
  10. use OCP\Contacts\IManager;
  11. use OCP\IL10N;
  12. use OCP\IURLGenerator;
  13. use Test\TestCase;
  14. class ContactsManagerTest extends TestCase {
  15. public function test(): void {
  16. /** @var IManager | \PHPUnit\Framework\MockObject\MockObject $cm */
  17. $cm = $this->getMockBuilder(IManager::class)->disableOriginalConstructor()->getMock();
  18. $cm->expects($this->exactly(2))->method('registerAddressBook');
  19. $urlGenerator = $this->getMockBuilder(IURLGenerator::class)->disableOriginalConstructor()->getMock();
  20. /** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $backEnd */
  21. $backEnd = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
  22. $backEnd->method('getAddressBooksForUser')->willReturn([
  23. ['{DAV:}displayname' => 'Test address book', 'uri' => 'default'],
  24. ]);
  25. $l = $this->createMock(IL10N::class);
  26. $app = new ContactsManager($backEnd, $l);
  27. $app->setupContactsProvider($cm, 'user01', $urlGenerator);
  28. }
  29. }