aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV/Backend
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CalDAV/Backend')
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php550
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php88
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php400
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php39
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php25
5 files changed, 1102 insertions, 0 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php
new file mode 100644
index 000000000..2224f0b63
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php
@@ -0,0 +1,550 @@
+<?php
+
+namespace Sabre\CalDAV\Backend;
+use Sabre\CalDAV;
+use Sabre\DAV;
+
+abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
+
+ protected $pdo;
+
+ function testConstruct() {
+
+ $backend = new PDO($this->pdo);
+ $this->assertTrue($backend instanceof PDO);
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testGetCalendarsForUserNoCalendars() {
+
+ $backend = new PDO($this->pdo);
+ $calendars = $backend->getCalendarsForUser('principals/user2');
+ $this->assertEquals(array(),$calendars);
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testCreateCalendarAndFetch() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array(
+ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT')),
+ '{DAV:}displayname' => 'Hello!',
+ '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Property\ScheduleCalendarTransp('transparent'),
+ ));
+ $calendars = $backend->getCalendarsForUser('principals/user2');
+
+ $elementCheck = array(
+ 'id' => $returnedId,
+ 'uri' => 'somerandomid',
+ '{DAV:}displayname' => 'Hello!',
+ '{urn:ietf:params:xml:ns:caldav}calendar-description' => '',
+ '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Property\ScheduleCalendarTransp('transparent'),
+ );
+
+ $this->assertInternalType('array',$calendars);
+ $this->assertEquals(1,count($calendars));
+
+ foreach($elementCheck as $name=>$value) {
+
+ $this->assertArrayHasKey($name, $calendars[0]);
+ $this->assertEquals($value,$calendars[0][$name]);
+
+ }
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testUpdateCalendarAndFetch() {
+
+ $backend = new PDO($this->pdo);
+
+ //Creating a new calendar
+ $newId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ // Updating the calendar
+ $result = $backend->updateCalendar($newId,array(
+ '{DAV:}displayname' => 'myCalendar',
+ '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Property\ScheduleCalendarTransp('transparent'),
+ ));
+
+ // Verifying the result of the update
+ $this->assertEquals(true, $result);
+
+ // Fetching all calendars from this user
+ $calendars = $backend->getCalendarsForUser('principals/user2');
+
+ // Checking if all the information is still correct
+ $elementCheck = array(
+ 'id' => $newId,
+ 'uri' => 'somerandomid',
+ '{DAV:}displayname' => 'myCalendar',
+ '{urn:ietf:params:xml:ns:caldav}calendar-description' => '',
+ '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => '',
+ '{http://calendarserver.org/ns/}getctag' => '2',
+ '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Property\ScheduleCalendarTransp('transparent'),
+ );
+
+ $this->assertInternalType('array',$calendars);
+ $this->assertEquals(1,count($calendars));
+
+ foreach($elementCheck as $name=>$value) {
+
+ $this->assertArrayHasKey($name, $calendars[0]);
+ $this->assertEquals($value,$calendars[0][$name]);
+
+ }
+
+ }
+
+ /**
+ * @depends testUpdateCalendarAndFetch
+ */
+ function testUpdateCalendarUnknownProperty() {
+
+ $backend = new PDO($this->pdo);
+
+ //Creating a new calendar
+ $newId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ // Updating the calendar
+ $result = $backend->updateCalendar($newId,array(
+ '{DAV:}displayname' => 'myCalendar',
+ '{DAV:}yourmom' => 'wittycomment',
+ ));
+
+ // Verifying the result of the update
+ $this->assertEquals(array(
+ '403' => array('{DAV:}yourmom' => null),
+ '424' => array('{DAV:}displayname' => null),
+ ), $result);
+
+ }
+
+ /**
+ * @depends testCreateCalendarAndFetch
+ */
+ function testDeleteCalendar() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array(
+ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT')),
+ '{DAV:}displayname' => 'Hello!',
+ ));
+
+ $backend->deleteCalendar($returnedId);
+
+ $calendars = $backend->getCalendarsForUser('principals/user2');
+ $this->assertEquals(array(),$calendars);
+
+ }
+
+ /**
+ * @depends testCreateCalendarAndFetch
+ * @expectedException \Sabre\DAV\Exception
+ */
+ function testCreateCalendarIncorrectComponentSet() {;
+
+ $backend = new PDO($this->pdo);
+
+ //Creating a new calendar
+ $newId = $backend->createCalendar('principals/user2','somerandomid',array(
+ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => 'blabla',
+ ));
+
+ }
+
+ function testCreateCalendarObject() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+
+ $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"');
+ $this->assertEquals(array(
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
+ 'firstoccurence' => strtotime('20120101'),
+ 'lastoccurence' => strtotime('20120101')+(3600*24),
+ 'componenttype' => 'VEVENT',
+ ), $result->fetch(\PDO::FETCH_ASSOC));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ * @depends testCreateCalendarObject
+ */
+ function testCreateCalendarObjectNoComponent() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nEND:VCALENDAR\r\n";
+
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+
+ }
+
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testCreateCalendarObjectDuration() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nDURATION:P2D\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+
+ $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"');
+ $this->assertEquals(array(
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
+ 'firstoccurence' => strtotime('20120101'),
+ 'lastoccurence' => strtotime('20120101')+(3600*48),
+ 'componenttype' => 'VEVENT',
+ ), $result->fetch(\PDO::FETCH_ASSOC));
+
+ }
+
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testCreateCalendarObjectNoDTEND() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+
+ $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"');
+ $this->assertEquals(array(
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
+ 'firstoccurence' => strtotime('2012-01-01 10:00:00'),
+ 'lastoccurence' => strtotime('2012-01-01 10:00:00'),
+ 'componenttype' => 'VEVENT',
+ ), $result->fetch(\PDO::FETCH_ASSOC));
+
+ }
+
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testCreateCalendarObjectInfiniteReccurence() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nRRULE:FREQ=DAILY\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+
+ $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"');
+ $this->assertEquals(array(
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
+ 'firstoccurence' => strtotime('2012-01-01 10:00:00'),
+ 'lastoccurence' => strtotime(PDO::MAX_DATE),
+ 'componenttype' => 'VEVENT',
+ ), $result->fetch(\PDO::FETCH_ASSOC));
+
+ }
+
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testCreateCalendarObjectEndingReccurence() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nDTEND;VALUE=DATE-TIME:20120101T110000Z\r\nRRULE:FREQ=DAILY;COUNT=1000\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+
+ $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"');
+ $this->assertEquals(array(
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
+ 'firstoccurence' => strtotime('2012-01-01 10:00:00'),
+ 'lastoccurence' => strtotime('2012-01-01 11:00:00') + (3600 * 24 * 999),
+ 'componenttype' => 'VEVENT',
+ ), $result->fetch(\PDO::FETCH_ASSOC));
+
+ }
+
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testCreateCalendarObjectTask() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nDUE;VALUE=DATE-TIME:20120101T100000Z\r\nEND:VTODO\r\nEND:VCALENDAR\r\n";
+
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+
+ $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"');
+ $this->assertEquals(array(
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
+ 'firstoccurence' => null,
+ 'lastoccurence' => null,
+ 'componenttype' => 'VTODO',
+ ), $result->fetch(\PDO::FETCH_ASSOC));
+
+ }
+
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testGetCalendarObjects() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+
+ $data = $backend->getCalendarObjects($returnedId,'random-id');
+
+ $this->assertEquals(1, count($data));
+ $data = $data[0];
+
+ $this->assertEquals($returnedId, $data['calendarid']);
+ $this->assertEquals('random-id', $data['uri']);
+ $this->assertEquals(strlen($object),$data['size']);
+
+
+ }
+
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testUpdateCalendarObject() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+ $object2 = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20130101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+ $backend->updateCalendarObject($returnedId, 'random-id', $object2);
+
+ $data = $backend->getCalendarObject($returnedId,'random-id');
+
+ $this->assertEquals($object2, $data['calendardata']);
+ $this->assertEquals($returnedId, $data['calendarid']);
+ $this->assertEquals('random-id', $data['uri']);
+
+
+ }
+
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testDeleteCalendarObject() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+ $backend->deleteCalendarObject($returnedId, 'random-id');
+
+ $data = $backend->getCalendarObject($returnedId,'random-id');
+ $this->assertNull($data);
+
+ }
+
+ function testCalendarQueryNoResult() {
+
+ $abstract = new PDO($this->pdo);
+ $filters = array(
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => array(
+ array(
+ 'name' => 'VJOURNAL',
+ 'comp-filters' => array(),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ ),
+ ),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ );
+
+ $this->assertEquals(array(
+ ), $abstract->calendarQuery(1, $filters));
+
+ }
+
+ function testCalendarQueryTodo() {
+
+ $backend = new PDO($this->pdo);
+ $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
+ $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
+
+ $filters = array(
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => array(
+ array(
+ 'name' => 'VTODO',
+ 'comp-filters' => array(),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ ),
+ ),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ );
+
+ $this->assertEquals(array(
+ "todo",
+ ), $backend->calendarQuery(1, $filters));
+
+ }
+ function testCalendarQueryTodoNotMatch() {
+
+ $backend = new PDO($this->pdo);
+ $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
+ $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
+
+ $filters = array(
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => array(
+ array(
+ 'name' => 'VTODO',
+ 'comp-filters' => array(),
+ 'prop-filters' => array(
+ array(
+ 'name' => 'summary',
+ 'text-match' => null,
+ 'time-range' => null,
+ 'param-filters' => array(),
+ 'is-not-defined' => false,
+ ),
+ ),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ ),
+ ),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ );
+
+ $this->assertEquals(array(
+ ), $backend->calendarQuery(1, $filters));
+
+ }
+
+ function testCalendarQueryNoFilter() {
+
+ $backend = new PDO($this->pdo);
+ $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
+ $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
+
+ $filters = array(
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => array(),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ );
+
+ $result = $backend->calendarQuery(1, $filters);
+ $this->assertTrue(in_array('todo', $result));
+ $this->assertTrue(in_array('event', $result));
+
+ }
+
+ function testCalendarQueryTimeRange() {
+
+ $backend = new PDO($this->pdo);
+ $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
+ $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
+ $backend->createCalendarObject(1, "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
+
+ $filters = array(
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => array(
+ array(
+ 'name' => 'VEVENT',
+ 'comp-filters' => array(),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => array(
+ 'start' => new \DateTime('20120103'),
+ 'end' => new \DateTime('20120104'),
+ ),
+ ),
+ ),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ );
+
+ $this->assertEquals(array(
+ "event2",
+ ), $backend->calendarQuery(1, $filters));
+
+ }
+ function testCalendarQueryTimeRangeNoEnd() {
+
+ $backend = new PDO($this->pdo);
+ $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n");
+ $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
+ $backend->createCalendarObject(1, "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
+
+ $filters = array(
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => array(
+ array(
+ 'name' => 'VEVENT',
+ 'comp-filters' => array(),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => array(
+ 'start' => new \DateTime('20120102'),
+ 'end' => null,
+ ),
+ ),
+ ),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ );
+
+ $this->assertEquals(array(
+ "event2",
+ ), $backend->calendarQuery(1, $filters));
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php
new file mode 100644
index 000000000..04fb16df5
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php
@@ -0,0 +1,88 @@
+<?php
+
+namespace Sabre\CalDAV\Backend;
+
+class AbstractTest extends \PHPUnit_Framework_TestCase {
+
+ function testUpdateCalendar() {
+
+ $abstract = new AbstractMock();
+ $this->assertEquals(false, $abstract->updateCalendar('randomid', array('{DAV:}displayname' => 'anything')));
+
+ }
+
+ function testCalendarQuery() {
+
+ $abstract = new AbstractMock();
+ $filters = array(
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => array(
+ array(
+ 'name' => 'VEVENT',
+ 'comp-filters' => array(),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ ),
+ ),
+ 'prop-filters' => array(),
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ );
+
+ $this->assertEquals(array(
+ 'event1.ics',
+ ), $abstract->calendarQuery(1, $filters));
+
+ }
+
+}
+
+class AbstractMock extends AbstractBackend {
+
+ function getCalendarsForUser($principalUri) { }
+ 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 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",
+ );
+ case 'task1.ics' :
+ return array(
+ 'id' => 1,
+ 'calendarid' => 1,
+ 'uri' => 'event1.ics',
+ 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n",
+ );
+
+ }
+
+ }
+ function createCalendarObject($calendarId,$objectUri,$calendarData) { }
+ function updateCalendarObject($calendarId,$objectUri,$calendarData) { }
+ function deleteCalendarObject($calendarId,$objectUri) { }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php
new file mode 100644
index 000000000..d196297f7
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php
@@ -0,0 +1,400 @@
+<?php
+
+namespace Sabre\CalDAV\Backend;
+use Sabre\DAV;
+use Sabre\CalDAV;
+
+class Mock extends AbstractBackend implements NotificationSupport, SharingSupport {
+
+ private $calendarData;
+ private $calendars;
+ private $notifications;
+ private $shares = array();
+
+ function __construct(array $calendars, array $calendarData, array $notifications = array()) {
+
+ $this->calendars = $calendars;
+ $this->calendarData = $calendarData;
+ $this->notifications = $notifications;
+
+ }
+
+ /**
+ * Returns a list of calendars for a principal.
+ *
+ * Every project is an array with the following keys:
+ * * id, a unique id that will be used by other functions to modify the
+ * calendar. This can be the same as the uri or a database key.
+ * * uri, which the basename of the uri with which the calendar is
+ * accessed.
+ * * principalUri. The owner of the calendar. Almost always the same as
+ * principalUri passed to this method.
+ *
+ * Furthermore it can contain webdav properties in clark notation. A very
+ * common one is '{DAV:}displayname'.
+ *
+ * @param string $principalUri
+ * @return array
+ */
+ function getCalendarsForUser($principalUri) {
+
+ $r = array();
+ foreach($this->calendars as $row) {
+ if ($row['principaluri'] == $principalUri) {
+ $r[] = $row;
+ }
+ }
+
+ return $r;
+
+ }
+
+ /**
+ * Creates a new calendar for a principal.
+ *
+ * If the creation was a success, an id must be returned that can be used to reference
+ * this calendar in other methods, such as updateCalendar.
+ *
+ * This function must return a server-wide unique id that can be used
+ * later to reference the calendar.
+ *
+ * @param string $principalUri
+ * @param string $calendarUri
+ * @param array $properties
+ * @return string|int
+ */
+ function createCalendar($principalUri,$calendarUri,array $properties) {
+
+ $id = DAV\UUIDUtil::getUUID();
+ $this->calendars[] = array_merge(array(
+ 'id' => $id,
+ 'principaluri' => $principalUri,
+ 'uri' => $calendarUri,
+ '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
+ ), $properties);
+
+ return $id;
+
+ }
+
+ /**
+ * Updates properties on this node,
+ *
+ * The properties array uses the propertyName in clark-notation as key,
+ * and the array value for the property value. In the case a property
+ * should be deleted, the property value will be null.
+ *
+ * This method must be atomic. If one property cannot be changed, the
+ * entire operation must fail.
+ *
+ * If the operation was successful, true can be returned.
+ * If the operation failed, false can be returned.
+ *
+ * Deletion of a non-existent property is always successful.
+ *
+ * Lastly, it is optional to return detailed information about any
+ * failures. In this case an array should be returned with the following
+ * structure:
+ *
+ * array(
+ * 403 => array(
+ * '{DAV:}displayname' => null,
+ * ),
+ * 424 => array(
+ * '{DAV:}owner' => null,
+ * )
+ * )
+ *
+ * In this example it was forbidden to update {DAV:}displayname.
+ * (403 Forbidden), which in turn also caused {DAV:}owner to fail
+ * (424 Failed Dependency) because the request needs to be atomic.
+ *
+ * @param string $calendarId
+ * @param array $properties
+ * @return bool|array
+ */
+ public function updateCalendar($calendarId, array $properties) {
+
+ return false;
+
+ }
+
+ /**
+ * Delete a calendar and all it's objects
+ *
+ * @param string $calendarId
+ * @return void
+ */
+ public function deleteCalendar($calendarId) {
+
+ foreach($this->calendars as $k=>$calendar) {
+ if ($calendar['id'] === $calendarId) {
+ unset($this->calendars[$k]);
+ }
+ }
+
+ }
+
+ /**
+ * Returns all calendar objects within a calendar object.
+ *
+ * Every item contains an array with the following keys:
+ * * id - unique identifier which will be used for subsequent updates
+ * * calendardata - The iCalendar-compatible calendar data
+ * * uri - a unique key which will be used to construct the uri. This can be any arbitrary string.
+ * * lastmodified - a timestamp of the last modification time
+ * * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
+ * ' "abcdef"')
+ * * calendarid - The calendarid as it was passed to this function.
+ *
+ * Note that the etag is optional, but it's highly encouraged to return for
+ * speed reasons.
+ *
+ * The calendardata is also optional. If it's not returned
+ * 'getCalendarObject' will be called later, which *is* expected to return
+ * calendardata.
+ *
+ * @param string $calendarId
+ * @return array
+ */
+ public function getCalendarObjects($calendarId) {
+
+ if (!isset($this->calendarData[$calendarId]))
+ return array();
+
+ $objects = $this->calendarData[$calendarId];
+
+ foreach($objects as $uri => &$object) {
+ $object['calendarid'] = $calendarId;
+ $object['uri'] = $uri;
+
+ }
+ return $objects;
+
+ }
+
+ /**
+ * Returns information from a single calendar object, based on it's object
+ * uri.
+ *
+ * The returned array must have the same keys as getCalendarObjects. The
+ * 'calendardata' object is required here though, while it's not required
+ * for getCalendarObjects.
+ *
+ * @param string $calendarId
+ * @param string $objectUri
+ * @return array
+ */
+ function getCalendarObject($calendarId,$objectUri) {
+
+ if (!isset($this->calendarData[$calendarId][$objectUri])) {
+ throw new DAV\Exception\NotFound('Object could not be found');
+ }
+ $object = $this->calendarData[$calendarId][$objectUri];
+ $object['calendarid'] = $calendarId;
+ $object['uri'] = $objectUri;
+ return $object;
+
+ }
+
+ /**
+ * Creates a new calendar object.
+ *
+ * @param string $calendarId
+ * @param string $objectUri
+ * @param string $calendarData
+ * @return void
+ */
+ function createCalendarObject($calendarId,$objectUri,$calendarData) {
+
+ $this->calendarData[$calendarId][$objectUri] = array(
+ 'calendardata' => $calendarData,
+ 'calendarid' => $calendarId,
+ 'uri' => $objectUri,
+ );
+
+ }
+
+ /**
+ * Updates an existing calendarobject, based on it's uri.
+ *
+ * @param string $calendarId
+ * @param string $objectUri
+ * @param string $calendarData
+ * @return void
+ */
+ function updateCalendarObject($calendarId,$objectUri,$calendarData) {
+
+ $this->calendarData[$calendarId][$objectUri] = array(
+ 'calendardata' => $calendarData,
+ 'calendarid' => $calendarId,
+ 'uri' => $objectUri,
+ );
+
+ }
+
+ /**
+ * Deletes an existing calendar object.
+ *
+ * @param string $calendarId
+ * @param string $objectUri
+ * @return void
+ */
+ function deleteCalendarObject($calendarId,$objectUri) {
+
+ throw new Exception('Not implemented');
+
+
+ }
+
+ /**
+ * Returns a list of notifications for a given principal url.
+ *
+ * The returned array should only consist of implementations of
+ * Sabre\CalDAV\Notifications\INotificationType.
+ *
+ * @param string $principalUri
+ * @return array
+ */
+ public function getNotificationsForPrincipal($principalUri) {
+
+ if (isset($this->notifications[$principalUri])) {
+ return $this->notifications[$principalUri];
+ }
+ return array();
+
+ }
+
+ /**
+ * This deletes a specific notifcation.
+ *
+ * This may be called by a client once it deems a notification handled.
+ *
+ * @param string $principalUri
+ * @param Sabre\CalDAV\Notifications\INotificationType $notification
+ * @return void
+ */
+ public function deleteNotification($principalUri, CalDAV\Notifications\INotificationType $notification) {
+
+ foreach($this->notifications[$principalUri] as $key=>$value) {
+ if ($notification === $value) {
+ unset($this->notifications[$principalUri][$key]);
+ }
+ }
+
+ }
+
+ /**
+ * Updates the list of shares.
+ *
+ * The first array is a list of people that are to be added to the
+ * calendar.
+ *
+ * Every element in the add array has the following properties:
+ * * href - A url. Usually a mailto: address
+ * * commonName - Usually a first and last name, or false
+ * * summary - A description of the share, can also be false
+ * * readOnly - A boolean value
+ *
+ * Every element in the remove array is just the address string.
+ *
+ * Note that if the calendar is currently marked as 'not shared' by and
+ * this method is called, the calendar should be 'upgraded' to a shared
+ * calendar.
+ *
+ * @param mixed $calendarId
+ * @param array $add
+ * @param array $remove
+ * @return void
+ */
+ public function updateShares($calendarId, array $add, array $remove) {
+
+ if (!isset($this->shares[$calendarId])) {
+ $this->shares[$calendarId] = array();
+ }
+
+ foreach($add as $val) {
+ $val['status'] = CalDAV\SharingPlugin::STATUS_NORESPONSE;
+ $this->shares[$calendarId][] = $val;
+ }
+
+ foreach($this->shares[$calendarId] as $k=>$share) {
+
+ if (in_array($share['href'], $remove)) {
+ unset($this->shares[$calendarId][$k]);
+ }
+
+ }
+
+ // Re-numbering keys
+ $this->shares[$calendarId] = array_values($this->shares[$calendarId]);
+
+ }
+
+ /**
+ * Returns the list of people whom this calendar is shared with.
+ *
+ * Every element in this array should have the following properties:
+ * * href - Often a mailto: address
+ * * commonName - Optional, for example a first + last name
+ * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants.
+ * * readOnly - boolean
+ * * summary - Optional, a description for the share
+ *
+ * @param mixed $calendarId
+ * @return array
+ */
+ public function getShares($calendarId) {
+
+ if (!isset($this->shares[$calendarId])) {
+ return array();
+ }
+
+ return $this->shares[$calendarId];
+
+ }
+
+ /**
+ * This method is called when a user replied to a request to share.
+ *
+ * @param string href The sharee who is replying (often a mailto: address)
+ * @param int status One of the SharingPlugin::STATUS_* constants
+ * @param string $calendarUri The url to the calendar thats being shared
+ * @param string $inReplyTo The unique id this message is a response to
+ * @param string $summary A description of the reply
+ * @return void
+ */
+ public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null) {
+
+ // This operation basically doesn't do anything yet
+ if ($status === CalDAV\SharingPlugin::STATUS_ACCEPTED) {
+ return 'calendars/blabla/calendar';
+ }
+
+ }
+
+ /**
+ * Publishes a calendar
+ *
+ * @param mixed $calendarId
+ * @param bool $value
+ * @return void
+ */
+ public function setPublishStatus($calendarId, $value) {
+
+ foreach($this->calendars as $k=>$cal) {
+ if ($cal['id'] === $calendarId) {
+ if (!$value) {
+ unset($cal['{http://calendarserver.org/ns/}publish-url']);
+ } else {
+ $cal['{http://calendarserver.org/ns/}publish-url'] = 'http://example.org/public/ ' . $calendarId . '.ics';
+ }
+ return;
+ }
+ }
+
+ throw new DAV\Exception('Calendar with id "' . $calendarId . '" not found');
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php
new file mode 100644
index 000000000..15c1d91fd
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Sabre\CalDAV\Backend;
+
+require_once 'Sabre/TestUtil.php';
+require_once 'Sabre/CalDAV/TestUtil.php';
+require_once 'Sabre/CalDAV/Backend/AbstractPDOTest.php';
+
+class PDOMySQLTest extends AbstractPDOTest {
+
+ function setup() {
+
+ if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured');
+ $pdo = \Sabre\TestUtil::getMySQLDB();
+ if (!$pdo) $this->markTestSkipped('Could not connect to mysql database');
+
+ $pdo->query('DROP TABLE IF EXISTS calendarobjects, calendars');
+
+ $queries = explode(
+ ';',
+ file_get_contents(__DIR__ . '/../../../../examples/sql/mysql.calendars.sql')
+ );
+
+ foreach($queries as $query) {
+ $query = trim($query," \r\n\t");
+ if ($query)
+ $pdo->exec($query);
+ }
+ $this->pdo = $pdo;
+
+ }
+
+ function teardown() {
+
+ $this->pdo = null;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php
new file mode 100644
index 000000000..c50f06986
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Sabre\CalDAV\Backend;
+
+use Sabre\CalDAV;
+
+require_once 'Sabre/CalDAV/Backend/AbstractPDOTest.php';
+
+class PDOSQLiteTest extends AbstractPDOTest {
+
+ function setup() {
+
+ if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
+ $this->pdo = CalDAV\TestUtil::getSQLiteDB();
+
+ }
+
+ function teardown() {
+
+ $this->pdo = null;
+ unlink(SABRE_TEMPDIR . '/testdb.sqlite');
+
+ }
+
+}