diff options
author | redmatrix <git@macgirvin.com> | 2016-05-10 17:26:44 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-05-10 17:26:44 -0700 |
commit | 0b02a6d123b2014705998c94ddf3d460948d3eac (patch) | |
tree | 78ff2cab9944a4f5ab3f80ec93cbe1120de90bb2 /vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php | |
parent | 40b5b6e9d2da7ab65c8b4d38cdceac83a4d78deb (diff) | |
download | volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.gz volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.bz2 volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.zip |
initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import)
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php | 184 |
1 files changed, 137 insertions, 47 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php index 04fb16df5..7f642efc9 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php @@ -2,37 +2,92 @@ namespace Sabre\CalDAV\Backend; +use + Sabre\DAV\PropPatch; + class AbstractTest extends \PHPUnit_Framework_TestCase { function testUpdateCalendar() { $abstract = new AbstractMock(); - $this->assertEquals(false, $abstract->updateCalendar('randomid', array('{DAV:}displayname' => 'anything'))); + $propPatch = new PropPatch(['{DAV:}displayname' => 'anything']); + + $abstract->updateCalendar('randomid', $propPatch); + $result = $propPatch->commit(); + + $this->assertFalse($result); } function testCalendarQuery() { $abstract = new AbstractMock(); - $filters = array( - 'name' => 'VCALENDAR', - 'comp-filters' => array( - array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filters = [ + 'name' => 'VCALENDAR', + 'comp-filters' => [ + [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, - ), - ), - 'prop-filters' => array(), + 'time-range' => null, + ], + ], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, + ]; + + $this->assertEquals([ + 'event1.ics', + ], $abstract->calendarQuery(1, $filters)); + + } + + function testGetCalendarObjectByUID() { + + $abstract = new AbstractMock(); + $this->assertNull( + $abstract->getCalendarObjectByUID('principal1', 'zim') + ); + $this->assertEquals( + 'cal1/event1.ics', + $abstract->getCalendarObjectByUID('principal1', 'foo') + ); + $this->assertNull( + $abstract->getCalendarObjectByUID('principal3', 'foo') ); + $this->assertNull( + $abstract->getCalendarObjectByUID('principal1', 'shared') + ); + + } - $this->assertEquals(array( + function testGetMultipleCalendarObjects() { + + $abstract = new AbstractMock(); + $result = $abstract->getMultipleCalendarObjects(1, [ 'event1.ics', - ), $abstract->calendarQuery(1, $filters)); + 'task1.ics', + ]); + + $expected = [ + [ + 'id' => 1, + 'calendarid' => 1, + 'uri' => 'event1.ics', + 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", + ], + [ + 'id' => 2, + 'calendarid' => 1, + 'uri' => 'task1.ics', + 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", + ], + ]; + + $this->assertEquals($expected, $result); + } @@ -40,49 +95,84 @@ class AbstractTest extends \PHPUnit_Framework_TestCase { class AbstractMock extends AbstractBackend { - function getCalendarsForUser($principalUri) { } - function createCalendar($principalUri,$calendarUri,array $properties) { } + function getCalendarsForUser($principalUri) { + + return [ + [ + 'id' => 1, + 'principaluri' => 'principal1', + 'uri' => 'cal1', + ], + [ + 'id' => 2, + 'principaluri' => 'principal1', + '{http://sabredav.org/ns}owner-principal' => 'principal2', + 'uri' => 'cal1', + ], + ]; + + } + function createCalendar($principalUri, $calendarUri, array $properties) { } function deleteCalendar($calendarId) { } - function getCalendarObjects($calendarId) { - - return array( - array( - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', - ), - array( - 'id' => 2, - 'calendarid' => 1, - 'uri' => 'task1.ics', - ), - ); + function getCalendarObjects($calendarId) { + + switch ($calendarId) { + case 1: + return [ + [ + 'id' => 1, + 'calendarid' => 1, + 'uri' => 'event1.ics', + ], + [ + 'id' => 2, + 'calendarid' => 1, + 'uri' => 'task1.ics', + ], + ]; + case 2: + return [ + [ + 'id' => 3, + 'calendarid' => 2, + 'uri' => 'shared-event.ics', + ] + ]; + } } - function getCalendarObject($calendarId,$objectUri) { - switch($objectUri) { + function getCalendarObject($calendarId, $objectUri) { + + switch ($objectUri) { case 'event1.ics' : - return array( - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', - 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", - ); + return [ + 'id' => 1, + 'calendarid' => 1, + 'uri' => 'event1.ics', + 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", + ]; case 'task1.ics' : - return array( - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', + return [ + 'id' => 2, + 'calendarid' => 1, + 'uri' => 'task1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", - ); + ]; + case 'shared-event.ics' : + return [ + 'id' => 3, + 'calendarid' => 2, + 'uri' => 'event1.ics', + 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:shared\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", + ]; } } - function createCalendarObject($calendarId,$objectUri,$calendarData) { } - function updateCalendarObject($calendarId,$objectUri,$calendarData) { } - function deleteCalendarObject($calendarId,$objectUri) { } + function createCalendarObject($calendarId, $objectUri, $calendarData) { } + function updateCalendarObject($calendarId, $objectUri, $calendarData) { } + function deleteCalendarObject($calendarId, $objectUri) { } } |