1
0

ContactsManagerTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCA\DAV\Tests\unit\CardDAV;
  27. use OCA\DAV\CardDAV\CardDavBackend;
  28. use OCA\DAV\CardDAV\ContactsManager;
  29. use OCP\Contacts\IManager;
  30. use OCP\IL10N;
  31. use OCP\IURLGenerator;
  32. use Test\TestCase;
  33. class ContactsManagerTest extends TestCase {
  34. public function test(): void {
  35. /** @var IManager | \PHPUnit\Framework\MockObject\MockObject $cm */
  36. $cm = $this->getMockBuilder(IManager::class)->disableOriginalConstructor()->getMock();
  37. $cm->expects($this->exactly(2))->method('registerAddressBook');
  38. $urlGenerator = $this->getMockBuilder(IURLGenerator::class)->disableOriginalConstructor()->getMock();
  39. /** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $backEnd */
  40. $backEnd = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
  41. $backEnd->method('getAddressBooksForUser')->willReturn([
  42. ['{DAV:}displayname' => 'Test address book', 'uri' => 'default'],
  43. ]);
  44. $l = $this->createMock(IL10N::class);
  45. $app = new ContactsManager($backEnd, $l);
  46. $app->setupContactsProvider($cm, 'user01', $urlGenerator);
  47. }
  48. }