summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-21 12:34:20 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-21 12:34:20 +0200
commit38c729686728c743f5acb53a83b1d869dc429610 (patch)
tree5adcaf0fbe064feb6b5d60a37d1e93058e2f1843 /apps/dav/tests
parent93649d6fe8e2e079dec7fa3bd34f8d8c2306f055 (diff)
downloadnextcloud-server-38c729686728c743f5acb53a83b1d869dc429610.tar.gz
nextcloud-server-38c729686728c743f5acb53a83b1d869dc429610.zip
Personal calendar should be generated even if the birthday calendar already exists - fixes #24082
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/unit/dav/HookManagerTest.php81
1 files changed, 81 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/dav/HookManagerTest.php b/apps/dav/tests/unit/dav/HookManagerTest.php
index bec4c240ce8..5c36d0d785c 100644
--- a/apps/dav/tests/unit/dav/HookManagerTest.php
+++ b/apps/dav/tests/unit/dav/HookManagerTest.php
@@ -22,6 +22,7 @@
namespace OCA\DAV\Tests\Unit\DAV;
+use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\CardDAV\SyncService;
@@ -68,4 +69,84 @@ class HookManagerTest extends TestCase {
$hm = new HookManager($userManager, $syncService, $cal, $card);
$hm->postLogin(['uid' => 'newUser']);
}
+
+ public function testWithExisting() {
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $user->expects($this->once())->method('getUID')->willReturn('newUser');
+
+ /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject $userManager */
+ $userManager = $this->getMockBuilder('\OCP\IUserManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $userManager->expects($this->once())->method('get')->willReturn($user);
+
+ /** @var SyncService | \PHPUnit_Framework_MockObject_MockObject $syncService */
+ $syncService = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ /** @var CalDavBackend | \PHPUnit_Framework_MockObject_MockObject $cal */
+ $cal = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $cal->expects($this->once())->method('getCalendarsForUser')->willReturn([
+ ['uri' => 'my-events']
+ ]);
+ $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->never())->method('createAddressBook');
+
+ $hm = new HookManager($userManager, $syncService, $cal, $card);
+ $hm->postLogin(['uid' => 'newUser']);
+ }
+
+ public function testWithBirthdayCalendar() {
+ $user = $this->getMockBuilder('\OCP\IUser')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $user->expects($this->once())->method('getUID')->willReturn('newUser');
+
+ /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject $userManager */
+ $userManager = $this->getMockBuilder('\OCP\IUserManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $userManager->expects($this->once())->method('get')->willReturn($user);
+
+ /** @var SyncService | \PHPUnit_Framework_MockObject_MockObject $syncService */
+ $syncService = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ /** @var CalDavBackend | \PHPUnit_Framework_MockObject_MockObject $cal */
+ $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('createCalendar')->with(
+ 'principals/users/newUser',
+ 'personal', ['{DAV:}displayname' => 'Personal']);
+
+ /** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $card */
+ $card = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $card->expects($this->once())->method('getAddressBooksForUser')->willReturn([]);
+ $card->expects($this->once())->method('createAddressBook')->with(
+ 'principals/users/newUser',
+ 'contacts', ['{DAV:}displayname' => 'Contacts']);
+
+ $hm = new HookManager($userManager, $syncService, $cal, $card);
+ $hm->postLogin(['uid' => 'newUser']);
+ }
}