|
|
|
|
@ -35,10 +35,7 @@ use DateTime;
|
|
|
|
|
use DateTimeZone;
|
|
|
|
|
use OCA\DAV\CalDAV\CalDavBackend;
|
|
|
|
|
use OCA\DAV\CalDAV\Calendar;
|
|
|
|
|
use OCA\DAV\Events\CalendarCreatedEvent;
|
|
|
|
|
use OCA\DAV\Events\CalendarDeletedEvent;
|
|
|
|
|
use OCA\DAV\Events\CalendarObjectCreatedEvent;
|
|
|
|
|
use OCA\DAV\Events\CalendarUpdatedEvent;
|
|
|
|
|
use OCP\IConfig;
|
|
|
|
|
use OCP\IL10N;
|
|
|
|
|
use Sabre\DAV\Exception\NotFound;
|
|
|
|
|
@ -62,11 +59,8 @@ class CalDavBackendTest extends AbstractCalDavBackend {
|
|
|
|
|
'{DAV:}displayname' => 'Unit test',
|
|
|
|
|
'{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar used for unit testing'
|
|
|
|
|
]);
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarUpdatedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->updateCalendar($calendarId, $patch);
|
|
|
|
|
$patch->commit();
|
|
|
|
|
$this->assertEquals(1, $this->backend->getCalendarsForUserCount(self::UNIT_TEST_USER));
|
|
|
|
|
@ -77,11 +71,8 @@ class CalDavBackendTest extends AbstractCalDavBackend {
|
|
|
|
|
$this->assertEquals('User\'s displayname', $calendars[0]['{http://nextcloud.com/ns}owner-displayname']);
|
|
|
|
|
|
|
|
|
|
// delete the address book
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarDeletedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->deleteCalendar($calendars[0]['id'], true);
|
|
|
|
|
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
|
|
|
|
|
self::assertEmpty($calendars);
|
|
|
|
|
@ -190,11 +181,8 @@ END:VEVENT
|
|
|
|
|
END:VCALENDAR
|
|
|
|
|
EOD;
|
|
|
|
|
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarObjectCreatedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->createCalendarObject($calendarId, $uri, $calData);
|
|
|
|
|
|
|
|
|
|
/** @var IACL $child */
|
|
|
|
|
@ -238,11 +226,8 @@ END:VEVENT
|
|
|
|
|
END:VCALENDAR
|
|
|
|
|
EOD;
|
|
|
|
|
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarObjectCreatedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->createCalendarObject($calendarId, $uri, $calData);
|
|
|
|
|
|
|
|
|
|
// get all the cards
|
|
|
|
|
@ -278,21 +263,15 @@ DTEND;VALUE=DATE-TIME:20130912T140000Z
|
|
|
|
|
END:VEVENT
|
|
|
|
|
END:VCALENDAR
|
|
|
|
|
EOD;
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarUpdatedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->updateCalendarObject($calendarId, $uri, $calData);
|
|
|
|
|
$calendarObject = $this->backend->getCalendarObject($calendarId, $uri);
|
|
|
|
|
$this->assertEquals($calData, $calendarObject['calendardata']);
|
|
|
|
|
|
|
|
|
|
// delete the card
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarDeletedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->deleteCalendarObject($calendarId, $uri);
|
|
|
|
|
$calendarObjects = $this->backend->getCalendarObjects($calendarId);
|
|
|
|
|
$this->assertCount(0, $calendarObjects);
|
|
|
|
|
@ -385,25 +364,16 @@ END:VCALENDAR
|
|
|
|
|
EOD;
|
|
|
|
|
|
|
|
|
|
$uri0 = static::getUniqueID('card');
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarObjectCreatedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->createCalendarObject($calendarId, $uri0, $calData[0]);
|
|
|
|
|
$uri1 = static::getUniqueID('card');
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarObjectCreatedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->createCalendarObject($calendarId, $uri1, $calData[1]);
|
|
|
|
|
$uri2 = static::getUniqueID('card');
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarObjectCreatedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->createCalendarObject($calendarId, $uri2, $calData[2]);
|
|
|
|
|
|
|
|
|
|
// get all the cards
|
|
|
|
|
@ -430,23 +400,14 @@ EOD;
|
|
|
|
|
$this->assertEquals($calData[2], $calendarObjects[1]['calendardata']);
|
|
|
|
|
|
|
|
|
|
// delete the card
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarDeletedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->deleteCalendarObject($calendarId, $uri0);
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarDeletedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->deleteCalendarObject($calendarId, $uri1);
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarDeletedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
$this->backend->deleteCalendarObject($calendarId, $uri2);
|
|
|
|
|
$calendarObjects = $this->backend->getCalendarObjects($calendarId);
|
|
|
|
|
$this->assertCount(0, $calendarObjects);
|
|
|
|
|
@ -529,11 +490,8 @@ EOD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testPublications() {
|
|
|
|
|
$this->dispatcher->expects(self::once())
|
|
|
|
|
->method('dispatchTyped')
|
|
|
|
|
->with(self::callback(function ($event) {
|
|
|
|
|
return $event instanceof CalendarCreatedEvent;
|
|
|
|
|
}));
|
|
|
|
|
$this->dispatcher->expects(self::atLeastOnce())
|
|
|
|
|
->method('dispatchTyped');
|
|
|
|
|
|
|
|
|
|
$this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', []);
|
|
|
|
|
|
|
|
|
|
|