diff options
Diffstat (limited to 'apps/dav/tests/unit/CalDAV/CalendarTest.php')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/CalendarTest.php | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/apps/dav/tests/unit/CalDAV/CalendarTest.php b/apps/dav/tests/unit/CalDAV/CalendarTest.php index 99ad640c447..dbdbf0dbafd 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarTest.php @@ -29,6 +29,7 @@ namespace OCA\DAV\Tests\unit\CalDAV; use OCA\DAV\CalDAV\BirthdayService; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\Calendar; +use OCP\IConfig; use OCP\IL10N; use Sabre\DAV\PropPatch; use Sabre\VObject\Reader; @@ -39,10 +40,14 @@ class CalendarTest extends TestCase { /** @var IL10N */ protected $l10n; + /** @var IConfig */ + protected $config; + public function setUp() { parent::setUp(); $this->l10n = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); + $this->config = $this->createMock(IConfig::class); $this->l10n ->expects($this->any()) ->method('t') @@ -64,7 +69,7 @@ class CalendarTest extends TestCase { 'id' => 666, 'uri' => 'cal', ]; - $c = new Calendar($backend, $calendarInfo, $this->l10n); + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config); $c->delete(); } @@ -84,7 +89,7 @@ class CalendarTest extends TestCase { 'id' => 666, 'uri' => 'cal', ]; - $c = new Calendar($backend, $calendarInfo, $this->l10n); + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config); $c->delete(); } @@ -94,6 +99,8 @@ class CalendarTest extends TestCase { $backend->expects($this->never())->method('updateShares'); $backend->expects($this->never())->method('getShares'); + $this->config->expects($this->never())->method('setUserValue'); + $backend->expects($this->once())->method('deleteCalendar') ->with(666); @@ -103,7 +110,28 @@ class CalendarTest extends TestCase { 'id' => 666, 'uri' => 'cal', ]; - $c = new Calendar($backend, $calendarInfo, $this->l10n); + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config); + $c->delete(); + } + + public function testDeleteBirthdayCalendar() { + /** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */ + $backend = $this->createMock(CalDavBackend::class); + $backend->expects($this->once())->method('deleteCalendar') + ->with(666); + + $this->config->expects($this->once()) + ->method('setUserValue') + ->with('user1', 'dav', 'generateBirthdayCalendar', 'no'); + + $calendarInfo = [ + '{http://owncloud.org/ns}owner-principal' => 'principals/users/user1', + 'principaluri' => 'principals/users/user1', + 'id' => 666, + 'uri' => 'contact_birthdays', + ]; + + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config); $c->delete(); } @@ -146,7 +174,7 @@ class CalendarTest extends TestCase { 'id' => 666, 'uri' => 'default' ]; - $c = new Calendar($backend, $calendarInfo, $this->l10n); + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config); $propPatch = new PropPatch($mutations); if (!$shared) { @@ -176,7 +204,7 @@ class CalendarTest extends TestCase { if ($hasOwnerSet) { $calendarInfo['{http://owncloud.org/ns}owner-principal'] = 'user1'; } - $c = new Calendar($backend, $calendarInfo, $this->l10n); + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config); $acl = $c->getACL(); $childAcl = $c->getChildACL(); @@ -271,7 +299,7 @@ class CalendarTest extends TestCase { $calendarInfo['{http://owncloud.org/ns}owner-principal'] = 'user1'; } - $c = new Calendar($backend, $calendarInfo, $this->l10n); + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config); $children = $c->getChildren(); $this->assertEquals($expectedChildren, count($children)); $children = $c->getMultipleChildren(['event-0', 'event-1', 'event-2']); @@ -355,7 +383,7 @@ EOD; 'id' => 666, 'uri' => 'cal', ]; - $c = new Calendar($backend, $calendarInfo, $this->l10n); + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config); $this->assertEquals(count($c->getChildren()), $expectedChildren); @@ -531,9 +559,9 @@ EOD; 'uri' => 'cal', ]; - $ownerCalendar = new Calendar($backend, $calendarInfoOwner, $this->l10n); - $rwCalendar = new Calendar($backend, $calendarInfoSharedRW, $this->l10n); - $roCalendar = new Calendar($backend, $calendarInfoSharedRO, $this->l10n); + $ownerCalendar = new Calendar($backend, $calendarInfoOwner, $this->l10n, $this->config); + $rwCalendar = new Calendar($backend, $calendarInfoSharedRW, $this->l10n, $this->config); + $roCalendar = new Calendar($backend, $calendarInfoSharedRO, $this->l10n, $this->config); $this->assertEquals(count($ownerCalendar->getChildren()), 2); $this->assertEquals(count($rwCalendar->getChildren()), 2); |