summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-08 15:19:38 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-08 15:19:38 +0200
commit6f3eeeeb36d86b352d396f730fbc6a8d1e8ca160 (patch)
tree62f29d34ebbd891a56ffc9c0a64eba3d5f36394b /apps/dav/tests/unit
parent88a366b3143b70953224f96c500cf725270065b4 (diff)
parentc8d6a9594ab7c0525cc9485b394547ae960d8f34 (diff)
downloadnextcloud-server-6f3eeeeb36d86b352d396f730fbc6a8d1e8ca160.tar.gz
nextcloud-server-6f3eeeeb36d86b352d396f730fbc6a8d1e8ca160.zip
Merge pull request #23510 from owncloud/birthdays-on-shared-addressbooks
Propagate birthdays of shared addressbooks to the sharee's birthday c…
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r--apps/dav/tests/unit/carddav/birthdayservicetest.php49
1 files changed, 47 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/carddav/birthdayservicetest.php b/apps/dav/tests/unit/carddav/birthdayservicetest.php
index 2efb3c09aea..e15edd16c62 100644
--- a/apps/dav/tests/unit/carddav/birthdayservicetest.php
+++ b/apps/dav/tests/unit/carddav/birthdayservicetest.php
@@ -24,6 +24,7 @@ namespace OCA\DAV\Tests\Unit\CardDAV;
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CardDAV\CardDavBackend;
+use OCA\DAV\DAV\GroupPrincipalBackend;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Reader;
use Test\TestCase;
@@ -36,14 +37,17 @@ class BirthdayServiceTest extends TestCase {
private $calDav;
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject */
private $cardDav;
+ /** @var GroupPrincipalBackend | \PHPUnit_Framework_MockObject_MockObject */
+ private $groupPrincialBackend;
public function setUp() {
parent::setUp();
$this->calDav = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
$this->cardDav = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock();
+ $this->groupPrincialBackend = $this->getMockBuilder('OCA\DAV\DAV\GroupPrincipalBackend')->disableOriginalConstructor()->getMock();
- $this->service = new BirthdayService($this->calDav, $this->cardDav);
+ $this->service = new BirthdayService($this->calDav, $this->cardDav, $this->groupPrincialBackend);
}
/**
@@ -77,6 +81,7 @@ class BirthdayServiceTest extends TestCase {
'id' => 1234
]);
$this->calDav->expects($this->once())->method('deleteCalendarObject')->with(1234, 'default-gump.vcf.ics');
+ $this->cardDav->expects($this->once())->method('getShares')->willReturn([]);
$this->service->onCardDeleted(666, 'gump.vcf');
}
@@ -96,10 +101,11 @@ class BirthdayServiceTest extends TestCase {
->willReturn([
'id' => 1234
]);
+ $this->cardDav->expects($this->once())->method('getShares')->willReturn([]);
/** @var BirthdayService | \PHPUnit_Framework_MockObject_MockObject $service */
$service = $this->getMock('\OCA\DAV\CalDAV\BirthdayService',
- ['buildBirthdayFromContact', 'birthdayEvenChanged'], [$this->calDav, $this->cardDav]);
+ ['buildBirthdayFromContact', 'birthdayEvenChanged'], [$this->calDav, $this->cardDav, $this->groupPrincialBackend]);
if ($expectedOp === 'delete') {
$this->calDav->expects($this->once())->method('getCalendarObject')->willReturn('');
@@ -132,6 +138,45 @@ class BirthdayServiceTest extends TestCase {
$this->assertEquals($expected, $this->service->birthdayEvenChanged($old, $new));
}
+ public function testGetAllAffectedPrincipals() {
+ $this->cardDav->expects($this->once())->method('getShares')->willReturn([
+ [
+ '{http://owncloud.org/ns}group-share' => false,
+ '{http://owncloud.org/ns}principal' => 'principals/users/user01'
+ ],
+ [
+ '{http://owncloud.org/ns}group-share' => false,
+ '{http://owncloud.org/ns}principal' => 'principals/users/user01'
+ ],
+ [
+ '{http://owncloud.org/ns}group-share' => false,
+ '{http://owncloud.org/ns}principal' => 'principals/users/user02'
+ ],
+ [
+ '{http://owncloud.org/ns}group-share' => true,
+ '{http://owncloud.org/ns}principal' => 'principals/groups/users'
+ ],
+ ]);
+ $this->groupPrincialBackend->expects($this->once())->method('getGroupMemberSet')
+ ->willReturn([
+ [
+ 'uri' => 'principals/users/user01',
+ ],
+ [
+ 'uri' => 'principals/users/user02',
+ ],
+ [
+ 'uri' => 'principals/users/user03',
+ ],
+ ]);
+ $users = $this->invokePrivate($this->service, 'getAllAffectedPrincipals', [6666]);
+ $this->assertEquals([
+ 'principals/users/user01',
+ 'principals/users/user02',
+ 'principals/users/user03'
+ ], $users);
+ }
+
public function providesBirthday() {
return [
[true,