From fbfca80f42ae0a7759bd71c3b2a38a15738af314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Wed, 13 Jan 2016 11:55:06 +0100 Subject: [PATCH] Add test for ensureSystemAddressBookExists --- apps/dav/tests/unit/carddav/syncservicetest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/dav/tests/unit/carddav/syncservicetest.php b/apps/dav/tests/unit/carddav/syncservicetest.php index 338ac2bbe1..d66383461b 100644 --- a/apps/dav/tests/unit/carddav/syncservicetest.php +++ b/apps/dav/tests/unit/carddav/syncservicetest.php @@ -57,6 +57,17 @@ class SyncServiceTest extends TestCase { $this->assertEquals('sync-token-1', $return); } + public function testEnsureSystemAddressBookExists() { + /** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backend */ + $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDAVBackend')->disableOriginalConstructor()->getMock(); + $backend->expects($this->exactly(1))->method('createAddressBook'); + $backend->expects($this->at(0))->method('getAddressBooksByUri')->willReturn(null); + $backend->expects($this->at(1))->method('getAddressBooksByUri')->willReturn([]); + + $ss = new SyncService($backend); + $book = $ss->ensureSystemAddressBookExists('principals/users/adam', 'contacts', []); + } + /** * @param int $createCount * @param int $updateCount