summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2016-08-30 15:11:33 +0200
committerRobin Appelman <robin@icewind.nl>2016-08-31 15:08:29 +0200
commit344945bfe9c6d446742fb1d8020862c3c474776a (patch)
tree5e5defb625b0845bea479ec79156bde7db23db90 /apps/dav/tests/unit
parenta82d4a56fb5bc484114c702bcd63e6278830bd5d (diff)
downloadnextcloud-server-344945bfe9c6d446742fb1d8020862c3c474776a.tar.gz
nextcloud-server-344945bfe9c6d446742fb1d8020862c3c474776a.zip
more efficient check if addressbook and calendar exists for user
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r--apps/dav/tests/unit/CalDAV/CalDavBackendTest.php1
-rw-r--r--apps/dav/tests/unit/CardDAV/CardDavBackendTest.php1
-rw-r--r--apps/dav/tests/unit/DAV/HookManagerTest.php18
3 files changed, 8 insertions, 12 deletions
diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
index 48434b2512d..1a5673161de 100644
--- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
@@ -53,6 +53,7 @@ class CalDavBackendTest extends AbstractCalDavBackendTest {
]);
$this->backend->updateCalendar($calendarId, $patch);
$patch->commit();
+ $this->assertEquals(1, $this->backend->getCalendarsForUserCount(self::UNIT_TEST_USER));
$books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertEquals(1, count($books));
$this->assertEquals('Unit test', $books[0]['{DAV:}displayname']);
diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
index bbeadf81277..cf5972f79bf 100644
--- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
+++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
@@ -118,6 +118,7 @@ class CardDavBackendTest extends TestCase {
// create a new address book
$this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []);
+ $this->assertEquals(1, $this->backend->getAddressBooksForUserCount(self::UNIT_TEST_USER));
$books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
$this->assertEquals(1, count($books));
$this->assertEquals('Example', $books[0]['{DAV:}displayname']);
diff --git a/apps/dav/tests/unit/DAV/HookManagerTest.php b/apps/dav/tests/unit/DAV/HookManagerTest.php
index 5e6e65e59b4..0db66bf76c1 100644
--- a/apps/dav/tests/unit/DAV/HookManagerTest.php
+++ b/apps/dav/tests/unit/DAV/HookManagerTest.php
@@ -53,7 +53,7 @@ class HookManagerTest extends TestCase {
$cal = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')
->disableOriginalConstructor()
->getMock();
- $cal->expects($this->once())->method('getCalendarsForUser')->willReturn([]);
+ $cal->expects($this->once())->method('getCalendarsForUserCount')->willReturn(0);
$cal->expects($this->once())->method('createCalendar')->with(
'principals/users/newUser',
'personal', ['{DAV:}displayname' => 'Personal']);
@@ -62,7 +62,7 @@ class HookManagerTest extends TestCase {
$card = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
->disableOriginalConstructor()
->getMock();
- $card->expects($this->once())->method('getAddressBooksForUser')->willReturn([]);
+ $card->expects($this->once())->method('getAddressBooksForUserCount')->willReturn(0);
$card->expects($this->once())->method('createAddressBook')->with(
'principals/users/newUser',
'contacts', ['{DAV:}displayname' => 'Contacts']);
@@ -92,18 +92,14 @@ class HookManagerTest extends TestCase {
$cal = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')
->disableOriginalConstructor()
->getMock();
- $cal->expects($this->once())->method('getCalendarsForUser')->willReturn([
- ['uri' => 'my-events']
- ]);
+ $cal->expects($this->once())->method('getCalendarsForUserCount')->willReturn(1);
$cal->expects($this->never())->method('createCalendar');
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $card */
$card = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
->disableOriginalConstructor()
->getMock();
- $card->expects($this->once())->method('getAddressBooksForUser')->willReturn([
- ['uri' => 'my-contacts']
- ]);
+ $card->expects($this->once())->method('getAddressBooksForUserCount')->willReturn(1);
$card->expects($this->never())->method('createAddressBook');
$hm = new HookManager($userManager, $syncService, $cal, $card);
@@ -131,9 +127,7 @@ class HookManagerTest extends TestCase {
$cal = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')
->disableOriginalConstructor()
->getMock();
- $cal->expects($this->once())->method('getCalendarsForUser')->willReturn([
- ['uri' => BirthdayService::BIRTHDAY_CALENDAR_URI]
- ]);
+ $cal->expects($this->once())->method('getCalendarsForUserCount')->willReturn(0);
$cal->expects($this->once())->method('createCalendar')->with(
'principals/users/newUser',
'personal', ['{DAV:}displayname' => 'Personal']);
@@ -142,7 +136,7 @@ class HookManagerTest extends TestCase {
$card = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
->disableOriginalConstructor()
->getMock();
- $card->expects($this->once())->method('getAddressBooksForUser')->willReturn([]);
+ $card->expects($this->once())->method('getAddressBooksForUserCount')->willReturn(0);
$card->expects($this->once())->method('createAddressBook')->with(
'principals/users/newUser',
'contacts', ['{DAV:}displayname' => 'Contacts']);