aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
committerredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
commit0b02a6d123b2014705998c94ddf3d460948d3eac (patch)
tree78ff2cab9944a4f5ab3f80ec93cbe1120de90bb2 /vendor/sabre/dav/tests/Sabre/CalDAV
parent40b5b6e9d2da7ab65c8b4d38cdceac83a4d78deb (diff)
downloadvolse-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')
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php733
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php184
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php267
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php6
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php16
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php50
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryParserTest.php540
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php70
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php74
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php55
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php49
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php6
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php71
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php282
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php68
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php544
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php60
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php4
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php4
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php6
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php4
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php4
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php10
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteReplyTest.php134
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteTest.php230
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/SystemStatusTest.php61
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/OutboxPostTest.php545
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php869
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php2
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Property/AllowedSharingModesTest.php46
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Property/InviteTest.php196
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Property/ScheduleCalendarTranspTest.php99
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCalendarComponentSetTest.php67
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php44
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php46
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/IMip/Mock.php50
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php21
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/ShareableCalendarTest.php10
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php91
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php84
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/UserCalendarsSharedCalendarsTest.php93
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/UserCalendarsTest.php207
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php91
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/VersionTest.php17
44 files changed, 2159 insertions, 3951 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php
index 2224f0b63..25f8b1794 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php
@@ -1,8 +1,10 @@
<?php
namespace Sabre\CalDAV\Backend;
+
use Sabre\CalDAV;
use Sabre\DAV;
+use Sabre\DAV\PropPatch;
abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
@@ -22,7 +24,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$backend = new PDO($this->pdo);
$calendars = $backend->getCalendarsForUser('principals/user2');
- $this->assertEquals(array(),$calendars);
+ $this->assertEquals([], $calendars);
}
@@ -32,28 +34,28 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
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'),
- ));
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [
+ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']),
+ '{DAV:}displayname' => 'Hello!',
+ '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\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'),
- );
+ $elementCheck = [
+ '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\Xml\Property\ScheduleCalendarTransp('transparent'),
+ ];
- $this->assertInternalType('array',$calendars);
- $this->assertEquals(1,count($calendars));
+ $this->assertInternalType('array', $calendars);
+ $this->assertEquals(1, count($calendars));
- foreach($elementCheck as $name=>$value) {
+ foreach ($elementCheck as $name => $value) {
$this->assertArrayHasKey($name, $calendars[0]);
- $this->assertEquals($value,$calendars[0][$name]);
+ $this->assertEquals($value, $calendars[0][$name]);
}
@@ -67,38 +69,41 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$backend = new PDO($this->pdo);
//Creating a new calendar
- $newId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $newId = $backend->createCalendar('principals/user2', 'somerandomid', []);
+
+ $propPatch = new PropPatch([
+ '{DAV:}displayname' => 'myCalendar',
+ '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'),
+ ]);
// 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'),
- ));
+ $backend->updateCalendar($newId, $propPatch);
+ $result = $propPatch->commit();
// Verifying the result of the update
- $this->assertEquals(true, $result);
+ $this->assertTrue($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'),
- );
+ $elementCheck = [
+ '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' => 'http://sabre.io/ns/sync/2',
+ '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'),
+ ];
- $this->assertInternalType('array',$calendars);
- $this->assertEquals(1,count($calendars));
+ $this->assertInternalType('array', $calendars);
+ $this->assertEquals(1, count($calendars));
- foreach($elementCheck as $name=>$value) {
+ foreach ($elementCheck as $name => $value) {
$this->assertArrayHasKey($name, $calendars[0]);
- $this->assertEquals($value,$calendars[0][$name]);
+ $this->assertEquals($value, $calendars[0][$name]);
}
@@ -112,19 +117,22 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$backend = new PDO($this->pdo);
//Creating a new calendar
- $newId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $newId = $backend->createCalendar('principals/user2', 'somerandomid', []);
- // Updating the calendar
- $result = $backend->updateCalendar($newId,array(
+ $propPatch = new PropPatch([
'{DAV:}displayname' => 'myCalendar',
'{DAV:}yourmom' => 'wittycomment',
- ));
+ ]);
+
+ // Updating the calendar
+ $backend->updateCalendar($newId, $propPatch);
+ $propPatch->commit();
// Verifying the result of the update
- $this->assertEquals(array(
- '403' => array('{DAV:}yourmom' => null),
- '424' => array('{DAV:}displayname' => null),
- ), $result);
+ $this->assertEquals([
+ '{DAV:}yourmom' => 403,
+ '{DAV:}displayname' => 424,
+ ], $propPatch->getResult());
}
@@ -134,15 +142,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
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!',
- ));
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [
+ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']),
+ '{DAV:}displayname' => 'Hello!',
+ ]);
$backend->deleteCalendar($returnedId);
$calendars = $backend->getCalendarsForUser('principals/user2');
- $this->assertEquals(array(),$calendars);
+ $this->assertEquals([], $calendars);
}
@@ -155,30 +163,78 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$backend = new PDO($this->pdo);
//Creating a new calendar
- $newId = $backend->createCalendar('principals/user2','somerandomid',array(
+ $newId = $backend->createCalendar('principals/user2', 'somerandomid', [
'{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());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
$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,
+ $this->assertEquals([
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
'firstoccurence' => strtotime('20120101'),
- 'lastoccurence' => strtotime('20120101')+(3600*24),
- 'componenttype' => 'VEVENT',
- ), $result->fetch(\PDO::FETCH_ASSOC));
+ 'lastoccurence' => strtotime('20120101') + (3600 * 24),
+ 'componenttype' => 'VEVENT',
+ ], $result->fetch(\PDO::FETCH_ASSOC));
+
+ }
+ function testGetMultipleObjects() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+
+ $backend->createCalendarObject($returnedId, 'id-1', $object);
+ $backend->createCalendarObject($returnedId, 'id-2', $object);
+
+ $check = [
+ [
+ 'id' => 1,
+ 'etag' => '"' . md5($object) . '"',
+ 'uri' => 'id-1',
+ 'size' => strlen($object),
+ 'calendardata' => $object,
+ 'lastmodified' => null,
+ 'calendarid' => $returnedId,
+ ],
+ [
+ 'id' => 2,
+ 'etag' => '"' . md5($object) . '"',
+ 'uri' => 'id-2',
+ 'size' => strlen($object),
+ 'calendardata' => $object,
+ 'lastmodified' => null,
+ 'calendarid' => $returnedId,
+ ],
+ ];
+
+ $result = $backend->getMultipleCalendarObjects($returnedId, [ 'id-1', 'id-2' ]);
+
+ foreach ($check as $index => $props) {
+
+ foreach ($props as $key => $value) {
+
+ if ($key !== 'lastmodified') {
+ $this->assertEquals($value, $result[$index][$key]);
+ } else {
+ $this->assertTrue(isset($result[$index][$key]));
+ }
+
+ }
+
+ }
}
@@ -189,7 +245,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testCreateCalendarObjectNoComponent() {
$backend = new PDO($this->pdo);
- $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
$object = "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nEND:VCALENDAR\r\n";
@@ -203,21 +259,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testCreateCalendarObjectDuration() {
$backend = new PDO($this->pdo);
- $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
$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,
+ $this->assertEquals([
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
'firstoccurence' => strtotime('20120101'),
- 'lastoccurence' => strtotime('20120101')+(3600*48),
- 'componenttype' => 'VEVENT',
- ), $result->fetch(\PDO::FETCH_ASSOC));
+ 'lastoccurence' => strtotime('20120101') + (3600 * 48),
+ 'componenttype' => 'VEVENT',
+ ], $result->fetch(\PDO::FETCH_ASSOC));
}
@@ -227,21 +283,45 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testCreateCalendarObjectNoDTEND() {
$backend = new PDO($this->pdo);
- $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
$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,
+ $this->assertEquals([
+ '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));
+ 'lastoccurence' => strtotime('2012-01-01 10:00:00'),
+ 'componenttype' => 'VEVENT',
+ ], $result->fetch(\PDO::FETCH_ASSOC));
+
+ }
+
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testCreateCalendarObjectWithDTEND() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nDTEND:20120101T110000Z\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([
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
+ 'firstoccurence' => strtotime('2012-01-01 10:00:00'),
+ 'lastoccurence' => strtotime('2012-01-01 11:00:00'),
+ 'componenttype' => 'VEVENT',
+ ], $result->fetch(\PDO::FETCH_ASSOC));
}
@@ -251,21 +331,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testCreateCalendarObjectInfiniteReccurence() {
$backend = new PDO($this->pdo);
- $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
- $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nRRULE:FREQ=DAILY\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nRRULE:FREQ=DAILY\r\nUID:foo\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,
+ $this->assertEquals([
+ '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));
+ 'lastoccurence' => strtotime(PDO::MAX_DATE),
+ 'componenttype' => 'VEVENT',
+ ], $result->fetch(\PDO::FETCH_ASSOC));
}
@@ -275,21 +355,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testCreateCalendarObjectEndingReccurence() {
$backend = new PDO($this->pdo);
- $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
- $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";
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nDTEND;VALUE=DATE-TIME:20120101T110000Z\r\nUID:foo\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,
+ $this->assertEquals([
+ '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));
+ 'lastoccurence' => strtotime('2012-01-01 11:00:00') + (3600 * 24 * 999),
+ 'componenttype' => 'VEVENT',
+ ], $result->fetch(\PDO::FETCH_ASSOC));
}
@@ -299,21 +379,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testCreateCalendarObjectTask() {
$backend = new PDO($this->pdo);
- $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
$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,
+ $this->assertEquals([
+ 'etag' => md5($object),
+ 'size' => strlen($object),
+ 'calendardata' => $object,
'firstoccurence' => null,
- 'lastoccurence' => null,
- 'componenttype' => 'VTODO',
- ), $result->fetch(\PDO::FETCH_ASSOC));
+ 'lastoccurence' => null,
+ 'componenttype' => 'VTODO',
+ ], $result->fetch(\PDO::FETCH_ASSOC));
}
@@ -323,22 +403,42 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testGetCalendarObjects() {
$backend = new PDO($this->pdo);
- $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
$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');
+ $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']);
+ $this->assertEquals(strlen($object), $data['size']);
}
+ /**
+ * @depends testCreateCalendarObject
+ */
+ function testGetCalendarObjectByUID() {
+
+ $backend = new PDO($this->pdo);
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
+
+ $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
+ $backend->createCalendarObject($returnedId, 'random-id', $object);
+
+ $this->assertNull(
+ $backend->getCalendarObjectByUID('principals/user2', 'bar')
+ );
+ $this->assertEquals(
+ 'somerandomid/random-id',
+ $backend->getCalendarObjectByUID('principals/user2', 'foo')
+ );
+
+ }
/**
* @depends testCreateCalendarObject
@@ -346,14 +446,14 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testUpdateCalendarObject() {
$backend = new PDO($this->pdo);
- $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
$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');
+ $data = $backend->getCalendarObject($returnedId, 'random-id');
$this->assertEquals($object2, $data['calendardata']);
$this->assertEquals($returnedId, $data['calendarid']);
@@ -368,13 +468,13 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testDeleteCalendarObject() {
$backend = new PDO($this->pdo);
- $returnedId = $backend->createCalendar('principals/user2','somerandomid',array());
+ $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []);
$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');
+ $data = $backend->getCalendarObject($returnedId, 'random-id');
$this->assertNull($data);
}
@@ -382,24 +482,24 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
function testCalendarQueryNoResult() {
$abstract = new PDO($this->pdo);
- $filters = array(
- 'name' => 'VCALENDAR',
- 'comp-filters' => array(
- array(
- 'name' => 'VJOURNAL',
- 'comp-filters' => array(),
- 'prop-filters' => array(),
+ $filters = [
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [
+ [
+ 'name' => 'VJOURNAL',
+ '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(array(
- ), $abstract->calendarQuery(1, $filters));
+ $this->assertEquals([
+ ], $abstract->calendarQuery(1, $filters));
}
@@ -409,25 +509,25 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$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(),
+ $filters = [
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [
+ [
+ 'name' => 'VTODO',
+ '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(array(
+ $this->assertEquals([
"todo",
- ), $backend->calendarQuery(1, $filters));
+ ], $backend->calendarQuery(1, $filters));
}
function testCalendarQueryTodoNotMatch() {
@@ -436,32 +536,32 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$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(),
+ $filters = [
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [
+ [
+ 'name' => 'VTODO',
+ 'comp-filters' => [],
+ 'prop-filters' => [
+ [
+ 'name' => 'summary',
+ 'text-match' => null,
+ 'time-range' => null,
+ 'param-filters' => [],
'is-not-defined' => false,
- ),
- ),
+ ],
+ ],
'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(array(
- ), $backend->calendarQuery(1, $filters));
+ $this->assertEquals([
+ ], $backend->calendarQuery(1, $filters));
}
@@ -471,13 +571,13 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$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(),
+ $filters = [
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [],
+ 'prop-filters' => [],
'is-not-defined' => false,
- 'time-range' => null,
- );
+ 'time-range' => null,
+ ];
$result = $backend->calendarQuery(1, $filters);
$this->assertTrue(in_array('todo', $result));
@@ -492,28 +592,28 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$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(),
+ $filters = [
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [
+ [
+ 'name' => 'VEVENT',
+ 'comp-filters' => [],
+ 'prop-filters' => [],
'is-not-defined' => false,
- 'time-range' => array(
+ 'time-range' => [
'start' => new \DateTime('20120103'),
'end' => new \DateTime('20120104'),
- ),
- ),
- ),
- 'prop-filters' => array(),
+ ],
+ ],
+ ],
+ 'prop-filters' => [],
'is-not-defined' => false,
- 'time-range' => null,
- );
+ 'time-range' => null,
+ ];
- $this->assertEquals(array(
+ $this->assertEquals([
"event2",
- ), $backend->calendarQuery(1, $filters));
+ ], $backend->calendarQuery(1, $filters));
}
function testCalendarQueryTimeRangeNoEnd() {
@@ -523,28 +623,261 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$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(),
+ $filters = [
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [
+ [
+ 'name' => 'VEVENT',
+ 'comp-filters' => [],
+ 'prop-filters' => [],
'is-not-defined' => false,
- 'time-range' => array(
+ 'time-range' => [
'start' => new \DateTime('20120102'),
- 'end' => null,
- ),
- ),
- ),
- 'prop-filters' => array(),
+ 'end' => null,
+ ],
+ ],
+ ],
+ 'prop-filters' => [],
'is-not-defined' => false,
- 'time-range' => null,
- );
+ 'time-range' => null,
+ ];
- $this->assertEquals(array(
+ $this->assertEquals([
"event2",
- ), $backend->calendarQuery(1, $filters));
+ ], $backend->calendarQuery(1, $filters));
}
+
+ function testGetChanges() {
+
+ $backend = new PDO($this->pdo);
+ $id = $backend->createCalendar(
+ 'principals/user1',
+ 'bla',
+ []
+ );
+ $result = $backend->getChangesForCalendar($id, null, 1);
+
+ $this->assertEquals([
+ 'syncToken' => 1,
+ 'modified' => [],
+ 'deleted' => [],
+ 'added' => [],
+ ], $result);
+
+ $currentToken = $result['syncToken'];
+
+ $dummyTodo = "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n";
+
+ $backend->createCalendarObject($id, "todo1.ics", $dummyTodo);
+ $backend->createCalendarObject($id, "todo2.ics", $dummyTodo);
+ $backend->createCalendarObject($id, "todo3.ics", $dummyTodo);
+ $backend->updateCalendarObject($id, "todo1.ics", $dummyTodo);
+ $backend->deleteCalendarObject($id, "todo2.ics");
+
+ $result = $backend->getChangesForCalendar($id, $currentToken, 1);
+
+ $this->assertEquals([
+ 'syncToken' => 6,
+ 'modified' => ["todo1.ics"],
+ 'deleted' => ["todo2.ics"],
+ 'added' => ["todo3.ics"],
+ ], $result);
+
+ $result = $backend->getChangesForCalendar($id, null, 1);
+
+ $this->assertEquals([
+ 'syncToken' => 6,
+ 'modified' => [],
+ 'deleted' => [],
+ 'added' => ["todo1.ics", "todo3.ics"],
+ ], $result);
+ }
+
+ function testCreateSubscriptions() {
+
+ $props = [
+ '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false),
+ '{DAV:}displayname' => 'cal',
+ '{http://apple.com/ns/ical/}refreshrate' => 'P1W',
+ '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF',
+ '{http://calendarserver.org/ns/}subscribed-strip-todos' => true,
+ //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true,
+ '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true,
+ ];
+
+ $backend = new PDO($this->pdo);
+ $backend->createSubscription('principals/user1', 'sub1', $props);
+
+ $subs = $backend->getSubscriptionsForUser('principals/user1');
+
+ $expected = $props;
+ $expected['id'] = 1;
+ $expected['uri'] = 'sub1';
+ $expected['principaluri'] = 'principals/user1';
+
+ unset($expected['{http://calendarserver.org/ns/}source']);
+ $expected['source'] = 'http://example.org/cal.ics';
+
+ $this->assertEquals(1, count($subs));
+ foreach ($expected as $k => $v) {
+ $this->assertEquals($subs[0][$k], $expected[$k]);
+ }
+
+ }
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\Forbidden
+ */
+ function testCreateSubscriptionFail() {
+
+ $props = [
+ ];
+
+ $backend = new PDO($this->pdo);
+ $backend->createSubscription('principals/user1', 'sub1', $props);
+
+ }
+
+ function testUpdateSubscriptions() {
+
+ $props = [
+ '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false),
+ '{DAV:}displayname' => 'cal',
+ '{http://apple.com/ns/ical/}refreshrate' => 'P1W',
+ '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF',
+ '{http://calendarserver.org/ns/}subscribed-strip-todos' => true,
+ //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true,
+ '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true,
+ ];
+
+ $backend = new PDO($this->pdo);
+ $backend->createSubscription('principals/user1', 'sub1', $props);
+
+ $newProps = [
+ '{DAV:}displayname' => 'new displayname',
+ '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false),
+ ];
+
+ $propPatch = new DAV\PropPatch($newProps);
+ $backend->updateSubscription(1, $propPatch);
+ $result = $propPatch->commit();
+
+ $this->assertTrue($result);
+
+ $subs = $backend->getSubscriptionsForUser('principals/user1');
+
+ $expected = array_merge($props, $newProps);
+ $expected['id'] = 1;
+ $expected['uri'] = 'sub1';
+ $expected['principaluri'] = 'principals/user1';
+
+ unset($expected['{http://calendarserver.org/ns/}source']);
+ $expected['source'] = 'http://example.org/cal2.ics';
+
+ $this->assertEquals(1, count($subs));
+ foreach ($expected as $k => $v) {
+ $this->assertEquals($subs[0][$k], $expected[$k]);
+ }
+
+ }
+
+ function testUpdateSubscriptionsFail() {
+
+ $props = [
+ '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false),
+ '{DAV:}displayname' => 'cal',
+ '{http://apple.com/ns/ical/}refreshrate' => 'P1W',
+ '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF',
+ '{http://calendarserver.org/ns/}subscribed-strip-todos' => true,
+ //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true,
+ '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true,
+ ];
+
+ $backend = new PDO($this->pdo);
+ $backend->createSubscription('principals/user1', 'sub1', $props);
+
+ $propPatch = new DAV\PropPatch([
+ '{DAV:}displayname' => 'new displayname',
+ '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false),
+ '{DAV:}unknown' => 'foo',
+ ]);
+
+ $backend->updateSubscription(1, $propPatch);
+ $propPatch->commit();
+
+ $this->assertEquals([
+ '{DAV:}unknown' => 403,
+ '{DAV:}displayname' => 424,
+ '{http://calendarserver.org/ns/}source' => 424,
+ ], $propPatch->getResult());
+
+ }
+
+ function testDeleteSubscriptions() {
+
+ $props = [
+ '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false),
+ '{DAV:}displayname' => 'cal',
+ '{http://apple.com/ns/ical/}refreshrate' => 'P1W',
+ '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF',
+ '{http://calendarserver.org/ns/}subscribed-strip-todos' => true,
+ //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true,
+ '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true,
+ ];
+
+ $backend = new PDO($this->pdo);
+ $backend->createSubscription('principals/user1', 'sub1', $props);
+
+ $newProps = [
+ '{DAV:}displayname' => 'new displayname',
+ '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false),
+ ];
+
+ $backend->deleteSubscription(1);
+
+ $subs = $backend->getSubscriptionsForUser('principals/user1');
+ $this->assertEquals(0, count($subs));
+ }
+
+ function testSchedulingMethods() {
+
+ $backend = new PDO($this->pdo);
+
+ $calData = "BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n";
+
+ $backend->createSchedulingObject(
+ 'principals/user1',
+ 'schedule1.ics',
+ $calData
+ );
+
+ $expected = [
+ 'calendardata' => $calData,
+ 'uri' => 'schedule1.ics',
+ 'etag' => '"' . md5($calData) . '"',
+ 'size' => strlen($calData)
+ ];
+
+ $result = $backend->getSchedulingObject('principals/user1', 'schedule1.ics');
+ foreach ($expected as $k => $v) {
+ $this->assertArrayHasKey($k, $result);
+ $this->assertEquals($v, $result[$k]);
+ }
+
+ $results = $backend->getSchedulingObjects('principals/user1');
+
+ $this->assertEquals(1, count($results));
+ $result = $results[0];
+ foreach ($expected as $k => $v) {
+ $this->assertEquals($v, $result[$k]);
+ }
+
+ $backend->deleteSchedulingObject('principals/user1', 'schedule1.ics');
+ $result = $backend->getSchedulingObject('principals/user1', 'schedule1.ics');
+
+ $this->assertNull($result);
+
+ }
+
}
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) { }
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php
index d196297f7..4412e5531 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php
@@ -1,21 +1,25 @@
<?php
namespace Sabre\CalDAV\Backend;
+
use Sabre\DAV;
use Sabre\CalDAV;
-class Mock extends AbstractBackend implements NotificationSupport, SharingSupport {
+class Mock extends AbstractBackend {
+
+ protected $calendarData;
+ protected $calendars;
- private $calendarData;
- private $calendars;
- private $notifications;
- private $shares = array();
+ function __construct(array $calendars = [], array $calendarData = []) {
- function __construct(array $calendars, array $calendarData, array $notifications = array()) {
+ foreach ($calendars as &$calendar) {
+ if (!isset($calendar['id'])) {
+ $calendar['id'] = DAV\UUIDUtil::getUUID();
+ }
+ }
$this->calendars = $calendars;
$this->calendarData = $calendarData;
- $this->notifications = $notifications;
}
@@ -38,8 +42,8 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
*/
function getCalendarsForUser($principalUri) {
- $r = array();
- foreach($this->calendars as $row) {
+ $r = [];
+ foreach ($this->calendars as $row) {
if ($row['principaluri'] == $principalUri) {
$r[] = $row;
}
@@ -63,71 +67,29 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
* @param array $properties
* @return string|int
*/
- function createCalendar($principalUri,$calendarUri,array $properties) {
+ 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);
+ $this->calendars[] = array_merge([
+ 'id' => $id,
+ 'principaluri' => $principalUri,
+ 'uri' => $calendarUri,
+ '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['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) {
+ function deleteCalendar($calendarId) {
- foreach($this->calendars as $k=>$calendar) {
+ foreach ($this->calendars as $k => $calendar) {
if ($calendar['id'] === $calendarId) {
unset($this->calendars[$k]);
}
@@ -157,17 +119,17 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
* @param string $calendarId
* @return array
*/
- public function getCalendarObjects($calendarId) {
+ function getCalendarObjects($calendarId) {
if (!isset($this->calendarData[$calendarId]))
- return array();
+ return [];
$objects = $this->calendarData[$calendarId];
- foreach($objects as $uri => &$object) {
+ foreach ($objects as $uri => &$object) {
$object['calendarid'] = $calendarId;
$object['uri'] = $uri;
-
+ $object['lastmodified'] = null;
}
return $objects;
@@ -185,7 +147,7 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
* @param string $objectUri
* @return array
*/
- function getCalendarObject($calendarId,$objectUri) {
+ function getCalendarObject($calendarId, $objectUri) {
if (!isset($this->calendarData[$calendarId][$objectUri])) {
throw new DAV\Exception\NotFound('Object could not be found');
@@ -193,6 +155,7 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
$object = $this->calendarData[$calendarId][$objectUri];
$object['calendarid'] = $calendarId;
$object['uri'] = $objectUri;
+ $object['lastmodified'] = null;
return $object;
}
@@ -205,13 +168,14 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
* @param string $calendarData
* @return void
*/
- function createCalendarObject($calendarId,$objectUri,$calendarData) {
+ function createCalendarObject($calendarId, $objectUri, $calendarData) {
- $this->calendarData[$calendarId][$objectUri] = array(
+ $this->calendarData[$calendarId][$objectUri] = [
'calendardata' => $calendarData,
- 'calendarid' => $calendarId,
- 'uri' => $objectUri,
- );
+ 'calendarid' => $calendarId,
+ 'uri' => $objectUri,
+ ];
+ return '"' . md5($calendarData) . '"';
}
@@ -223,13 +187,14 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
* @param string $calendarData
* @return void
*/
- function updateCalendarObject($calendarId,$objectUri,$calendarData) {
+ function updateCalendarObject($calendarId, $objectUri, $calendarData) {
- $this->calendarData[$calendarId][$objectUri] = array(
+ $this->calendarData[$calendarId][$objectUri] = [
'calendardata' => $calendarData,
- 'calendarid' => $calendarId,
- 'uri' => $objectUri,
- );
+ 'calendarid' => $calendarId,
+ 'uri' => $objectUri,
+ ];
+ return '"' . md5($calendarData) . '"';
}
@@ -240,161 +205,11 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
* @param string $objectUri
* @return void
*/
- function deleteCalendarObject($calendarId,$objectUri) {
+ 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
index 15c1d91fd..c215ca171 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php
@@ -14,15 +14,15 @@ class PDOMySQLTest extends AbstractPDOTest {
$pdo = \Sabre\TestUtil::getMySQLDB();
if (!$pdo) $this->markTestSkipped('Could not connect to mysql database');
- $pdo->query('DROP TABLE IF EXISTS calendarobjects, calendars');
+ $pdo->query('DROP TABLE IF EXISTS calendarobjects, calendars, calendarchanges, calendarsubscriptions, schedulingobjects');
$queries = explode(
';',
file_get_contents(__DIR__ . '/../../../../examples/sql/mysql.calendars.sql')
);
- foreach($queries as $query) {
- $query = trim($query," \r\n\t");
+ foreach ($queries as $query) {
+ $query = trim($query, " \r\n\t");
if ($query)
$pdo->exec($query);
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php
index c50f06986..4074259f2 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php
@@ -6,12 +6,24 @@ use Sabre\CalDAV;
require_once 'Sabre/CalDAV/Backend/AbstractPDOTest.php';
-class PDOSQLiteTest extends AbstractPDOTest {
+class PDOSqliteTest extends AbstractPDOTest {
function setup() {
if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
- $this->pdo = CalDAV\TestUtil::getSQLiteDB();
+
+ if (file_exists(SABRE_TEMPDIR . '/testdb.sqlite'))
+ unlink(SABRE_TEMPDIR . '/testdb.sqlite');
+
+ $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/testdb.sqlite');
+ $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
+
+ // Yup this is definitely not 'fool proof', but good enough for now.
+ $queries = explode(';', file_get_contents(__DIR__ . '/../../../../examples/sql/sqlite.calendars.sql'));
+ foreach ($queries as $query) {
+ $pdo->exec($query);
+ }
+ $this->pdo = $pdo;
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php
index eab10eae7..9fc1eee4c 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php
@@ -43,7 +43,7 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase {
$this->assertInternalType('string',$children[0]->getName());
$this->assertInternalType('string',$children[0]->get());
$this->assertInternalType('string',$children[0]->getETag());
- $this->assertEquals('text/calendar; charset=utf-8', $children[0]->getContentType());
+ $this->assertEquals('text/calendar; charset=utf-8; component=vevent', $children[0]->getContentType());
}
@@ -180,6 +180,46 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase {
'protected' => true,
),
array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/user1/calendar-proxy-write',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/user1/calendar-proxy-read',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}write',
+ 'principal' => 'principals/user1',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}write',
+ 'principal' => 'principals/user1/calendar-proxy-write',
+ 'protected' => true,
+ ),
+ );
+
+ $children = $this->calendar->getChildren();
+ $this->assertTrue($children[0] instanceof CalendarObject);
+
+ $obj = $children[0];
+ $this->assertEquals($expected, $obj->getACL());
+
+ }
+
+ function testDefaultACL() {
+
+ $backend = new Backend\Mock([], []);
+ $calendarObject = new CalendarObject($backend, ['principaluri' => 'principals/user1'], ['calendarid' => 1, 'uri' => 'foo']);
+ $expected = array(
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/user1',
+ 'protected' => true,
+ ),
+ array(
'privilege' => '{DAV:}write',
'principal' => 'principals/user1',
'protected' => true,
@@ -200,12 +240,8 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase {
'protected' => true,
),
);
+ $this->assertEquals($expected, $calendarObject->getACL());
- $children = $this->calendar->getChildren();
- $this->assertTrue($children[0] instanceof CalendarObject);
-
- $obj = $children[0];
- $this->assertEquals($expected, $obj->getACL());
}
@@ -278,7 +314,7 @@ END:VCALENDAR";
),
)
));
- $obj = new CalendarObject($backend, array(), array('calendarid' => 1, 'uri' => 'foo'));
+ $obj = new CalendarObject($backend, array('id' => 1), array('uri' => 'foo'));
$this->assertEquals('foo', $obj->get());
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryParserTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryParserTest.php
deleted file mode 100644
index fdfe4de89..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryParserTest.php
+++ /dev/null
@@ -1,540 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV;
-use Sabre\DAV;
-
-class CalendarQueryParserTest extends \PHPUnit_Framework_TestCase {
-
- function parse($xml) {
-
- $xml =
-'<?xml version="1.0"?>
-<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">
-' . implode("\n", $xml) . '
-</c:calendar-query>';
-
- $dom = DAV\XMLUtil::loadDOMDocument($xml);
-
- $q = new CalendarQueryParser($dom);
- $q->parse();
- return $q->filters;
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testNoFilter() {
-
- $xml = array();
- $this->parse($xml);
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testTwoCompFilter() {
-
- $xml = array(
- '<c:filter>',
- ' <c:comp-filter name="VEVENT" />',
- ' <c:comp-filter name="VEVENT" />',
- '</c:filter>'
- );
- $this->parse($xml);
-
- }
-
- function testBasicFilter() {
-
- $xml = array(
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR" />',
- '</c:filter>'
- );
- $result = $this->parse($xml);
-
- $expected = array(
- 'name' => 'VCALENDAR',
- 'comp-filters' => array(),
- 'prop-filters' => array(),
- 'is-not-defined' => false,
- 'time-range' => false
- );
-
- $this->assertEquals(
- $expected,
- $result
- );
-
- }
-
- function testCompIsNotDefined() {
-
- $xml = array(
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR">',
- ' <c:comp-filter name="VEVENT">',
- ' <c:is-not-defined/>',
- ' </c:comp-filter>',
- ' </c:comp-filter>',
- '</c:filter>'
- );
- $result = $this->parse($xml);
-
- $expected = array(
- 'name' => 'VCALENDAR',
- 'comp-filters' => array(
- array(
- 'name' => 'VEVENT',
- 'comp-filters' => array(),
- 'prop-filters' => array(),
- 'is-not-defined' => true,
- 'time-range' => false
- ),
- ),
- 'prop-filters' => array(),
- 'is-not-defined' => false,
- 'time-range' => false
- );
-
- $this->assertEquals(
- $expected,
- $result
- );
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testCompTimeRangeOnVCALENDAR() {
-
- $xml = array(
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR">',
- ' <c:time-range start="20110101T000000Z" end="20111231T235959Z" />',
- ' </c:comp-filter>',
- '</c:filter>'
- );
- $result = $this->parse($xml);
-
- }
-
- function testCompTimeRange() {
-
- $xml = array(
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR">',
- ' <c:comp-filter name="VEVENT">',
- ' <c:time-range start="20110101T000000Z" end="20111231T235959Z" />',
- ' </c:comp-filter>',
- ' <c:comp-filter name="VTODO">',
- ' <c:time-range start="20110101T000000Z" />',
- ' </c:comp-filter>',
- ' <c:comp-filter name="VJOURNAL">',
- ' <c:time-range end="20111231T235959Z" />',
- ' </c:comp-filter>',
- ' </c:comp-filter>',
- '</c:filter>'
- );
- $result = $this->parse($xml);
-
- $expected = 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('2011-01-01 00:00:00', new \DateTimeZone('GMT')),
- 'end' => new \DateTime('2011-12-31 23:59:59', new \DateTimeZone('GMT')),
- ),
- ),
- array(
- 'name' => 'VTODO',
- 'comp-filters' => array(),
- 'prop-filters' => array(),
- 'is-not-defined' => false,
- 'time-range' => array(
- 'start' => new \DateTime('2011-01-01 00:00:00', new \DateTimeZone('GMT')),
- 'end' => null,
- ),
- ),
- array(
- 'name' => 'VJOURNAL',
- 'comp-filters' => array(),
- 'prop-filters' => array(),
- 'is-not-defined' => false,
- 'time-range' => array(
- 'start' => null,
- 'end' => new \DateTime('2011-12-31 23:59:59', new \DateTimeZone('GMT')),
- ),
- ),
- ),
- 'prop-filters' => array(),
- 'is-not-defined' => false,
- 'time-range' => false
- );
-
- $this->assertEquals(
- $expected,
- $result
- );
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testCompTimeRangeBadRange() {
-
- $xml = array(
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR">',
- ' <c:comp-filter name="VEVENT">',
- ' <c:time-range start="20110101T000000Z" end="20100101T000000Z" />',
- ' </c:comp-filter>',
- ' </c:comp-filter>',
- '</c:filter>'
- );
- $this->parse($xml);
-
- }
-
- function testProp() {
-
- $xml = array(
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR">',
- ' <c:comp-filter name="VEVENT">',
- ' <c:prop-filter name="SUMMARY">',
- ' <c:text-match>vacation</c:text-match>',
- ' </c:prop-filter>',
- ' </c:comp-filter>',
- ' </c:comp-filter>',
- '</c:filter>'
- );
- $result = $this->parse($xml);
-
- $expected = array(
- 'name' => 'VCALENDAR',
- 'comp-filters' => array(
- array(
- 'name' => 'VEVENT',
- 'is-not-defined' => false,
- 'comp-filters' => array(),
- 'prop-filters' => array(
- array(
- 'name' => 'SUMMARY',
- 'is-not-defined' => false,
- 'param-filters' => array(),
- 'text-match' => array(
- 'negate-condition' => false,
- 'collation' => 'i;ascii-casemap',
- 'value' => 'vacation',
- ),
- 'time-range' => null,
- ),
- ),
- 'time-range' => null,
- ),
- ),
- 'prop-filters' => array(),
- 'is-not-defined' => false,
- 'time-range' => false
- );
-
- $this->assertEquals(
- $expected,
- $result
- );
-
- }
-
- function testComplex() {
-
- $xml = array(
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR">',
- ' <c:comp-filter name="VEVENT">',
- ' <c:prop-filter name="SUMMARY">',
- ' <c:text-match collation="i;unicode-casemap">vacation</c:text-match>',
- ' </c:prop-filter>',
- ' <c:prop-filter name="DTSTAMP">',
- ' <c:time-range start="20110704T000000Z" />',
- ' </c:prop-filter>',
- ' <c:prop-filter name="ORGANIZER">',
- ' <c:is-not-defined />',
- ' </c:prop-filter>',
- ' <c:prop-filter name="DTSTART">',
- ' <c:param-filter name="VALUE">',
- ' <c:text-match negate-condition="yes">DATE</c:text-match>',
- ' </c:param-filter>',
- ' </c:prop-filter>',
- ' </c:comp-filter>',
- ' </c:comp-filter>',
- '</c:filter>'
- );
- $result = $this->parse($xml);
-
- $expected = array(
- 'name' => 'VCALENDAR',
- 'comp-filters' => array(
- array(
- 'name' => 'VEVENT',
- 'is-not-defined' => false,
- 'comp-filters' => array(),
- 'prop-filters' => array(
- array(
- 'name' => 'SUMMARY',
- 'is-not-defined' => false,
- 'param-filters' => array(),
- 'text-match' => array(
- 'negate-condition' => false,
- 'collation' => 'i;unicode-casemap',
- 'value' => 'vacation',
- ),
- 'time-range' => null,
- ),
- array(
- 'name' => 'DTSTAMP',
- 'is-not-defined' => false,
- 'param-filters' => array(),
- 'text-match' => null,
- 'time-range' => array(
- 'start' => new \DateTime('2011-07-04 00:00:00', new \DateTimeZone('GMT')),
- 'end' => null,
- ),
- ),
- array(
- 'name' => 'ORGANIZER',
- 'is-not-defined' => true,
- 'param-filters' => array(),
- 'text-match' => null,
- 'time-range' => null,
- ),
- array(
- 'name' => 'DTSTART',
- 'is-not-defined' => false,
- 'param-filters' => array(
- array(
- 'name' => 'VALUE',
- 'is-not-defined' => false,
- 'text-match' => array(
- 'negate-condition' => true,
- 'value' => 'DATE',
- 'collation' => 'i;ascii-casemap',
- ),
- ),
- ),
- 'text-match' => null,
- 'time-range' => null,
- ),
- ),
- 'time-range' => null,
- ),
- ),
- 'prop-filters' => array(),
- 'is-not-defined' => false,
- 'time-range' => false
- );
-
- $this->assertEquals(
- $expected,
- $result
- );
-
- }
-
- function testOther1() {
-
- // This body was exactly sent to us from the sabredav mailing list. Checking if this parses correctly.
-
- $body = <<<BLA
-<?xml version="1.0" encoding="utf-8" ?>
-<C:calendar-query xmlns:D="DAV:"
-xmlns:C="urn:ietf:params:xml:ns:caldav">
- <D:prop>
- <C:calendar-data/>
- <D:getetag/>
- </D:prop>
- <C:filter>
- <C:comp-filter name="VCALENDAR">
- <C:comp-filter name="VEVENT">
- <C:time-range start="20090101T000000Z" end="20121202T000000Z"/>
- </C:comp-filter>
- </C:comp-filter>
- </C:filter>
-</C:calendar-query>
-BLA;
-
- $dom = DAV\XMLUtil::loadDOMDocument($body);
-
- $q = new CalendarQueryParser($dom);
- $q->parse();
-
- $this->assertEquals(array(
- '{urn:ietf:params:xml:ns:caldav}calendar-data',
- '{DAV:}getetag',
- ), $q->requestedProperties);
-
- $expectedFilters = array(
- 'name' => 'VCALENDAR',
- 'comp-filters' => array(
- array(
- 'name' => 'VEVENT',
- 'comp-filters' => array(),
- 'prop-filters' => array(),
- 'time-range' => array(
- 'start' => new \DateTime('2009-01-01 00:00:00', new \DateTimeZone('UTC')),
- 'end' => new \DateTime('2012-12-02 00:00:00', new \DateTimeZone('UTC')),
- ),
- 'is-not-defined' => false,
- ),
- ),
- 'prop-filters' => array(),
- 'time-range' => null,
- 'is-not-defined' => false,
- );
-
- $this->assertEquals($expectedFilters, $q->filters);
-
- }
-
- function testExpand() {
-
- $xml = array(
- '<d:prop>',
- ' <c:calendar-data>',
- ' <c:expand start="20110101T000000Z" end="20120101T000000Z"/>',
- ' </c:calendar-data>',
- '</d:prop>',
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR" />',
- '</c:filter>'
- );
-
- $xml =
-'<?xml version="1.0"?>
-<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">
-' . implode("\n", $xml) . '
-</c:calendar-query>';
-
- $dom = DAV\XMLUtil::loadDOMDocument($xml);
- $q = new CalendarQueryParser($dom);
- $q->parse();
-
-
- $expected = array(
- 'name' => 'VCALENDAR',
- 'comp-filters' => array(),
- 'prop-filters' => array(),
- 'is-not-defined' => false,
- 'time-range' => false
- );
-
- $this->assertEquals(
- $expected,
- $q->filters
- );
-
- $this->assertEquals(array(
- '{urn:ietf:params:xml:ns:caldav}calendar-data',
- ), $q->requestedProperties);
-
- $this->assertEquals(
- array(
- 'start' => new \DateTime('2011-01-01 00:00:00', new \DateTimeZone('UTC')),
- 'end' => new \DateTime('2012-01-01 00:00:00', new \DateTimeZone('UTC')),
- ),
- $q->expand
- );
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testExpandNoStart() {
-
- $xml = array(
- '<d:prop>',
- ' <c:calendar-data>',
- ' <c:expand end="20120101T000000Z"/>',
- ' </c:calendar-data>',
- '</d:prop>',
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR" />',
- '</c:filter>'
- );
-
- $xml =
-'<?xml version="1.0"?>
-<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">
-' . implode("\n", $xml) . '
-</c:calendar-query>';
-
- $dom = DAV\XMLUtil::loadDOMDocument($xml);
- $q = new CalendarQueryParser($dom);
- $q->parse();
-
- }
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testExpandNoEnd() {
-
- $xml = array(
- '<d:prop>',
- ' <c:calendar-data>',
- ' <c:expand start="20120101T000000Z"/>',
- ' </c:calendar-data>',
- '</d:prop>',
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR" />',
- '</c:filter>'
- );
-
- $xml =
-'<?xml version="1.0"?>
-<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">
-' . implode("\n", $xml) . '
-</c:calendar-query>';
-
- $dom = DAV\XMLUtil::loadDOMDocument($xml);
- $q = new CalendarQueryParser($dom);
- $q->parse();
-
- }
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testExpandBadTimes() {
-
- $xml = array(
- '<d:prop>',
- ' <c:calendar-data>',
- ' <c:expand start="20120101T000000Z" end="19980101T000000Z"/>',
- ' </c:calendar-data>',
- '</d:prop>',
- '<c:filter>',
- ' <c:comp-filter name="VCALENDAR" />',
- '</c:filter>'
- );
-
- $xml =
-'<?xml version="1.0"?>
-<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">
-' . implode("\n", $xml) . '
-</c:calendar-query>';
-
- $dom = DAV\XMLUtil::loadDOMDocument($xml);
- $q = new CalendarQueryParser($dom);
- $q->parse();
-
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php
index deb70d205..9822e82e2 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php
@@ -6,6 +6,20 @@ use Sabre\DAV;
class CalendarQueryValidatorTest extends \PHPUnit_Framework_TestCase {
+ function testTopLevelFail() {
+
+ $validator = new CalendarQueryValidator();
+ $vcal = <<<ICS
+BEGIN:VCALENDAR
+BEGIN:VEVENT
+END:VEVENT
+END:VCALENDAR
+ICS;
+ $vcal = VObject\Reader::read($vcal);
+ $this->assertFalse($validator->validate($vcal, ['name' => 'VFOO']));
+
+ }
+
/**
* @dataProvider provider
*/
@@ -35,10 +49,14 @@ class CalendarQueryValidatorTest extends \PHPUnit_Framework_TestCase {
case -1 :
try {
$validator->validate($vObject, $filters);
- } catch (DAV\Exception $e) {
- // Success
- } catch (\LogicException $e) {
- // Success
+ $this->fail('This test was supposed to fail');
+ } catch (\Exception $e) {
+ // We need to test something to be valid for phpunit strict
+ // mode.
+ $this->assertTrue(true);
+ } catch (\Throwable $e) {
+ // PHP7
+ $this->assertTrue(true);
}
break;
@@ -334,6 +352,7 @@ yow;
$blob31 = <<<yow
BEGIN:VCALENDAR
BEGIN:VEVENT
+UID:foobar
DTSTART:20080101T120000Z
DURATION:PT1H
RRULE:FREQ=YEARLY
@@ -344,6 +363,7 @@ yow;
$blob32 = <<<yow
BEGIN:VCALENDAR
BEGIN:VEVENT
+UID:foobar
DTSTART:20080102T120000Z
DURATION:PT1H
RRULE:FREQ=YEARLY
@@ -353,6 +373,7 @@ yow;
$blob33 = <<<yow
BEGIN:VCALENDAR
BEGIN:VEVENT
+UID:foobar
DTSTART;VALUE=DATE:20120628
RRULE:FREQ=DAILY
END:VEVENT
@@ -361,6 +382,7 @@ yow;
$blob34 = <<<yow
BEGIN:VCALENDAR
BEGIN:VEVENT
+UID:foobar
DTSTART;VALUE=DATE:20120628
RRULE:FREQ=DAILY
BEGIN:VALARM
@@ -667,38 +689,38 @@ yow;
array($blob1, $filter3, 0),
array($blob1, $filter4, 1),
- // Subcomponent check
+ // Subcomponent check (4)
array($blob1, $filter5, 0),
array($blob2, $filter5, 1),
- // Property check
+ // Property checki (6)
array($blob1, $filter6, 1),
array($blob1, $filter7, 0),
array($blob1, $filter8, 0),
array($blob1, $filter9, 1),
- // Subcomponent + property
+ // Subcomponent + property (10)
array($blob2, $filter10, 1),
- // Param filter
+ // Param filter (11)
array($blob3, $filter11, 1),
array($blob3, $filter12, 0),
array($blob3, $filter13, 0),
array($blob3, $filter14, 1),
- // Param + text
+ // Param + text (15)
array($blob3, $filter15, 1),
array($blob3, $filter16, 0),
array($blob3, $filter17, 0),
array($blob3, $filter18, 1),
- // Prop + text
+ // Prop + text (19)
array($blob2, $filter19, 1),
- // Incorrect object (vcard)
+ // Incorrect object (vcard) (20)
array($blob4, $filter1, -1),
- // Time-range for event
+ // Time-range for event (21)
array($blob5, $filter20, 1),
array($blob6, $filter20, 1),
array($blob7, $filter20, 1),
@@ -712,7 +734,7 @@ yow;
array($blob7, $filter23, 0),
array($blob8, $filter23, 0),
- // Time-range for todo
+ // Time-range for todo (31)
array($blob9, $filter24, 1),
array($blob9, $filter25, 0),
array($blob9, $filter26, 1),
@@ -744,7 +766,7 @@ yow;
array($blob16, $filter25, 1),
array($blob16, $filter26, 1),
- // Time-range for journals
+ // Time-range for journals (55)
array($blob17, $filter27, 0),
array($blob17, $filter28, 0),
array($blob18, $filter27, 0),
@@ -752,15 +774,15 @@ yow;
array($blob19, $filter27, 1),
array($blob19, $filter28, 1),
- // Time-range for free-busy
+ // Time-range for free-busy (61)
array($blob20, $filter29, -1),
- // Time-range on property
+ // Time-range on property (62)
array($blob5, $filter30, 1),
array($blob3, $filter37, -1),
array($blob3, $filter30, 0),
- // Time-range on alarm in vevent
+ // Time-range on alarm in vevent (65)
array($blob21, $filter31, 1),
array($blob21, $filter32, 0),
array($blob22, $filter31, 1),
@@ -774,28 +796,28 @@ yow;
array($blob26, $filter31, 1),
array($blob26, $filter32, 0),
- // Time-range on alarm for vtodo
+ // Time-range on alarm for vtodo (77)
array($blob27, $filter33, 1),
array($blob27, $filter34, 0),
- // Time-range on alarm for vjournal
+ // Time-range on alarm for vjournal (79)
array($blob28, $filter35, -1),
array($blob28, $filter36, -1),
- // Time-range on alarm with duration
+ // Time-range on alarm with duration (81)
array($blob29, $filter31, 1),
array($blob29, $filter32, 0),
array($blob30, $filter31, 0),
array($blob30, $filter32, 0),
- // Time-range with RRULE
+ // Time-range with RRULE (85)
array($blob31, $filter20, 1),
array($blob32, $filter20, 0),
- // Bug reported on mailing list, related to all-day events.
- array($blob33, $filter38, 1),
+ // Bug reported on mailing list, related to all-day events (87)
+ //array($blob33, $filter38, 1),
- // Event in timerange, but filtered alarm is in the far future.
+ // Event in timerange, but filtered alarm is in the far future (88).
array($blob34, $filter39, 0),
);
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php
index 2b2690d42..ea744d2cf 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php
@@ -1,6 +1,8 @@
<?php
namespace Sabre\CalDAV;
+
+use Sabre\DAV\PropPatch;
use Sabre\DAVACL;
require_once 'Sabre/CalDAV/TestUtil.php';
@@ -8,7 +10,7 @@ require_once 'Sabre/CalDAV/TestUtil.php';
class CalendarTest extends \PHPUnit_Framework_TestCase {
/**
- * @var Sabre\CalDAV\Backend_PDO
+ * @var Sabre\CalDAV\Backend\PDO
*/
protected $backend;
protected $principalBackend;
@@ -51,9 +53,12 @@ class CalendarTest extends \PHPUnit_Framework_TestCase {
*/
function testUpdateProperties() {
- $result = $this->calendar->updateProperties(array(
+ $propPatch = new PropPatch([
'{DAV:}displayname' => 'NewName',
- ));
+ ]);
+
+ $result = $this->calendar->propPatch($propPatch);
+ $result = $propPatch->commit();
$this->assertEquals(true, $result);
@@ -69,9 +74,6 @@ class CalendarTest extends \PHPUnit_Framework_TestCase {
$question = array(
'{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set',
- '{urn:ietf:params:xml:ns:caldav}supported-calendar-data',
- '{urn:ietf:params:xml:ns:caldav}supported-collation-set',
- '{DAV:}owner',
);
$result = $this->calendar->getProperties($question);
@@ -80,11 +82,6 @@ class CalendarTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals(array('VEVENT','VTODO'), $result['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set']->getValue());
- $this->assertTrue($result['{urn:ietf:params:xml:ns:caldav}supported-collation-set'] instanceof Property\SupportedCollationSet);
-
- $this->assertTrue($result['{DAV:}owner'] instanceof DAVACL\Property\Principal);
- $this->assertEquals('principals/user1', $result['{DAV:}owner']->getHref());
-
}
/**
@@ -202,28 +199,28 @@ class CalendarTest extends \PHPUnit_Framework_TestCase {
'protected' => true,
),
array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/user1',
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/user1/calendar-proxy-write',
'protected' => true,
),
array(
'privilege' => '{DAV:}read',
- 'principal' => 'principals/user1/calendar-proxy-write',
+ 'principal' => 'principals/user1/calendar-proxy-read',
'protected' => true,
),
array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/user1/calendar-proxy-write',
+ 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
+ 'principal' => '{DAV:}authenticated',
'protected' => true,
),
array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/user1/calendar-proxy-read',
+ 'privilege' => '{DAV:}write',
+ 'principal' => 'principals/user1',
'protected' => true,
),
array(
- 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
- 'principal' => '{DAV:}authenticated',
+ 'privilege' => '{DAV:}write',
+ 'principal' => 'principals/user1/calendar-proxy-write',
'protected' => true,
),
);
@@ -251,5 +248,42 @@ class CalendarTest extends \PHPUnit_Framework_TestCase {
}
+ function testGetSyncToken() {
+
+ $this->assertEquals(2, $this->calendar->getSyncToken());
+
+ }
+ function testGetSyncToken2() {
+
+ $calendar = new Calendar(new Backend\Mock([],[]), [
+ '{DAV:}sync-token' => 2
+ ]);
+ $this->assertEquals(2, $this->calendar->getSyncToken());
+
+ }
+
+ function testGetSyncTokenNoSyncSupport() {
+
+ $calendar = new Calendar(new Backend\Mock([],[]), []);
+ $this->assertNull($calendar->getSyncToken());
+ }
+
+ function testGetChanges() {
+
+ $this->assertEquals([
+ 'syncToken' => 2,
+ 'modified' => [],
+ 'deleted' => [],
+ 'added' => ['UUID-2345'],
+ ], $this->calendar->getChanges(1, 1));
+
+ }
+
+ function testGetChangesNoSyncSupport() {
+
+ $calendar = new Calendar(new Backend\Mock([],[]), []);
+ $this->assertNull($calendar->getChanges(1,null));
+
+ }
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php
index 2767b5f8d..9a3d47828 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php
@@ -1,6 +1,7 @@
<?php
namespace Sabre\CalDAV;
+
use Sabre\HTTP;
use Sabre\VObject;
@@ -8,7 +9,7 @@ use Sabre\VObject;
* This unittests is created to find out why recurring events have wrong DTSTART value
*
*
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -16,18 +17,18 @@ class ExpandEventsDTSTARTandDTENDTest extends \Sabre\DAVServerTest {
protected $setupCalDAV = true;
- protected $caldavCalendars = array(
- array(
- 'id' => 1,
- 'name' => 'Calendar',
+ protected $caldavCalendars = [
+ [
+ 'id' => 1,
+ 'name' => 'Calendar',
'principaluri' => 'principals/user1',
- 'uri' => 'calendar1',
- )
- );
+ 'uri' => 'calendar1',
+ ]
+ ];
- protected $caldavCalendarObjects = array(
- 1 => array(
- 'event.ics' => array(
+ protected $caldavCalendarObjects = [
+ 1 => [
+ 'event.ics' => [
'calendardata' => 'BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
@@ -47,18 +48,18 @@ RECURRENCE-ID;TZID=Europe/Berlin:20120208T181500
END:VEVENT
END:VCALENDAR
',
- ),
- ),
- );
+ ],
+ ],
+ ];
function testExpand() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
+ $request = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
- 'REQUEST_URI' => '/calendars/user1/calendar1',
- 'HTTP_DEPTH' => '1',
- ));
+ 'REQUEST_URI' => '/calendars/user1/calendar1',
+ 'HTTP_DEPTH' => '1',
+ ]);
$request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
@@ -85,26 +86,28 @@ END:VCALENDAR
$start = strpos($response->body, 'BEGIN:VCALENDAR'),
strpos($response->body, 'END:VCALENDAR') - $start + 13
);
- $body = str_replace('&#13;','',$body);
+ $body = str_replace('&#13;', '', $body);
- $vObject = VObject\Reader::read($body);
+ try {
+ $vObject = VObject\Reader::read($body);
+ } catch (VObject\ParseException $e) {
+ $this->fail('Could not parse object. Error:' . $e->getMessage() . ' full object: ' . $response->getBodyAsString());
+ }
// check if DTSTARTs and DTENDs are correct
foreach ($vObject->VEVENT as $vevent) {
/** @var $vevent Sabre\VObject\Component\VEvent */
- foreach ($vevent->children as $child) {
+ foreach ($vevent->children() as $child) {
/** @var $child Sabre\VObject\Property */
-
if ($child->name == 'DTSTART') {
// DTSTART has to be one of three valid values
- $this->assertContains($child->getValue(), array('20120207T171500Z', '20120208T171500Z', '20120209T171500Z'), 'DTSTART is not a valid value: '.$child->getValue());
+ $this->assertContains($child->getValue(), ['20120207T171500Z', '20120208T171500Z', '20120209T171500Z'], 'DTSTART is not a valid value: ' . $child->getValue());
} elseif ($child->name == 'DTEND') {
// DTEND has to be one of three valid values
- $this->assertContains($child->getValue(), array('20120207T181500Z', '20120208T181500Z', '20120209T181500Z'), 'DTEND is not a valid value: '.$child->getValue());
+ $this->assertContains($child->getValue(), ['20120207T181500Z', '20120208T181500Z', '20120209T181500Z'], 'DTEND is not a valid value: ' . $child->getValue());
}
}
}
}
}
-
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php
index 3793cadc7..efc49673f 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php
@@ -1,13 +1,14 @@
<?php
namespace Sabre\CalDAV;
+
use Sabre\HTTP;
use Sabre\VObject;
/**
* This unittests is created to find out why recurring events have wrong DTSTART value
*
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -15,18 +16,18 @@ class ExpandEventsDTSTARTandDTENDbyDayTest extends \Sabre\DAVServerTest {
protected $setupCalDAV = true;
- protected $caldavCalendars = array(
- array(
- 'id' => 1,
- 'name' => 'Calendar',
+ protected $caldavCalendars = [
+ [
+ 'id' => 1,
+ 'name' => 'Calendar',
'principaluri' => 'principals/user1',
- 'uri' => 'calendar1',
- )
- );
+ 'uri' => 'calendar1',
+ ]
+ ];
- protected $caldavCalendarObjects = array(
- 1 => array(
- 'event.ics' => array(
+ protected $caldavCalendarObjects = [
+ 1 => [
+ 'event.ics' => [
'calendardata' => 'BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
@@ -38,18 +39,18 @@ DTSTART;TZID=Europe/Berlin:20120207T181500
END:VEVENT
END:VCALENDAR
',
- ),
- ),
- );
+ ],
+ ],
+ ];
function testExpandRecurringByDayEvent() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
+ $request = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
- 'REQUEST_URI' => '/calendars/user1/calendar1',
- 'HTTP_DEPTH' => '1',
- ));
+ 'REQUEST_URI' => '/calendars/user1/calendar1',
+ 'HTTP_DEPTH' => '1',
+ ]);
$request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
@@ -76,7 +77,7 @@ END:VCALENDAR
$start = strpos($response->body, 'BEGIN:VCALENDAR'),
strpos($response->body, 'END:VCALENDAR') - $start + 13
);
- $body = str_replace('&#13;','',$body);
+ $body = str_replace('&#13;', '', $body);
$vObject = VObject\Reader::read($body);
@@ -85,19 +86,17 @@ END:VCALENDAR
// check if DTSTARTs and DTENDs are correct
foreach ($vObject->VEVENT as $vevent) {
/** @var $vevent Sabre\VObject\Component\VEvent */
- foreach ($vevent->children as $child) {
+ foreach ($vevent->children() as $child) {
/** @var $child Sabre\VObject\Property */
-
if ($child->name == 'DTSTART') {
// DTSTART has to be one of two valid values
- $this->assertContains($child->getValue(), array('20120214T171500Z', '20120216T171500Z'), 'DTSTART is not a valid value: '.$child->getValue());
+ $this->assertContains($child->getValue(), ['20120214T171500Z', '20120216T171500Z'], 'DTSTART is not a valid value: ' . $child->getValue());
} elseif ($child->name == 'DTEND') {
// DTEND has to be one of two valid values
- $this->assertContains($child->getValue(), array('20120214T181500Z', '20120216T181500Z'), 'DTEND is not a valid value: '.$child->getValue());
+ $this->assertContains($child->getValue(), ['20120214T181500Z', '20120216T181500Z'], 'DTEND is not a valid value: ' . $child->getValue());
}
}
}
}
}
-
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php
index 09eea5276..b64fb122a 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php
@@ -11,7 +11,7 @@ use Sabre\VObject;
* Hopefully, by the time I'm done with this, I've both found the problem, and
* fixed it :)
*
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -56,12 +56,12 @@ END:VCALENDAR
function testExpand() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
'REQUEST_URI' => '/calendars/user1/calendar1',
'HTTP_DEPTH' => '1',
- ));
+ ]);
$request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php
index 93eca9ee9..84f05f3c0 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php
@@ -30,6 +30,7 @@ DURATION:PT1H
END:VEVENT
END:VCALENDAR
ics;
+
$obj2 = fopen('php://memory','r+');
fwrite($obj2,<<<ics
BEGIN:VCALENDAR
@@ -42,41 +43,55 @@ ics
);
rewind($obj2);
- $calendarData = array(
- 1 => array(
- 'obj1' => array(
+ $obj3 = <<<ics
+BEGIN:VCALENDAR
+BEGIN:VEVENT
+DTSTART:20111006T120000
+DURATION:PT1H
+END:VEVENT
+END:VCALENDAR
+ics;
+
+ $calendarData = [
+ 1 => [
+ 'obj1' => [
'calendarid' => 1,
'uri' => 'event1.ics',
'calendardata' => $obj1,
- ),
- 'obj2' => array(
+ ],
+ 'obj2' => [
'calendarid' => 1,
'uri' => 'event2.ics',
'calendardata' => $obj2
- )
- ),
- );
+ ],
+ 'obj3' => [
+ 'calendarid' => 1,
+ 'uri' => 'event3.ics',
+ 'calendardata' => $obj3
+ ]
+ ],
+ ];
- $caldavBackend = new Backend\Mock(array(), $calendarData);
+ $caldavBackend = new Backend\Mock([], $calendarData);
- $calendar = new Calendar($caldavBackend, array(
+ $calendar = new Calendar($caldavBackend, [
'id' => 1,
'uri' => 'calendar',
'principaluri' => 'principals/user1',
- ));
+ '{' . Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR",
+ ]);
- $this->server = new DAV\Server(array($calendar));
+ $this->server = new DAV\Server([$calendar]);
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray([
'REQUEST_URI' => '/calendar',
- ));
+ ]);
$this->server->httpRequest = $request;
$this->server->httpResponse = new HTTP\ResponseMock();
$this->plugin = new Plugin();
$this->server->addPlugin($this->plugin);
- $this->server->addPlugin(new DAVACL\Plugin());
}
@@ -89,12 +104,14 @@ ics
</c:free-busy-query>
XML;
- $dom = DAV\XMLUtil::loadDOMDocument($reportXML);
- $this->plugin->report('{urn:ietf:params:xml:ns:caldav}free-busy-query', $dom);
+ $report = $this->server->xml->parse($reportXML, null, $rootElem);
+ $this->plugin->report($rootElem, $report);
- $this->assertEquals('HTTP/1.1 200 OK', $this->server->httpResponse->status);
- $this->assertEquals('text/calendar', $this->server->httpResponse->headers['Content-Type']);
- $this->assertTrue(strpos($this->server->httpResponse->body,'BEGIN:VFREEBUSY')!==false);
+ $this->assertEquals(200, $this->server->httpResponse->status);
+ $this->assertEquals('text/calendar', $this->server->httpResponse->getHeader('Content-Type'));
+ $this->assertTrue(strpos($this->server->httpResponse->body, 'BEGIN:VFREEBUSY')!==false);
+ $this->assertTrue(strpos($this->server->httpResponse->body, '20111005T120000Z/20111005T130000Z')!==false);
+ $this->assertTrue(strpos($this->server->httpResponse->body, '20111006T100000Z/20111006T110000Z')!==false);
}
@@ -109,8 +126,8 @@ XML;
</c:free-busy-query>
XML;
- $dom = DAV\XMLUtil::loadDOMDocument($reportXML);
- $this->plugin->report('{urn:ietf:params:xml:ns:caldav}free-busy-query', $dom);
+ $report = $this->server->xml->parse($reportXML, null, $rootElem);
+ $this->plugin->report($rootElem, $report);
}
@@ -119,7 +136,7 @@ XML;
*/
function testFreeBusyReportWrongNode() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_URI' => '/',
));
$this->server->httpRequest = $request;
@@ -131,8 +148,8 @@ XML;
</c:free-busy-query>
XML;
- $dom = DAV\XMLUtil::loadDOMDocument($reportXML);
- $this->plugin->report('{urn:ietf:params:xml:ns:caldav}free-busy-query', $dom);
+ $report = $this->server->xml->parse($reportXML, null, $rootElem);
+ $this->plugin->report($rootElem, $report);
}
@@ -152,8 +169,8 @@ XML;
</c:free-busy-query>
XML;
- $dom = DAV\XMLUtil::loadDOMDocument($reportXML);
- $this->plugin->report('{urn:ietf:params:xml:ns:caldav}free-busy-query', $dom);
+ $report = $this->server->xml->parse($reportXML, null, $rootElem);
+ $this->plugin->report($rootElem, $report);
}
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php
deleted file mode 100644
index 62252e6a1..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php
+++ /dev/null
@@ -1,282 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV;
-
-use Sabre\DAV;
-use Sabre\DAVACL;
-use Sabre\HTTP;
-
-require_once 'Sabre/HTTP/ResponseMock.php';
-
-class FreeBusyRequestTest extends \PHPUnit_Framework_TestCase {
-
- protected $plugin;
- protected $server;
- protected $aclPlugin;
- protected $request;
- protected $authPlugin;
-
- function setUp() {
-
- $calendars = array(
- array(
- 'principaluri' => 'principals/user2',
- 'id' => 1,
- 'uri' => 'calendar1',
- ),
- );
- $calendarobjects = array(
- 1 => array( '1.ics' => array(
- 'uri' => '1.ics',
- 'calendardata' => 'BEGIN:VCALENDAR
-BEGIN:VEVENT
-DTSTART:20110101T130000
-DURATION:PT1H
-END:VEVENT
-END:VCALENDAR',
- 'calendarid' => 1,
- ))
-
- );
-
- $principalBackend = new DAVACL\PrincipalBackend\Mock();
- $caldavBackend = new Backend\Mock($calendars, $calendarobjects);
-
- $tree = array(
- new DAVACL\PrincipalCollection($principalBackend),
- new CalendarRootNode($principalBackend, $caldavBackend),
- );
-
- $this->request = new HTTP\Request(array(
- 'CONTENT_TYPE' => 'text/calendar',
- ));
- $this->response = new HTTP\ResponseMock();
-
- $this->server = new DAV\Server($tree);
- $this->server->httpRequest = $this->request;
- $this->server->httpResponse = $this->response;
-
- $this->aclPlugin = new DAVACL\Plugin();
- $this->server->addPlugin($this->aclPlugin);
-
- $authBackend = new DAV\Auth\Backend\Mock();
- $authBackend->setCurrentUser('user1');
- $this->authPlugin = new DAV\Auth\Plugin($authBackend,'SabreDAV');
- $this->server->addPlugin($this->authPlugin);
-
- $this->plugin = new Plugin();
- $this->server->addPlugin($this->plugin);
-
- }
-
- function testWrongMethod() {
-
- $this->assertNull(
- $this->plugin->unknownMethod('PUT','calendars/user1/outbox')
- );
-
- }
-
- function testWrongContentType() {
-
- $this->server->httpRequest = new HTTP\Request(array(
- 'CONTENT_TYPE' => 'text/plain',
- ));
-
- $this->assertNull(
- $this->plugin->unknownMethod('POST','calendars/user1/outbox')
- );
-
- }
-
- function testNotFound() {
-
- $this->assertNull(
- $this->plugin->unknownMethod('POST','calendars/user1/blabla')
- );
-
- }
-
- function testNotOutbox() {
-
- $this->assertNull(
- $this->plugin->unknownMethod('POST','calendars/user1/inbox')
- );
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testNoItipMethod() {
-
- $body = <<<ICS
-BEGIN:VCALENDAR
-BEGIN:VFREEBUSY
-END:VFREEBUSY
-END:VCALENDAR
-ICS;
-
- $this->request->setBody($body);
- $this->plugin->unknownMethod('POST','calendars/user1/outbox');
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testNoVFreeBusy() {
-
- $body = <<<ICS
-BEGIN:VCALENDAR
-METHOD:REQUEST
-BEGIN:VEVENT
-END:VEVENT
-END:VCALENDAR
-ICS;
-
- $this->request->setBody($body);
- $this->plugin->unknownMethod('POST','calendars/user1/outbox');
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\Forbidden
- */
- function testIncorrectOrganizer() {
-
- $body = <<<ICS
-BEGIN:VCALENDAR
-METHOD:REQUEST
-BEGIN:VFREEBUSY
-ORGANIZER:mailto:john@wayne.org
-END:VFREEBUSY
-END:VCALENDAR
-ICS;
-
- $this->request->setBody($body);
- $this->plugin->unknownMethod('POST','calendars/user1/outbox');
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testNoAttendees() {
-
- $body = <<<ICS
-BEGIN:VCALENDAR
-METHOD:REQUEST
-BEGIN:VFREEBUSY
-ORGANIZER:mailto:user1.sabredav@sabredav.org
-END:VFREEBUSY
-END:VCALENDAR
-ICS;
-
- $this->request->setBody($body);
- $this->plugin->unknownMethod('POST','calendars/user1/outbox');
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testNoDTStart() {
-
- $body = <<<ICS
-BEGIN:VCALENDAR
-METHOD:REQUEST
-BEGIN:VFREEBUSY
-ORGANIZER:mailto:user1.sabredav@sabredav.org
-ATTENDEE:mailto:user2.sabredav@sabredav.org
-END:VFREEBUSY
-END:VCALENDAR
-ICS;
-
- $this->request->setBody($body);
- $this->plugin->unknownMethod('POST','calendars/user1/outbox');
-
- }
-
- function testSucceed() {
-
- $body = <<<ICS
-BEGIN:VCALENDAR
-METHOD:REQUEST
-BEGIN:VFREEBUSY
-ORGANIZER:mailto:user1.sabredav@sabredav.org
-ATTENDEE:mailto:user2.sabredav@sabredav.org
-ATTENDEE:mailto:user3.sabredav@sabredav.org
-DTSTART:20110101T080000Z
-DTEND:20110101T180000Z
-END:VFREEBUSY
-END:VCALENDAR
-ICS;
-
- // Lazily making the current principal an admin.
- $this->aclPlugin->adminPrincipals[] = 'principals/user1';
-
- $this->request->setBody($body);
- $this->assertFalse($this->plugin->unknownMethod('POST','calendars/user1/outbox'));
-
- $this->assertEquals('HTTP/1.1 200 OK' , $this->response->status);
- $this->assertEquals(array(
- 'Content-Type' => 'application/xml',
- ), $this->response->headers);
-
- $strings = array(
- '<d:href>mailto:user2.sabredav@sabredav.org</d:href>',
- '<d:href>mailto:user3.sabredav@sabredav.org</d:href>',
- '<cal:request-status>2.0;Success</cal:request-status>',
- '<cal:request-status>3.7;Could not find principal</cal:request-status>',
- 'FREEBUSY;FBTYPE=BUSY:20110101T130000Z/20110101T140000Z',
- );
-
- foreach($strings as $string) {
- $this->assertTrue(
- strpos($this->response->body, $string)!==false,
- 'The response body did not contain: ' . $string .'Full response: ' . $this->response->body
- );
- }
-
-
- }
-
- function testNoPrivilege() {
-
- $body = <<<ICS
-BEGIN:VCALENDAR
-METHOD:REQUEST
-BEGIN:VFREEBUSY
-ORGANIZER:mailto:user1.sabredav@sabredav.org
-ATTENDEE:mailto:user2.sabredav@sabredav.org
-DTSTART:20110101T080000Z
-DTEND:20110101T180000Z
-END:VFREEBUSY
-END:VCALENDAR
-ICS;
-
- $this->request->setBody($body);
- $this->assertFalse($this->plugin->unknownMethod('POST','calendars/user1/outbox'));
-
- $this->assertEquals('HTTP/1.1 200 OK' , $this->response->status);
- $this->assertEquals(array(
- 'Content-Type' => 'application/xml',
- ), $this->response->headers);
-
- $strings = array(
- '<d:href>mailto:user2.sabredav@sabredav.org</d:href>',
- '<cal:request-status>3.7;No calendar-home-set property found</cal:request-status>',
- );
-
- foreach($strings as $string) {
- $this->assertTrue(
- strpos($this->response->body, $string)!==false,
- 'The response body did not contain: ' . $string .'Full response: ' . $this->response->body
- );
- }
-
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php
index 6c9a09905..c3c97e8f6 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php
@@ -1,13 +1,13 @@
<?php
namespace Sabre\CalDAV;
+
use Sabre\HTTP;
-use Sabre\VObject;
/**
* This unittest is created to check if queries for time-range include the start timestamp or not
*
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -15,24 +15,24 @@ class GetEventsByTimerangeTest extends \Sabre\DAVServerTest {
protected $setupCalDAV = true;
- protected $caldavCalendars = array(
- array(
- 'id' => 1,
- 'name' => 'Calendar',
+ protected $caldavCalendars = [
+ [
+ 'id' => 1,
+ 'name' => 'Calendar',
'principaluri' => 'principals/user1',
- 'uri' => 'calendar1',
- )
- );
+ 'uri' => 'calendar1',
+ ]
+ ];
- protected $caldavCalendarObjects = array(
- 1 => array(
- 'event.ics' => array(
+ protected $caldavCalendarObjects = [
+ 1 => [
+ 'event.ics' => [
'calendardata' => 'BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
CREATED:20120313T142342Z
UID:171EBEFC-C951-499D-B234-7BA7D677B45D
-DTEND;TZID=Europe/Berlin:20120227T000000
+DTEND;TZID=Europe/Berlin:20120227T010000
TRANSP:OPAQUE
SUMMARY:Monday 0h
DTSTART;TZID=Europe/Berlin:20120227T000000
@@ -41,31 +41,33 @@ SEQUENCE:4
END:VEVENT
END:VCALENDAR
',
- ),
- ),
- );
+ ],
+ ],
+ ];
function testQueryTimerange() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_CONTENT_TYPE' => 'application/xml',
- 'REQUEST_URI' => '/calendars/user1/calendar1',
- 'HTTP_DEPTH' => '1',
- ));
+ $request = new HTTP\Request(
+ 'REPORT',
+ '/calendars/user1/calendar1',
+ [
+ 'Content-Type' => 'application/xml',
+ 'Depth' => '1',
+ ]
+ );
$request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
<D:prop>
<C:calendar-data>
- <C:expand start="20120226T230000Z" end="20120228T225959Z"/>
+ <C:expand start="20120226T220000Z" end="20120228T225959Z"/>
</C:calendar-data>
<D:getetag/>
</D:prop>
<C:filter>
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VEVENT">
- <C:time-range start="20120226T230000Z" end="20120228T225959Z"/>
+ <C:time-range start="20120226T220000Z" end="20120228T225959Z"/>
</C:comp-filter>
</C:comp-filter>
</C:filter>
@@ -73,24 +75,8 @@ END:VCALENDAR
$response = $this->request($request);
- if (strpos($response->body, 'BEGIN:VCALENDAR') === false) {
- $this->fail('Got no events instead of 1. Output: '.$response->body);
- }
-
- // Everts super awesome xml parser.
- $body = substr(
- $response->body,
- $start = strpos($response->body, 'BEGIN:VCALENDAR'),
- strpos($response->body, 'END:VCALENDAR') - $start + 13
- );
- $body = str_replace('&#13;','',$body);
-
- $vObject = VObject\Reader::read($body);
-
- // We expect 1 event
- $this->assertEquals(1, count($vObject->VEVENT), 'We got 0 events instead of 1. Output: ' . $body);
+ $this->assertTrue(strpos($response->body, 'BEGIN:VCALENDAR')!==false);
}
}
-
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php
index be21796dd..c123bd0c1 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php
@@ -12,27 +12,36 @@ require_once 'Sabre/HTTP/ResponseMock.php';
class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
+ function setUp() {
+
+ if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
+
+ }
+
function testInit() {
$p = new ICSExportPlugin();
$s = new DAV\Server();
$s->addPlugin($p);
+ $this->assertEquals($p, $s->getPlugin('ics-export'));
+ $this->assertEquals('ics-export', $p->getPluginInfo()['name']);
}
function testBeforeMethod() {
- if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
$cbackend = TestUtil::getBackend();
- $props = array(
+ $props = [
'uri'=>'UUID-123467',
'principaluri' => 'admin',
'id' => 1,
- );
- $tree = array(
+ '{DAV:}displayname' => 'Hello!',
+ '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF',
+ ];
+ $tree = [
new Calendar($cbackend,$props),
- );
+ ];
$p = new ICSExportPlugin();
@@ -40,29 +49,32 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
$s->addPlugin($p);
$s->addPlugin(new Plugin());
- $h = new HTTP\Request(array(
- 'QUERY_STRING' => 'export',
- ));
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
$s->httpRequest = $h;
$s->httpResponse = new HTTP\ResponseMock();
- $this->assertFalse($p->beforeMethod('GET','UUID-123467?export'));
+ $this->assertFalse($p->httpGet($h, $s->httpResponse));
- $this->assertEquals('HTTP/1.1 200 OK',$s->httpResponse->status);
- $this->assertEquals(array(
- 'Content-Type' => 'text/calendar',
- ), $s->httpResponse->headers);
+ $this->assertEquals(200, $s->httpResponse->status);
+ $this->assertEquals([
+ 'Content-Type' => ['text/calendar'],
+ ], $s->httpResponse->getHeaders());
$obj = VObject\Reader::read($s->httpResponse->body);
- $this->assertEquals(5,count($obj->children()));
+ $this->assertEquals(7,count($obj->children()));
$this->assertEquals(1,count($obj->VERSION));
$this->assertEquals(1,count($obj->CALSCALE));
$this->assertEquals(1,count($obj->PRODID));
$this->assertTrue(strpos((string)$obj->PRODID, DAV\Version::VERSION)!==false);
$this->assertEquals(1,count($obj->VTIMEZONE));
$this->assertEquals(1,count($obj->VEVENT));
+ $this->assertEquals("Hello!", $obj->{"X-WR-CALNAME"});
+ $this->assertEquals("#AA0000FF", $obj->{"X-APPLE-CALENDAR-COLOR"});
}
function testBeforeMethodNoVersion() {
@@ -70,14 +82,14 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
$cbackend = TestUtil::getBackend();
- $props = array(
+ $props = [
'uri'=>'UUID-123467',
'principaluri' => 'admin',
'id' => 1,
- );
- $tree = array(
+ ];
+ $tree = [
new Calendar($cbackend,$props),
- );
+ ];
$p = new ICSExportPlugin();
@@ -86,21 +98,22 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
$s->addPlugin($p);
$s->addPlugin(new Plugin());
- $h = new HTTP\Request(array(
- 'QUERY_STRING' => 'export',
- ));
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
$s->httpRequest = $h;
$s->httpResponse = new HTTP\ResponseMock();
DAV\Server::$exposeVersion = false;
- $this->assertFalse($p->beforeMethod('GET','UUID-123467?export'));
+ $this->assertFalse($p->httpGet($h, $s->httpResponse));
DAV\Server::$exposeVersion = true;
- $this->assertEquals('HTTP/1.1 200 OK',$s->httpResponse->status);
- $this->assertEquals(array(
- 'Content-Type' => 'text/calendar',
- ), $s->httpResponse->headers);
+ $this->assertEquals(200, $s->httpResponse->status);
+ $this->assertEquals([
+ 'Content-Type' => ['text/calendar'],
+ ], $s->httpResponse->getHeaders());
$obj = VObject\Reader::read($s->httpResponse->body);
@@ -114,17 +127,6 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
}
- function testBeforeMethodNoGET() {
-
- $p = new ICSExportPlugin();
-
- $s = new DAV\Server();
- $s->addPlugin($p);
-
- $this->assertNull($p->beforeMethod('POST','UUID-123467?export'));
-
- }
-
function testBeforeMethodNoExport() {
$p = new ICSExportPlugin();
@@ -132,16 +134,16 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
$s = new DAV\Server();
$s->addPlugin($p);
- $this->assertNull($p->beforeMethod('GET','UUID-123467'));
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+ $this->assertNull($p->httpGet($h, $s->httpResponse));
}
- /**
- * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
- */
function testACLIntegrationBlocked() {
- if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
$cbackend = TestUtil::getBackend();
$props = array(
@@ -160,20 +162,24 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
$s->addPlugin(new Plugin());
$s->addPlugin(new DAVACL\Plugin());
- $h = new HTTP\Request(array(
- 'QUERY_STRING' => 'export',
- ));
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export',
+ ]);
$s->httpRequest = $h;
$s->httpResponse = new HTTP\ResponseMock();
- $p->beforeMethod('GET','UUID-123467?export');
+ $p->httpGet($h, $s->httpResponse);
+
+ // If the ACL system blocked this request, the effect will be that
+ // there's no response, because the calendar information could not be
+ // fetched.
+ $this->assertNull($s->httpResponse->getStatus());
}
function testACLIntegrationNotBlocked() {
- if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
$cbackend = TestUtil::getBackend();
$pbackend = new DAVACL\PrincipalBackend\Mock();
@@ -190,6 +196,7 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
$p = new ICSExportPlugin();
$s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
$s->addPlugin($p);
$s->addPlugin(new Plugin());
$s->addPlugin(new DAVACL\Plugin());
@@ -198,21 +205,22 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
// Forcing login
$s->getPlugin('acl')->adminPrincipals = array('principals/admin');
- $h = new HTTP\Request(array(
- 'QUERY_STRING' => 'export',
- 'REQUEST_URI' => '/UUID-123467',
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export',
'REQUEST_METHOD' => 'GET',
- ));
+ ]);
$s->httpRequest = $h;
$s->httpResponse = new HTTP\ResponseMock();
$s->exec();
- $this->assertEquals('HTTP/1.1 200 OK',$s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+ $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
$this->assertEquals(array(
- 'Content-Type' => 'text/calendar',
- ), $s->httpResponse->headers);
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Type' => ['text/calendar'],
+ ), $s->httpResponse->getHeaders());
$obj = VObject\Reader::read($s->httpResponse->body);
@@ -224,4 +232,432 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals(1,count($obj->VEVENT));
}
+
+ function testBadStartParam() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = array(
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ );
+ $tree = array(
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ );
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export&start=foo',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(400, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+
+ }
+
+ function testBadEndParam() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = array(
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ );
+ $tree = array(
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ );
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export&end=foo',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(400, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+
+ }
+
+ function testFilterStartEnd() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = array(
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ );
+ $tree = array(
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ );
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export&start=1&end=2',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+ $obj = VObject\Reader::read($s->httpResponse->body);
+
+ $this->assertEquals(0,count($obj->VTIMEZONE));
+ $this->assertEquals(0,count($obj->VEVENT));
+
+ }
+
+ function testExpandNoStart() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = array(
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ );
+ $tree = array(
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ );
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export&expand=1&end=1',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(400, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+
+ }
+
+ function testExpand() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = array(
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ );
+ $tree = array(
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ );
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export&start=1&end=2000000000&expand=1',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+ $obj = VObject\Reader::read($s->httpResponse->body);
+
+ $this->assertEquals(0,count($obj->VTIMEZONE));
+ $this->assertEquals(1,count($obj->VEVENT));
+
+ }
+
+ function testJCal() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = array(
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ );
+ $tree = array(
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ );
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_ACCEPT' => 'application/calendar+json',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+ $this->assertEquals('application/calendar+json', $s->httpResponse->getHeader('Content-Type'));
+
+ }
+
+ function testJCalInUrl() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = array(
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ );
+ $tree = array(
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ );
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export&accept=jcal',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+ $this->assertEquals('application/calendar+json', $s->httpResponse->getHeader('Content-Type'));
+
+ }
+
+ function testNegotiateDefault() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = array(
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ );
+ $tree = array(
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ );
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_ACCEPT' => 'text/plain',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+ $this->assertEquals('text/calendar', $s->httpResponse->getHeader('Content-Type'));
+
+ }
+
+ function testFilterComponentVEVENT() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = array(
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ );
+ // add a todo to the calendar (see /tests/Sabre/TestUtil)
+ $cbackend->createCalendarObject(1, 'UUID-3456', TestUtil::getTestTODO());
+
+ $tree = array(
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ );
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export&componentType=VEVENT',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+ $obj = VObject\Reader::read($s->httpResponse->body);
+
+ $this->assertEquals(1,count($obj->VTIMEZONE));
+ $this->assertEquals(1,count($obj->VEVENT));
+ $this->assertEquals(0,count($obj->VTODO));
+
+ }
+
+ function testFilterComponentVTODO() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = [
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ ];
+ // add a todo to the calendar (see /tests/Sabre/TestUtil)
+ $cbackend->createCalendarObject(1, 'UUID-3456', TestUtil::getTestTODO());
+
+ $tree = [
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ ];
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export&componentType=VTODO',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+ $obj = VObject\Reader::read($s->httpResponse->body);
+
+ $this->assertEquals(0,count($obj->VTIMEZONE));
+ $this->assertEquals(0,count($obj->VEVENT));
+ $this->assertEquals(1,count($obj->VTODO));
+
+ }
+
+ function testFilterComponentBadComponent() {
+
+ $cbackend = TestUtil::getBackend();
+ $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+ $props = [
+ 'uri'=>'UUID-123467',
+ 'principaluri' => 'admin',
+ 'id' => 1,
+ ];
+ // add a todo to the calendar (see /tests/Sabre/TestUtil)
+ $cbackend->createCalendarObject(1, 'UUID-3456', TestUtil::getTestTODO());
+
+ $tree = [
+ new Calendar($cbackend,$props),
+ new DAVACL\PrincipalCollection($pbackend),
+ ];
+
+ $p = new ICSExportPlugin();
+
+ $s = new DAV\Server($tree);
+ $s->sapi = new HTTP\SapiMock();
+ $s->addPlugin($p);
+ $s->addPlugin(new Plugin());
+
+ $h = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_URI' => '/UUID-123467?export&componentType=VVOODOO',
+ 'REQUEST_METHOD' => 'GET',
+ ]);
+
+ $s->httpRequest = $h;
+ $s->httpResponse = new HTTP\ResponseMock();
+
+ $s->exec();
+
+ $this->assertEquals(400, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+
+ }
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php
index 21ee2f550..369e9a70c 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php
@@ -1,14 +1,14 @@
<?php
namespace Sabre\CalDAV;
+
use Sabre\HTTP;
use Sabre\VObject;
/**
* This unittest is created to find out why an overwritten DAILY event has wrong DTSTART, DTEND, SUMMARY and RECURRENCEID
*
- *
- * @copyright Copyright (C) 2007-2014 Rooftop Solutions. All rights reserved.
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -16,18 +16,18 @@ class Issue203Test extends \Sabre\DAVServerTest {
protected $setupCalDAV = true;
- protected $caldavCalendars = array(
- array(
- 'id' => 1,
- 'name' => 'Calendar',
+ protected $caldavCalendars = [
+ [
+ 'id' => 1,
+ 'name' => 'Calendar',
'principaluri' => 'principals/user1',
- 'uri' => 'calendar1',
- )
- );
+ 'uri' => 'calendar1',
+ ]
+ ];
- protected $caldavCalendarObjects = array(
- 1 => array(
- 'event.ics' => array(
+ protected $caldavCalendarObjects = [
+ 1 => [
+ 'event.ics' => [
'calendardata' => 'BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
@@ -52,18 +52,18 @@ TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
',
- ),
- ),
- );
+ ],
+ ],
+ ];
function testIssue203() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
+ $request = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
- 'REQUEST_URI' => '/calendars/user1/calendar1',
- 'HTTP_DEPTH' => '1',
- ));
+ 'REQUEST_URI' => '/calendars/user1/calendar1',
+ 'HTTP_DEPTH' => '1',
+ ]);
$request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
@@ -90,26 +90,26 @@ END:VCALENDAR
$start = strpos($response->body, 'BEGIN:VCALENDAR'),
strpos($response->body, 'END:VCALENDAR') - $start + 13
);
- $body = str_replace('&#13;','',$body);
+ $body = str_replace('&#13;', '', $body);
$vObject = VObject\Reader::read($body);
$this->assertEquals(2, count($vObject->VEVENT));
- $expectedEvents = array(
- array(
+ $expectedEvents = [
+ [
'DTSTART' => '20120326T135200Z',
'DTEND' => '20120326T145200Z',
'SUMMARY' => 'original summary',
- ),
- array(
+ ],
+ [
'DTSTART' => '20120328T135200Z',
'DTEND' => '20120328T145200Z',
'SUMMARY' => 'overwritten summary',
'RECURRENCE-ID' => '20120327T135200Z',
- )
- );
+ ]
+ ];
// try to match agains $expectedEvents array
foreach ($expectedEvents as $expectedEvent) {
@@ -118,10 +118,8 @@ END:VCALENDAR
foreach ($vObject->VEVENT as $vevent) {
/** @var $vevent Sabre\VObject\Component\VEvent */
-
- foreach ($vevent->children as $child) {
+ foreach ($vevent->children() as $child) {
/** @var $child Sabre\VObject\Property */
-
if (isset($expectedEvent[$child->name])) {
if ($expectedEvent[$child->name] != $child->getValue()) {
continue 2;
@@ -133,7 +131,7 @@ END:VCALENDAR
break;
}
- $this->assertTrue($matching, 'Did not find the following event in the response: '.var_export($expectedEvent, true));
+ $this->assertTrue($matching, 'Did not find the following event in the response: ' . var_export($expectedEvent, true));
}
}
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php
index cd6820b57..4a53fcbe2 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php
@@ -7,7 +7,7 @@ use Sabre\VObject;
/**
* This unittest is created to check if a VALARM TRIGGER of PT0S is supported
*
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -50,7 +50,7 @@ END:VCALENDAR
function testIssue205() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
'REQUEST_URI' => '/calendars/user1/calendar1',
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php
index cc700e50d..f291e5e57 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php
@@ -7,7 +7,7 @@ use Sabre\VObject;
/**
* This unittest is created to check for an endless loop in Sabre\CalDAV\CalendarQueryValidator
*
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -55,7 +55,7 @@ END:VCALENDAR
function testIssue211() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
'REQUEST_URI' => '/calendars/user1/calendar1',
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php
index ce66b6a5f..7b5dbfe63 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php
@@ -7,7 +7,7 @@ use Sabre\HTTP;
/**
* This unittest is created to check for an endless loop in CalendarQueryValidator
*
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -65,7 +65,7 @@ END:VCALENDAR
function testIssue220() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
'REQUEST_URI' => '/calendars/user1/calendar1',
@@ -94,6 +94,6 @@ END:VCALENDAR
$this->assertFalse(strpos($response->body, '<s:exception>PHPUnit_Framework_Error_Warning</s:exception>'), 'Error Warning occurred: ' . $response->body);
$this->assertFalse(strpos($response->body, 'Invalid argument supplied for foreach()'), 'Invalid argument supplied for foreach(): ' . $response->body);
- $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status);
+ $this->assertEquals(207, $response->status);
}
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php
index 23371a054..ccc6b303a 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php
@@ -6,7 +6,7 @@ use Sabre\HTTP;
/**
* This unittest is created to check if the time-range filter is working correctly with all-day-events
*
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -44,7 +44,7 @@ END:VCALENDAR
function testIssue228() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
'REQUEST_URI' => '/calendars/user1/calendar1',
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php
index eaed4f503..68035184f 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php
@@ -14,9 +14,9 @@ class CollectionTest extends \PHPUnit_Framework_TestCase {
$this->principalUri = 'principals/user1';
- $this->notification = new Notification\SystemStatus(1,'"1"');
+ $this->notification = new CalDAV\Xml\Notification\SystemStatus(1,'"1"');
- $this->caldavBackend = new CalDAV\Backend\Mock(array(),array(), array(
+ $this->caldavBackend = new CalDAV\Backend\MockSharing(array(),array(), array(
'principals/user1' => array(
$this->notification
)
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php
index 28e43ce08..d546116fc 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php
@@ -13,13 +13,13 @@ class NodeTest extends \PHPUnit_Framework_TestCase {
$principalUri = 'principals/user1';
- $this->systemStatus = new Notification\SystemStatus(1,'"1"');
+ $this->systemStatus = new CalDAV\Xml\Notification\SystemStatus(1,'"1"');
- $this->caldavBackend = new CalDAV\Backend\Mock(array(),array(), array(
- 'principals/user1' => array(
+ $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [
+ 'principals/user1' => [
$this->systemStatus
- )
- ));
+ ]
+ ]);
$node = new Node($this->caldavBackend, 'principals/user1', $this->systemStatus);
return $node;
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteReplyTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteReplyTest.php
deleted file mode 100644
index c53f68cee..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteReplyTest.php
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Notifications\Notification;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class InviteReplyTest extends \PHPUnit_Framework_TestCase {
-
- /**
- * @dataProvider dataProvider
- */
- function testSerializers($notification, $expected) {
-
- $notification = new InviteReply($notification);
-
- $this->assertEquals('foo', $notification->getId());
- $this->assertEquals('"1"', $notification->getETag());
-
- $simpleExpected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:invite-reply/></cs:root>' . "\n";
-
- $dom = new \DOMDocument('1.0','UTF-8');
- $elem = $dom->createElement('cs:root');
- $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER);
- $dom->appendChild($elem);
- $notification->serialize(new DAV\Server(), $elem);
- $this->assertEquals($simpleExpected, $dom->saveXML());
-
- $dom = new \DOMDocument('1.0','UTF-8');
- $dom->formatOutput = true;
- $elem = $dom->createElement('cs:root');
- $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER);
- $elem->setAttribute('xmlns:d','DAV:');
- $dom->appendChild($elem);
- $notification->serializeBody(new DAV\Server(), $elem);
- $this->assertEquals($expected, $dom->saveXML());
-
-
- }
-
- function dataProvider() {
-
- $dtStamp = new \DateTime('2012-01-01 00:00:00 GMT');
- return array(
- array(
- array(
- 'id' => 'foo',
- 'dtStamp' => $dtStamp,
- 'etag' => '"1"',
- 'inReplyTo' => 'bar',
- 'href' => 'mailto:foo@example.org',
- 'type' => CalDAV\SharingPlugin::STATUS_ACCEPTED,
- 'hostUrl' => 'calendar'
- ),
-<<<FOO
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:">
- <cs:dtstamp>20120101T000000Z</cs:dtstamp>
- <cs:invite-reply>
- <cs:uid>foo</cs:uid>
- <cs:in-reply-to>bar</cs:in-reply-to>
- <d:href>mailto:foo@example.org</d:href>
- <cs:invite-accepted/>
- <cs:hosturl>
- <d:href>/calendar</d:href>
- </cs:hosturl>
- </cs:invite-reply>
-</cs:root>
-
-FOO
- ),
- array(
- array(
- 'id' => 'foo',
- 'dtStamp' => $dtStamp,
- 'etag' => '"1"',
- 'inReplyTo' => 'bar',
- 'href' => 'mailto:foo@example.org',
- 'type' => CalDAV\SharingPlugin::STATUS_DECLINED,
- 'hostUrl' => 'calendar',
- 'summary' => 'Summary!'
- ),
-<<<FOO
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:">
- <cs:dtstamp>20120101T000000Z</cs:dtstamp>
- <cs:invite-reply>
- <cs:uid>foo</cs:uid>
- <cs:in-reply-to>bar</cs:in-reply-to>
- <d:href>mailto:foo@example.org</d:href>
- <cs:invite-declined/>
- <cs:hosturl>
- <d:href>/calendar</d:href>
- </cs:hosturl>
- <cs:summary>Summary!</cs:summary>
- </cs:invite-reply>
-</cs:root>
-
-FOO
- ),
-
- );
-
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- function testMissingArg() {
-
- new InviteReply(array());
-
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- function testUnknownArg() {
-
- new InviteReply(array(
- 'foo-i-will-break' => true,
-
- 'id' => 1,
- 'etag' => '"bla"',
- 'href' => 'abc',
- 'dtStamp' => 'def',
- 'inReplyTo' => 'qrs',
- 'type' => 'ghi',
- 'hostUrl' => 'jkl',
- ));
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteTest.php
deleted file mode 100644
index d2c114f4c..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteTest.php
+++ /dev/null
@@ -1,230 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Notifications\Notification;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class InviteTest extends \PHPUnit_Framework_TestCase {
-
- /**
- * @dataProvider dataProvider
- */
- function testSerializers($notification, $expected) {
-
- $notification = new Invite($notification);
-
- $this->assertEquals('foo', $notification->getId());
- $this->assertEquals('"1"', $notification->getETag());
-
- $simpleExpected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:invite-notification/></cs:root>' . "\n";
-
- $dom = new \DOMDocument('1.0','UTF-8');
- $elem = $dom->createElement('cs:root');
- $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER);
- $dom->appendChild($elem);
- $notification->serialize(new DAV\Server(), $elem);
- $this->assertEquals($simpleExpected, $dom->saveXML());
-
- $dom = new \DOMDocument('1.0','UTF-8');
- $dom->formatOutput = true;
- $elem = $dom->createElement('cs:root');
- $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER);
- $elem->setAttribute('xmlns:d','DAV:');
- $elem->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV);
- $dom->appendChild($elem);
- $notification->serializeBody(new DAV\Server(), $elem);
- $this->assertEquals($expected, $dom->saveXML());
-
-
- }
-
- function dataProvider() {
-
- $dtStamp = new \DateTime('2012-01-01 00:00:00', new \DateTimeZone('GMT'));
- return array(
- array(
- array(
- 'id' => 'foo',
- 'dtStamp' => $dtStamp,
- 'etag' => '"1"',
- 'href' => 'mailto:foo@example.org',
- 'type' => CalDAV\SharingPlugin::STATUS_ACCEPTED,
- 'readOnly' => true,
- 'hostUrl' => 'calendar',
- 'organizer' => 'principal/user1',
- 'commonName' => 'John Doe',
- 'summary' => 'Awesome stuff!'
- ),
-<<<FOO
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav">
- <cs:dtstamp>20120101T000000Z</cs:dtstamp>
- <cs:invite-notification>
- <cs:uid>foo</cs:uid>
- <d:href>mailto:foo@example.org</d:href>
- <cs:invite-accepted/>
- <cs:hosturl>
- <d:href>/calendar</d:href>
- </cs:hosturl>
- <cs:access>
- <cs:read/>
- </cs:access>
- <cs:organizer-cn>John Doe</cs:organizer-cn>
- <cs:organizer>
- <d:href>/principal/user1</d:href>
- <cs:common-name>John Doe</cs:common-name>
- </cs:organizer>
- <cs:summary>Awesome stuff!</cs:summary>
- </cs:invite-notification>
-</cs:root>
-
-FOO
- ),
- array(
- array(
- 'id' => 'foo',
- 'dtStamp' => $dtStamp,
- 'etag' => '"1"',
- 'href' => 'mailto:foo@example.org',
- 'type' => CalDAV\SharingPlugin::STATUS_DECLINED,
- 'readOnly' => true,
- 'hostUrl' => 'calendar',
- 'organizer' => 'principal/user1',
- 'commonName' => 'John Doe',
- ),
-<<<FOO
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav">
- <cs:dtstamp>20120101T000000Z</cs:dtstamp>
- <cs:invite-notification>
- <cs:uid>foo</cs:uid>
- <d:href>mailto:foo@example.org</d:href>
- <cs:invite-declined/>
- <cs:hosturl>
- <d:href>/calendar</d:href>
- </cs:hosturl>
- <cs:access>
- <cs:read/>
- </cs:access>
- <cs:organizer-cn>John Doe</cs:organizer-cn>
- <cs:organizer>
- <d:href>/principal/user1</d:href>
- <cs:common-name>John Doe</cs:common-name>
- </cs:organizer>
- </cs:invite-notification>
-</cs:root>
-
-FOO
- ),
- array(
- array(
- 'id' => 'foo',
- 'dtStamp' => $dtStamp,
- 'etag' => '"1"',
- 'href' => 'mailto:foo@example.org',
- 'type' => CalDAV\SharingPlugin::STATUS_NORESPONSE,
- 'readOnly' => true,
- 'hostUrl' => 'calendar',
- 'organizer' => 'principal/user1',
- 'firstName' => 'Foo',
- 'lastName' => 'Bar',
- ),
-<<<FOO
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav">
- <cs:dtstamp>20120101T000000Z</cs:dtstamp>
- <cs:invite-notification>
- <cs:uid>foo</cs:uid>
- <d:href>mailto:foo@example.org</d:href>
- <cs:invite-noresponse/>
- <cs:hosturl>
- <d:href>/calendar</d:href>
- </cs:hosturl>
- <cs:access>
- <cs:read/>
- </cs:access>
- <cs:organizer-first>Foo</cs:organizer-first>
- <cs:organizer-last>Bar</cs:organizer-last>
- <cs:organizer>
- <d:href>/principal/user1</d:href>
- <cs:first-name>Foo</cs:first-name>
- <cs:last-name>Bar</cs:last-name>
- </cs:organizer>
- </cs:invite-notification>
-</cs:root>
-
-FOO
- ),
- array(
- array(
- 'id' => 'foo',
- 'dtStamp' => $dtStamp,
- 'etag' => '"1"',
- 'href' => 'mailto:foo@example.org',
- 'type' => CalDAV\SharingPlugin::STATUS_DELETED,
- 'readOnly' => false,
- 'hostUrl' => 'calendar',
- 'organizer' => 'mailto:user1@fruux.com',
- 'supportedComponents' => new CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
- ),
-<<<FOO
-<?xml version="1.0" encoding="UTF-8"?>
-<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav">
- <cs:dtstamp>20120101T000000Z</cs:dtstamp>
- <cs:invite-notification>
- <cs:uid>foo</cs:uid>
- <d:href>mailto:foo@example.org</d:href>
- <cs:invite-deleted/>
- <cs:hosturl>
- <d:href>/calendar</d:href>
- </cs:hosturl>
- <cs:access>
- <cs:read-write/>
- </cs:access>
- <cs:organizer>
- <d:href>mailto:user1@fruux.com</d:href>
- </cs:organizer>
- <cal:supported-calendar-component-set>
- <cal:comp name="VEVENT"/>
- <cal:comp name="VTODO"/>
- </cal:supported-calendar-component-set>
- </cs:invite-notification>
-</cs:root>
-
-FOO
- ),
-
- );
-
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- function testMissingArg() {
-
- new Invite(array());
-
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- function testUnknownArg() {
-
- new Invite(array(
- 'foo-i-will-break' => true,
-
- 'id' => 1,
- 'etag' => '"bla"',
- 'href' => 'abc',
- 'dtStamp' => 'def',
- 'type' => 'ghi',
- 'readOnly' => true,
- 'hostUrl' => 'jkl',
- 'organizer' => 'mno',
- ));
-
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/SystemStatusTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/SystemStatusTest.php
deleted file mode 100644
index 8dc494932..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/SystemStatusTest.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Notifications\Notification;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class SystemStatusTest extends \PHPUnit_Framework_TestCase {
-
- /**
- * @dataProvider dataProvider
- */
- function testSerializers($notification, $expected1, $expected2) {
-
- $this->assertEquals('foo', $notification->getId());
- $this->assertEquals('"1"', $notification->getETag());
-
-
- $dom = new \DOMDocument('1.0','UTF-8');
- $elem = $dom->createElement('cs:root');
- $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER);
- $dom->appendChild($elem);
- $notification->serialize(new DAV\Server(), $elem);
- $this->assertEquals($expected1, $dom->saveXML());
-
- $dom = new \DOMDocument('1.0','UTF-8');
- $elem = $dom->createElement('cs:root');
- $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER);
- $dom->appendChild($elem);
- $notification->serializeBody(new DAV\Server(), $elem);
- $this->assertEquals($expected2, $dom->saveXML());
-
-
- }
-
- function dataProvider() {
-
- return array(
-
- array(
- new SystemStatus('foo', '"1"'),
- '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="high"/></cs:root>' . "\n",
- '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="high"/></cs:root>' . "\n",
- ),
-
- array(
- new SystemStatus('foo', '"1"', SystemStatus::TYPE_MEDIUM,'bar'),
- '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="medium"/></cs:root>' . "\n",
- '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="medium"><cs:description>bar</cs:description></cs:systemstatus></cs:root>' . "\n",
- ),
-
- array(
- new SystemStatus('foo', '"1"', SystemStatus::TYPE_LOW,null,'http://example.org/'),
- '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="low"/></cs:root>' . "\n",
- '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="low"><d:href>http://example.org/</d:href></cs:systemstatus></cs:root>' . "\n",
- )
- );
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/OutboxPostTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/OutboxPostTest.php
deleted file mode 100644
index 5a5a4e75c..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/OutboxPostTest.php
+++ /dev/null
@@ -1,545 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV;
-use Sabre\HTTP;
-use Sabre\VObject;
-use Sabre\DAV;
-
-require_once 'Sabre/DAVServerTest.php';
-require_once 'Sabre/CalDAV/Schedule/IMip/Mock.php';
-
-class OutboxPostTest extends \Sabre\DAVServerTest {
-
- protected $setupCalDAV = true;
-
- function testPostPassThruNotFound() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/notfound',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $this->assertHTTPStatus(501, $req);
-
- }
-
- function testPostPassThruNotTextCalendar() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/admin/outbox',
- ));
-
- $this->assertHTTPStatus(501, $req);
-
- }
-
- function testPostPassThruNoOutBox() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $this->assertHTTPStatus(501, $req);
-
- }
-
- function testNoOriginator() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/admin/outbox',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
- $req->setBody(implode("\r\n",$body));
-
- $this->assertHTTPStatus(400, $req);
-
- }
-
- function testNoRecipient() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/admin/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:orig@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
- $req->setBody(implode("\r\n",$body));
-
- $this->assertHTTPStatus(400, $req);
-
- }
-
- function testBadOriginator() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/admin/outbox',
- 'HTTP_ORIGINATOR' => 'nomailto:orig@example.org',
- 'HTTP_RECIPIENT' => 'mailto:user1@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
- $req->setBody(implode("\r\n",$body));
-
- $this->assertHTTPStatus(403, $req);
-
- }
-
- function testBadRecipient() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/admin/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:orig@example.org',
- 'HTTP_RECIPIENT' => 'http://user1@example.org, mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
- $req->setBody(implode("\r\n",$body));
-
- $this->assertHTTPStatus(400, $req);
-
- }
-
- function testIncorrectOriginator() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/admin/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:orig@example.org',
- 'HTTP_RECIPIENT' => 'mailto:user1@example.org, mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
- $req->setBody(implode("\r\n",$body));
-
- $this->assertHTTPStatus(403, $req);
-
- }
-
- function testInvalidIcalBody() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
- $req->setBody('foo');
-
- $this->assertHTTPStatus(400, $req);
-
- }
-
- function testNoVEVENT() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'BEGIN:VTIMEZONE',
- 'END:VTIMEZONE',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
- $this->assertHTTPStatus(400, $req);
-
- }
-
- function testNoMETHOD() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'BEGIN:VEVENT',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
- $this->assertHTTPStatus(400, $req);
-
- }
-
- function testUnsupportedMethod() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:PUBLISH',
- 'BEGIN:VEVENT',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
- $this->assertHTTPStatus(501, $req);
-
- }
-
- function testNoIMIPHandler() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
-
- $response = $this->request($req);
- $this->assertEquals('HTTP/1.1 200 OK', $response->status);
- $this->assertEquals(array(
- 'Content-Type' => 'application/xml',
- ), $response->headers);
-
- // Lazily checking the body for a few expected values.
- $this->assertTrue(strpos($response->body, '5.2;')!==false);
- $this->assertTrue(strpos($response->body,'user2@example.org')!==false);
-
-
- }
-
- function testSuccessRequest() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'SUMMARY:An invitation',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
- $handler = new Schedule\IMip\Mock('server@example.org');
-
- $this->caldavPlugin->setIMIPhandler($handler);
-
- $response = $this->request($req);
- $this->assertEquals('HTTP/1.1 200 OK', $response->status);
- $this->assertEquals(array(
- 'Content-Type' => 'application/xml',
- ), $response->headers);
-
- // Lazily checking the body for a few expected values.
- $this->assertTrue(strpos($response->body, '2.0;')!==false);
- $this->assertTrue(strpos($response->body,'user2@example.org')!==false);
-
- $this->assertEquals(array(
- array(
- 'to' => 'user2@example.org',
- 'subject' => 'Invitation for: An invitation',
- 'body' => implode("\r\n", $body) . "\r\n",
- 'headers' => array(
- 'Reply-To: user1.sabredav@sabredav.org',
- 'From: server@example.org',
- 'Content-Type: text/calendar; method=REQUEST; charset=utf-8',
- 'X-Sabre-Version: ' . DAV\Version::VERSION . '-' . DAV\Version::STABILITY,
- ),
- )
- ), $handler->getSentEmails());
-
- }
-
- function testSuccessRequestUseRelativePrincipal() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => '/principals/user1/',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'SUMMARY:An invitation',
- 'ORGANIZER:mailto:user1.sabredav@sabredav.org',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
- $handler = new Schedule\IMip\Mock('server@example.org');
-
- $this->caldavPlugin->setIMIPhandler($handler);
-
- $response = $this->request($req);
- $this->assertEquals('HTTP/1.1 200 OK', $response->status, 'Full body: ' . $response->body);
- $this->assertEquals(array(
- 'Content-Type' => 'application/xml',
- ), $response->headers);
-
- // Lazily checking the body for a few expected values.
- $this->assertTrue(strpos($response->body, '2.0;')!==false);
- $this->assertTrue(strpos($response->body,'user2@example.org')!==false);
-
- $this->assertEquals(array(
- array(
- 'to' => 'user2@example.org',
- 'subject' => 'Invitation for: An invitation',
- 'body' => implode("\r\n", $body) . "\r\n",
- 'headers' => array(
- 'Reply-To: user1.sabredav@sabredav.org',
- 'From: server@example.org',
- 'Content-Type: text/calendar; method=REQUEST; charset=utf-8',
- 'X-Sabre-Version: ' . DAV\Version::VERSION . '-' . DAV\Version::STABILITY,
- ),
- )
- ), $handler->getSentEmails());
-
- }
-
- function testSuccessRequestUpperCased() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => 'MAILTO:user1.sabredav@sabredav.org',
- 'HTTP_RECIPIENT' => 'MAILTO:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'SUMMARY:An invitation',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
- $handler = new Schedule\IMip\Mock('server@example.org');
-
- $this->caldavPlugin->setIMIPhandler($handler);
-
- $response = $this->request($req);
- $this->assertEquals('HTTP/1.1 200 OK', $response->status);
- $this->assertEquals(array(
- 'Content-Type' => 'application/xml',
- ), $response->headers);
-
- // Lazily checking the body for a few expected values.
- $this->assertTrue(strpos($response->body, '2.0;')!==false);
- $this->assertTrue(strpos($response->body,'user2@example.org')!==false);
-
- $this->assertEquals(array(
- array(
- 'to' => 'user2@example.org',
- 'subject' => 'Invitation for: An invitation',
- 'body' => implode("\r\n", $body) . "\r\n",
- 'headers' => array(
- 'Reply-To: user1.sabredav@sabredav.org',
- 'From: server@example.org',
- 'Content-Type: text/calendar; method=REQUEST; charset=utf-8',
- 'X-Sabre-Version: ' . DAV\Version::VERSION . '-' . DAV\Version::STABILITY,
- ),
- )
- ), $handler->getSentEmails());
-
- }
-
- function testSuccessReply() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REPLY',
- 'BEGIN:VEVENT',
- 'SUMMARY:An invitation',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
- $handler = new Schedule\IMip\Mock('server@example.org');
-
- $this->caldavPlugin->setIMIPhandler($handler);
- $this->assertHTTPStatus(200, $req);
-
- $this->assertEquals(array(
- array(
- 'to' => 'user2@example.org',
- 'subject' => 'Response for: An invitation',
- 'body' => implode("\r\n", $body) . "\r\n",
- 'headers' => array(
- 'Reply-To: user1.sabredav@sabredav.org',
- 'From: server@example.org',
- 'Content-Type: text/calendar; method=REPLY; charset=utf-8',
- 'X-Sabre-Version: ' . DAV\Version::VERSION . '-' . DAV\Version::STABILITY,
- ),
- )
- ), $handler->getSentEmails());
-
- }
-
- function testSuccessCancel() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:CANCEL',
- 'BEGIN:VEVENT',
- 'SUMMARY:An invitation',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
- $handler = new Schedule\IMip\Mock('server@example.org');
-
- $this->caldavPlugin->setIMIPhandler($handler);
- $this->assertHTTPStatus(200, $req);
-
- $this->assertEquals(array(
- array(
- 'to' => 'user2@example.org',
- 'subject' => 'Cancelled event: An invitation',
- 'body' => implode("\r\n", $body) . "\r\n",
- 'headers' => array(
- 'Reply-To: user1.sabredav@sabredav.org',
- 'From: server@example.org',
- 'Content-Type: text/calendar; method=CANCEL; charset=utf-8',
- 'X-Sabre-Version: ' . DAV\Version::VERSION . '-' . DAV\Version::STABILITY,
- ),
- )
- ), $handler->getSentEmails());
-
-
- }
-
- function testUseRelativePrincipalNoFallback() {
-
- $req = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/outbox',
- 'HTTP_ORIGINATOR' => '/principals/user1/',
- 'HTTP_RECIPIENT' => 'mailto:user2@example.org',
- 'HTTP_CONTENT_TYPE' => 'text/calendar',
- ));
-
- $body = array(
- 'BEGIN:VCALENDAR',
- 'METHOD:REQUEST',
- 'BEGIN:VEVENT',
- 'SUMMARY:An invitation',
- 'ORGANIZER:rrrrrr',
- 'END:VEVENT',
- 'END:VCALENDAR',
- );
-
- $req->setBody(implode("\r\n",$body));
-
- $handler = new Schedule\IMip\Mock('server@example.org');
-
- $this->caldavPlugin->setIMIPhandler($handler);
-
- $response = $this->request($req);
- $this->assertEquals('HTTP/1.1 403 Forbidden', $response->status, 'Full body: ' . $response->body);
-
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php
index fb7dc316a..138012ffa 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php
@@ -1,78 +1,80 @@
<?php
namespace Sabre\CalDAV;
+
use Sabre\DAVACL;
use Sabre\DAV;
use Sabre\HTTP;
-
-require_once 'Sabre/HTTP/ResponseMock.php';
-require_once 'Sabre/CalDAV/TestUtil.php';
+use DateTime;
+use DateTimeZone;
class PluginTest extends \PHPUnit_Framework_TestCase {
/**
- * @var Sabre\DAV\Server
+ * @var DAV\Server
*/
protected $server;
/**
- * @var Sabre\CalDAV\Plugin
+ * @var Plugin
*/
protected $plugin;
protected $response;
/**
- * @var Sabre\CalDAV\Backend\PDO
+ * @var Backend\PDO
*/
protected $caldavBackend;
function setup() {
- $this->caldavBackend = new Backend\Mock(array(
- array(
- 'id' => 1,
- 'uri' => 'UUID-123467',
- 'principaluri' => 'principals/user1',
- '{DAV:}displayname' => 'user1 calendar',
- '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description',
- '{http://apple.com/ns/ical/}calendar-order' => '1',
- '{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
- '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
- ),
- array(
- 'id' => 2,
- 'uri' => 'UUID-123468',
- 'principaluri' => 'principals/user1',
- '{DAV:}displayname' => 'user1 calendar2',
- '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description',
- '{http://apple.com/ns/ical/}calendar-order' => '1',
- '{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
- '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
- )
- ), array(
- 1 => array(
- 'UUID-2345' => array(
+ $caldavNS = '{urn:ietf:params:xml:ns:caldav}';
+
+ $this->caldavBackend = new Backend\Mock([
+ [
+ 'id' => 1,
+ 'uri' => 'UUID-123467',
+ 'principaluri' => 'principals/user1',
+ '{DAV:}displayname' => 'user1 calendar',
+ $caldavNS . 'calendar-description' => 'Calendar description',
+ '{http://apple.com/ns/ical/}calendar-order' => '1',
+ '{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
+ $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']),
+ ],
+ [
+ 'id' => 2,
+ 'uri' => 'UUID-123468',
+ 'principaluri' => 'principals/user1',
+ '{DAV:}displayname' => 'user1 calendar2',
+ $caldavNS . 'calendar-description' => 'Calendar description',
+ '{http://apple.com/ns/ical/}calendar-order' => '1',
+ '{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
+ $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']),
+ ]
+ ], [
+ 1 => [
+ 'UUID-2345' => [
'calendardata' => TestUtil::getTestCalendarData(),
- )
- )
- ));
+ ]
+ ]
+ ]);
$principalBackend = new DAVACL\PrincipalBackend\Mock();
- $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read',array('principals/user1'));
- $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write',array('principals/user1'));
- $principalBackend->addPrincipal(array(
+ $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', ['principals/user1']);
+ $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', ['principals/user1']);
+ $principalBackend->addPrincipal([
'uri' => 'principals/admin/calendar-proxy-read',
- ));
- $principalBackend->addPrincipal(array(
+ ]);
+ $principalBackend->addPrincipal([
'uri' => 'principals/admin/calendar-proxy-write',
- ));
+ ]);
- $calendars = new CalendarRootNode($principalBackend,$this->caldavBackend);
+ $calendars = new CalendarRoot($principalBackend, $this->caldavBackend);
$principals = new Principal\Collection($principalBackend);
$root = new DAV\SimpleCollection('root');
$root->addChild($calendars);
$root->addChild($principals);
- $objectTree = new DAV\ObjectTree($root);
- $this->server = new DAV\Server($objectTree);
+ $this->server = new DAV\Server($root);
+ $this->server->sapi = new HTTP\SapiMock();
$this->server->debugExceptions = true;
$this->server->setBaseUri('/');
$this->plugin = new Plugin();
@@ -83,11 +85,13 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
// Adding Auth plugin, and ensuring that we are logged in.
$authBackend = new DAV\Auth\Backend\Mock();
- $authBackend->defaultUser = 'user1';
+ $authBackend->setPrincipal('principals/user1');
$authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV');
+ $authPlugin->beforeMethod(new \Sabre\HTTP\Request(), new \Sabre\HTTP\Response());
$this->server->addPlugin($authPlugin);
- $authPlugin->beforeMethod('GET', '/');
+ // This forces a login
+ $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
$this->response = new HTTP\ResponseMock();
$this->server->httpResponse = $this->response;
@@ -96,48 +100,41 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
function testSimple() {
- $this->assertEquals(array('MKCALENDAR'), $this->plugin->getHTTPMethods('calendars/user1/randomnewcalendar'));
- $this->assertEquals(array('calendar-access','calendar-proxy'), $this->plugin->getFeatures());
- $this->assertArrayHasKey('urn:ietf:params:xml:ns:caldav', $this->server->xmlNamespaces);
+ $this->assertEquals(['MKCALENDAR'], $this->plugin->getHTTPMethods('calendars/user1/randomnewcalendar'));
+ $this->assertEquals(['calendar-access', 'calendar-proxy'], $this->plugin->getFeatures());
+ $this->assertEquals(
+ 'caldav',
+ $this->plugin->getPluginInfo()['name']
+ );
}
function testUnknownMethodPassThrough() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'MKBREAKFAST',
- 'REQUEST_URI' => '/',
- ));
+ $request = new HTTP\Request('MKBREAKFAST', '/');
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status,'Incorrect status returned. Full response body:' . $this->response->body);
+ $this->assertEquals(501, $this->response->status, 'Incorrect status returned. Full response body:' . $this->response->body);
}
function testReportPassThrough() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_CONTENT_TYPE' => 'application/xml',
- 'REQUEST_URI' => '/',
- ));
+ $request = new HTTP\Request('REPORT', '/', ['Content-Type' => 'application/xml']);
$request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />');
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 403 Forbidden', $this->response->status);
+ $this->assertEquals(415, $this->response->status);
}
function testMkCalendarBadLocation() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'MKCALENDAR',
- 'REQUEST_URI' => '/blabla',
- ));
+ $request = new HTTP\Request('MKCALENDAR', '/blabla');
$body = '<?xml version="1.0" encoding="utf-8" ?>
<C:mkcalendar xmlns:D="DAV:"
@@ -181,16 +178,13 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 403 Forbidden', $this->response->status);
+ $this->assertEquals(403, $this->response->status);
}
function testMkCalendarNoParentNode() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'MKCALENDAR',
- 'REQUEST_URI' => '/doesntexist/calendar',
- ));
+ $request = new HTTP\Request('MKCALENDAR', '/doesntexist/calendar');
$body = '<?xml version="1.0" encoding="utf-8" ?>
<C:mkcalendar xmlns:D="DAV:"
@@ -234,16 +228,16 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 409 Conflict', $this->response->status);
+ $this->assertEquals(409, $this->response->status);
}
function testMkCalendarExistingCalendar() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'MKCALENDAR',
'REQUEST_URI' => '/calendars/user1/UUID-123467',
- ));
+ ]);
$body = '<?xml version="1.0" encoding="utf-8" ?>
<C:mkcalendar xmlns:D="DAV:"
@@ -287,16 +281,13 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 405 Method Not Allowed', $this->response->status);
+ $this->assertEquals(405, $this->response->status);
}
function testMkCalendarSucceed() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'MKCALENDAR',
- 'REQUEST_URI' => '/calendars/user1/NEWCALENDAR',
- ));
+ $request = new HTTP\Request('MKCALENDAR', '/calendars/user1/NEWCALENDAR');
$timezone = 'BEGIN:VCALENDAR
PRODID:-//Example Corp.//CalDAV Client//EN
@@ -341,31 +332,31 @@ END:VCALENDAR';
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 201 Created', $this->response->status,'Invalid response code received. Full response body: ' .$this->response->body);
+ $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: ' . $this->response->body);
$calendars = $this->caldavBackend->getCalendarsForUser('principals/user1');
$this->assertEquals(3, count($calendars));
$newCalendar = null;
- foreach($calendars as $calendar) {
+ foreach ($calendars as $calendar) {
if ($calendar['uri'] === 'NEWCALENDAR') {
$newCalendar = $calendar;
break;
}
}
- $this->assertInternalType('array',$newCalendar);
+ $this->assertInternalType('array', $newCalendar);
- $keys = array(
- 'uri' => 'NEWCALENDAR',
- 'id' => null,
- '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar restricted to events.',
- '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => $timezone,
- '{DAV:}displayname' => 'Lisa\'s Events',
+ $keys = [
+ 'uri' => 'NEWCALENDAR',
+ 'id' => null,
+ '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar restricted to events.',
+ '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => $timezone,
+ '{DAV:}displayname' => 'Lisa\'s Events',
'{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null,
- );
+ ];
- foreach($keys as $key=>$value) {
+ foreach ($keys as $key => $value) {
$this->assertArrayHasKey($key, $newCalendar);
@@ -374,44 +365,41 @@ END:VCALENDAR';
}
$sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
- $this->assertTrue($newCalendar[$sccs] instanceof Property\SupportedCalendarComponentSet);
- $this->assertEquals(array('VEVENT'),$newCalendar[$sccs]->getValue());
+ $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet);
+ $this->assertEquals(['VEVENT'], $newCalendar[$sccs]->getValue());
}
function testMkCalendarEmptyBodySucceed() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'MKCALENDAR',
- 'REQUEST_URI' => '/calendars/user1/NEWCALENDAR',
- ));
+ $request = new HTTP\Request('MKCALENDAR', '/calendars/user1/NEWCALENDAR');
$request->setBody('');
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 201 Created', $this->response->status,'Invalid response code received. Full response body: ' .$this->response->body);
+ $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: ' . $this->response->body);
$calendars = $this->caldavBackend->getCalendarsForUser('principals/user1');
$this->assertEquals(3, count($calendars));
$newCalendar = null;
- foreach($calendars as $calendar) {
+ foreach ($calendars as $calendar) {
if ($calendar['uri'] === 'NEWCALENDAR') {
$newCalendar = $calendar;
break;
}
}
- $this->assertInternalType('array',$newCalendar);
+ $this->assertInternalType('array', $newCalendar);
- $keys = array(
- 'uri' => 'NEWCALENDAR',
- 'id' => null,
+ $keys = [
+ 'uri' => 'NEWCALENDAR',
+ 'id' => null,
'{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null,
- );
+ ];
- foreach($keys as $key=>$value) {
+ foreach ($keys as $key => $value) {
$this->assertArrayHasKey($key, $newCalendar);
@@ -420,84 +408,82 @@ END:VCALENDAR';
}
$sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
- $this->assertTrue($newCalendar[$sccs] instanceof Property\SupportedCalendarComponentSet);
- $this->assertEquals(array('VEVENT','VTODO'),$newCalendar[$sccs]->getValue());
+ $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet);
+ $this->assertEquals(['VEVENT', 'VTODO'], $newCalendar[$sccs]->getValue());
+
+ }
+
+ function testMkCalendarBadXml() {
+
+ $request = new HTTP\Request('MKCALENDAR', '/blabla');
+ $body = 'This is not xml';
+
+ $request->setBody($body);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals(400, $this->response->status);
}
function testPrincipalProperties() {
- $httpRequest = new HTTP\Request(array(
- 'HTTP_HOST' => 'sabredav.org',
- ));
+ $httpRequest = new HTTP\Request('FOO', '/blabla', ['Host' => 'sabredav.org']);
$this->server->httpRequest = $httpRequest;
- $props = $this->server->getPropertiesForPath('/principals/user1',array(
- '{urn:ietf:params:xml:ns:caldav}calendar-home-set',
- '{urn:ietf:params:xml:ns:caldav}schedule-outbox-URL',
- '{urn:ietf:params:xml:ns:caldav}calendar-user-address-set',
+ $props = $this->server->getPropertiesForPath('/principals/user1', [
+ '{' . Plugin::NS_CALDAV . '}calendar-home-set',
'{' . Plugin::NS_CALENDARSERVER . '}calendar-proxy-read-for',
'{' . Plugin::NS_CALENDARSERVER . '}calendar-proxy-write-for',
'{' . Plugin::NS_CALENDARSERVER . '}notification-URL',
- ));
+ '{' . Plugin::NS_CALENDARSERVER . '}email-address-set',
+ ]);
- $this->assertArrayHasKey(0,$props);
- $this->assertArrayHasKey(200,$props[0]);
+ $this->assertArrayHasKey(0, $props);
+ $this->assertArrayHasKey(200, $props[0]);
- $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-home-set',$props[0][200]);
+ $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-home-set', $props[0][200]);
$prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-home-set'];
- $this->assertTrue($prop instanceof DAV\Property\Href);
- $this->assertEquals('calendars/user1/',$prop->getHref());
-
- $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-outbox-URL',$props[0][200]);
- $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}schedule-outbox-URL'];
- $this->assertTrue($prop instanceof DAV\Property\Href);
- $this->assertEquals('calendars/user1/outbox',$prop->getHref());
-
- $this->assertArrayHasKey('{'.Plugin::NS_CALENDARSERVER .'}notification-URL',$props[0][200]);
- $prop = $props[0][200]['{'.Plugin::NS_CALENDARSERVER .'}notification-URL'];
- $this->assertTrue($prop instanceof DAV\Property\Href);
- $this->assertEquals('calendars/user1/notifications/',$prop->getHref());
-
-
- $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-user-address-set',$props[0][200]);
- $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-user-address-set'];
- $this->assertTrue($prop instanceof DAV\Property\HrefList);
- $this->assertEquals(array('mailto:user1.sabredav@sabredav.org','/principals/user1/'),$prop->getHrefs());
+ $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop);
+ $this->assertEquals('calendars/user1/', $prop->getHref());
$this->assertArrayHasKey('{http://calendarserver.org/ns/}calendar-proxy-read-for', $props[0][200]);
$prop = $props[0][200]['{http://calendarserver.org/ns/}calendar-proxy-read-for'];
- $this->assertInstanceOf('Sabre\\DAV\\Property\\HrefList', $prop);
- $this->assertEquals(array('principals/admin'), $prop->getHrefs());
+ $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop);
+ $this->assertEquals(['principals/admin/'], $prop->getHrefs());
$this->assertArrayHasKey('{http://calendarserver.org/ns/}calendar-proxy-write-for', $props[0][200]);
$prop = $props[0][200]['{http://calendarserver.org/ns/}calendar-proxy-write-for'];
- $this->assertInstanceOf('Sabre\\DAV\\Property\\HrefList', $prop);
- $this->assertEquals(array('principals/admin'), $prop->getHrefs());
+ $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop);
+ $this->assertEquals(['principals/admin/'], $prop->getHrefs());
+ $this->assertArrayHasKey('{' . Plugin::NS_CALENDARSERVER . '}email-address-set', $props[0][200]);
+ $prop = $props[0][200]['{' . Plugin::NS_CALENDARSERVER . '}email-address-set'];
+ $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\EmailAddressSet', $prop);
+ $this->assertEquals(['user1.sabredav@sabredav.org'], $prop->getValue());
}
function testSupportedReportSetPropertyNonCalendar() {
- $props = $this->server->getPropertiesForPath('/calendars/user1',array(
+ $props = $this->server->getPropertiesForPath('/calendars/user1', [
'{DAV:}supported-report-set',
- ));
+ ]);
- $this->assertArrayHasKey(0,$props);
- $this->assertArrayHasKey(200,$props[0]);
- $this->assertArrayHasKey('{DAV:}supported-report-set',$props[0][200]);
+ $this->assertArrayHasKey(0, $props);
+ $this->assertArrayHasKey(200, $props[0]);
+ $this->assertArrayHasKey('{DAV:}supported-report-set', $props[0][200]);
$prop = $props[0][200]['{DAV:}supported-report-set'];
- $this->assertInstanceOf('\\Sabre\\DAV\\Property\\SupportedReportSet', $prop);
- $value = array(
+ $this->assertInstanceOf('\\Sabre\\DAV\\Xml\\Property\\SupportedReportSet', $prop);
+ $value = [
'{DAV:}expand-property',
'{DAV:}principal-property-search',
'{DAV:}principal-search-property-set'
- );
- $this->assertEquals($value,$prop->getValue());
+ ];
+ $this->assertEquals($value, $prop->getValue());
}
@@ -506,26 +492,51 @@ END:VCALENDAR';
*/
function testSupportedReportSetProperty() {
- $props = $this->server->getPropertiesForPath('/calendars/user1/UUID-123467',array(
+ $props = $this->server->getPropertiesForPath('/calendars/user1/UUID-123467', [
'{DAV:}supported-report-set',
- ));
+ ]);
- $this->assertArrayHasKey(0,$props);
- $this->assertArrayHasKey(200,$props[0]);
- $this->assertArrayHasKey('{DAV:}supported-report-set',$props[0][200]);
+ $this->assertArrayHasKey(0, $props);
+ $this->assertArrayHasKey(200, $props[0]);
+ $this->assertArrayHasKey('{DAV:}supported-report-set', $props[0][200]);
$prop = $props[0][200]['{DAV:}supported-report-set'];
- $this->assertTrue($prop instanceof \Sabre\DAV\Property\SupportedReportSet);
- $value = array(
+ $this->assertInstanceOf('\\Sabre\\DAV\\Xml\\Property\\SupportedReportSet', $prop);
+ $value = [
'{urn:ietf:params:xml:ns:caldav}calendar-multiget',
'{urn:ietf:params:xml:ns:caldav}calendar-query',
'{urn:ietf:params:xml:ns:caldav}free-busy-query',
'{DAV:}expand-property',
'{DAV:}principal-property-search',
'{DAV:}principal-search-property-set'
- );
- $this->assertEquals($value,$prop->getValue());
+ ];
+ $this->assertEquals($value, $prop->getValue());
+
+ }
+
+ function testSupportedReportSetUserCalendars() {
+
+ $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
+
+ $props = $this->server->getPropertiesForPath('/calendars/user1', [
+ '{DAV:}supported-report-set',
+ ]);
+
+ $this->assertArrayHasKey(0, $props);
+ $this->assertArrayHasKey(200, $props[0]);
+ $this->assertArrayHasKey('{DAV:}supported-report-set', $props[0][200]);
+
+ $prop = $props[0][200]['{DAV:}supported-report-set'];
+
+ $this->assertInstanceOf('\\Sabre\\DAV\\Xml\\Property\\SupportedReportSet', $prop);
+ $value = [
+ '{DAV:}sync-collection',
+ '{DAV:}expand-property',
+ '{DAV:}principal-property-search',
+ '{DAV:}principal-search-property-set',
+ ];
+ $this->assertEquals($value, $prop->getValue());
}
@@ -544,48 +555,33 @@ END:VCALENDAR';
'<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' .
'</c:calendar-multiget>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1',
- 'HTTP_DEPTH' => '1',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Invalid HTTP status received. Full response body: ' . $this->response->body);
-
- $xml = simplexml_load_string(DAV\XMLUtil::convertDAVNamespace($this->response->body));
+ $this->assertEquals(207, $this->response->status, 'Invalid HTTP status received. Full response body');
- $xml->registerXPathNamespace('d','urn:DAV');
- $xml->registerXPathNamespace('c','urn:ietf:params:xml:ns:caldav');
+ $expectedIcal = TestUtil::getTestCalendarData();
- $check = array(
- '/d:multistatus',
- '/d:multistatus/d:response',
- '/d:multistatus/d:response/d:href',
- '/d:multistatus/d:response/d:propstat',
- '/d:multistatus/d:response/d:propstat/d:prop',
- '/d:multistatus/d:response/d:propstat/d:prop/d:getetag',
- '/d:multistatus/d:response/d:propstat/d:prop/c:calendar-data',
- '/d:multistatus/d:response/d:propstat/d:status' => 'HTTP/1.1 200 OK',
- );
+ $expected = <<<XML
+<?xml version="1.0"?>
+<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
+<d:response>
+ <d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>
+ <d:propstat>
+ <d:prop>
+ <cal:calendar-data>$expectedIcal</cal:calendar-data>
+ <d:getetag>"e207e33c10e5fb9c12cfb35b5d9116e1"</d:getetag>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+</d:response>
+</d:multistatus>
+XML;
- foreach($check as $v1=>$v2) {
-
- $xpath = is_int($v1)?$v2:$v1;
-
- $result = $xml->xpath($xpath);
- $this->assertEquals(1,count($result));
-
- if (!is_int($v1)) $this->assertEquals($v2,(string)$result[0]);
-
- }
-
- // The response object should have a reference to the Asia/Seoul
- // timezone.
- $this->assertTrue(strpos($this->response->body,'Asia/Seoul')!==false);
+ $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString());
}
@@ -606,46 +602,39 @@ END:VCALENDAR';
'<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' .
'</c:calendar-multiget>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1',
- 'HTTP_DEPTH' => '1',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Invalid HTTP status received. Full response body: ' . $this->response->body);
-
- $xml = simplexml_load_string(DAV\XMLUtil::convertDAVNamespace($this->response->body));
-
- $xml->registerXPathNamespace('d','urn:DAV');
- $xml->registerXPathNamespace('c','urn:ietf:params:xml:ns:caldav');
+ $this->assertEquals(207, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body);
- $check = array(
- '/d:multistatus',
- '/d:multistatus/d:response',
- '/d:multistatus/d:response/d:href',
- '/d:multistatus/d:response/d:propstat',
- '/d:multistatus/d:response/d:propstat/d:prop',
- '/d:multistatus/d:response/d:propstat/d:prop/d:getetag',
- '/d:multistatus/d:response/d:propstat/d:prop/c:calendar-data',
- '/d:multistatus/d:response/d:propstat/d:status' => 'HTTP/1.1 200 OK',
+ $expectedIcal = TestUtil::getTestCalendarData();
+ $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal);
+ $expectedIcal = $expectedIcal->expand(
+ new DateTime('2011-01-01 00:00:00', new DateTimeZone('UTC')),
+ new DateTime('2011-12-31 23:59:59', new DateTimeZone('UTC'))
);
-
- foreach($check as $v1=>$v2) {
-
- $xpath = is_int($v1)?$v2:$v1;
-
- $result = $xml->xpath($xpath);
- $this->assertEquals(1,count($result));
-
- if (!is_int($v1)) $this->assertEquals($v2,(string)$result[0]);
-
- }
- // The response object should no longer hold references to timezones.
- $this->assertTrue(strpos($this->response->body,'Asia/Seoul')===false);
+ $expectedIcal = str_replace("\r\n", "&#xD;\n", $expectedIcal->serialize());
+
+ $expected = <<<XML
+<?xml version="1.0"?>
+<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
+<d:response>
+ <d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>
+ <d:propstat>
+ <d:prop>
+ <cal:calendar-data>$expectedIcal</cal:calendar-data>
+ <d:getetag>"e207e33c10e5fb9c12cfb35b5d9116e1"</d:getetag>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+</d:response>
+</d:multistatus>
+XML;
+
+ $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString());
}
@@ -671,56 +660,117 @@ END:VCALENDAR';
'</c:filter>' .
'</c:calendar-query>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1/UUID-123467',
- 'HTTP_DEPTH' => '1',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', ['Depth' => '1']);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Received an unexpected status. Full response body: ' . $this->response->body);
+ $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body);
- $xml = simplexml_load_string(DAV\XMLUtil::convertDAVNamespace($this->response->body));
+ $expectedIcal = TestUtil::getTestCalendarData();
+ $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal);
+ $expectedIcal = $expectedIcal->expand(
+ new DateTime('2000-01-01 00:00:00', new DateTimeZone('UTC')),
+ new DateTime('2010-12-31 23:59:59', new DateTimeZone('UTC'))
+ );
+ $expectedIcal = str_replace("\r\n", "&#xD;\n", $expectedIcal->serialize());
+
+ $expected = <<<XML
+<?xml version="1.0"?>
+<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
+<d:response>
+ <d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>
+ <d:propstat>
+ <d:prop>
+ <cal:calendar-data>$expectedIcal</cal:calendar-data>
+ <d:getetag>"e207e33c10e5fb9c12cfb35b5d9116e1"</d:getetag>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+</d:response>
+</d:multistatus>
+XML;
+
+ $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString());
- $xml->registerXPathNamespace('d','urn:DAV');
- $xml->registerXPathNamespace('c','urn:ietf:params:xml:ns:caldav');
+ }
- $check = array(
- '/d:multistatus',
- '/d:multistatus/d:response',
- '/d:multistatus/d:response/d:href',
- '/d:multistatus/d:response/d:propstat',
- '/d:multistatus/d:response/d:propstat/d:prop',
- '/d:multistatus/d:response/d:propstat/d:prop/d:getetag',
- '/d:multistatus/d:response/d:propstat/d:prop/c:calendar-data',
- '/d:multistatus/d:response/d:propstat/d:status' => 'HTTP/1.1 200 OK',
- );
+ /**
+ * @depends testSupportedReportSetProperty
+ * @depends testCalendarMultiGetReport
+ */
+ function testCalendarQueryReportWindowsPhone() {
- foreach($check as $v1=>$v2) {
+ $body =
+ '<?xml version="1.0"?>' .
+ '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' .
+ '<d:prop>' .
+ ' <c:calendar-data>' .
+ ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />' .
+ ' </c:calendar-data>' .
+ ' <d:getetag />' .
+ '</d:prop>' .
+ '<c:filter>' .
+ ' <c:comp-filter name="VCALENDAR">' .
+ ' <c:comp-filter name="VEVENT" />' .
+ ' </c:comp-filter>' .
+ '</c:filter>' .
+ '</c:calendar-query>';
- $xpath = is_int($v1)?$v2:$v1;
+ $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [
+ 'Depth' => '0',
+ 'User-Agent' => 'MSFT-WP/8.10.14219 (gzip)',
+ ]);
- $result = $xml->xpath($xpath);
- $this->assertEquals(1,count($result), 'We expected 1 ' . $xpath . ' elements. We\'ve found ' . count($result) . '. Full result: ' . $this->response->body);
+ $request->setBody($body);
- if (!is_int($v1)) $this->assertEquals($v2,(string)$result[0]);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
- }
+ $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body);
+
+ $expectedIcal = TestUtil::getTestCalendarData();
+ $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal);
+ $expectedIcal = $expectedIcal->expand(
+ new DateTime('2000-01-01 00:00:00', new DateTimeZone('UTC')),
+ new DateTime('2010-12-31 23:59:59', new DateTimeZone('UTC'))
+ );
+ $expectedIcal = str_replace("\r\n", "&#xD;\n", $expectedIcal->serialize());
+
+ $expected = <<<XML
+<?xml version="1.0"?>
+<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
+<d:response>
+ <d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>
+ <d:propstat>
+ <d:prop>
+ <cal:calendar-data>$expectedIcal</cal:calendar-data>
+ <d:getetag>"e207e33c10e5fb9c12cfb35b5d9116e1"</d:getetag>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+</d:response>
+</d:multistatus>
+XML;
+
+ $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString());
}
/**
- * @depends testCalendarQueryReport
+ * @depends testSupportedReportSetProperty
+ * @depends testCalendarMultiGetReport
*/
- function testCalendarQueryReportNoCalData() {
+ function testCalendarQueryReportBadDepth() {
$body =
'<?xml version="1.0"?>' .
'<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' .
'<d:prop>' .
+ ' <c:calendar-data>' .
+ ' <c:expand start="20000101T000000Z" end="20101231T235959Z" />' .
+ ' </c:calendar-data>' .
' <d:getetag />' .
'</d:prop>' .
'<c:filter>' .
@@ -730,43 +780,62 @@ END:VCALENDAR';
'</c:filter>' .
'</c:calendar-query>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1//UUID-123467',
- 'HTTP_DEPTH' => '1',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [
+ 'Depth' => '0',
+ ]);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Received an unexpected status. Full response body: ' . $this->response->body);
-
- $xml = simplexml_load_string(DAV\XMLUtil::convertDAVNamespace($this->response->body));
+ $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body);
- $xml->registerXPathNamespace('d','urn:DAV');
- $xml->registerXPathNamespace('c','urn:ietf:params:xml:ns:caldav');
-
- $check = array(
- '/d:multistatus',
- '/d:multistatus/d:response',
- '/d:multistatus/d:response/d:href',
- '/d:multistatus/d:response/d:propstat',
- '/d:multistatus/d:response/d:propstat/d:prop',
- '/d:multistatus/d:response/d:propstat/d:prop/d:getetag',
- '/d:multistatus/d:response/d:propstat/d:status' => 'HTTP/1.1 200 OK',
- );
+ }
- foreach($check as $v1=>$v2) {
+ /**
+ * @depends testCalendarQueryReport
+ */
+ function testCalendarQueryReportNoCalData() {
- $xpath = is_int($v1)?$v2:$v1;
+ $body =
+ '<?xml version="1.0"?>' .
+ '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' .
+ '<d:prop>' .
+ ' <d:getetag />' .
+ '</d:prop>' .
+ '<c:filter>' .
+ ' <c:comp-filter name="VCALENDAR">' .
+ ' <c:comp-filter name="VEVENT" />' .
+ ' </c:comp-filter>' .
+ '</c:filter>' .
+ '</c:calendar-query>';
- $result = $xml->xpath($xpath);
- $this->assertEquals(1,count($result), 'We expected 1 ' . $xpath . ' elements. We\'ve found ' . count($result) . '. Full result: ' . $this->response->body);
+ $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [
+ 'Depth' => '1',
+ ]);
+ $request->setBody($body);
- if (!is_int($v1)) $this->assertEquals($v2,(string)$result[0]);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
- }
+ $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body);
+
+ $expected = <<<XML
+<?xml version="1.0"?>
+<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
+<d:response>
+ <d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>
+ <d:propstat>
+ <d:prop>
+ <d:getetag>"e207e33c10e5fb9c12cfb35b5d9116e1"</d:getetag>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+</d:response>
+</d:multistatus>
+XML;
+
+ $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString());
}
@@ -784,16 +853,13 @@ END:VCALENDAR';
'</d:prop>' .
'</c:calendar-query>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1//UUID-123467',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467');
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status,'Received an unexpected status. Full response body: ' . $this->response->body);
+ $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body);
}
@@ -819,44 +885,39 @@ END:VCALENDAR';
'</c:filter>' .
'</c:calendar-query>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1/UUID-123467/UUID-2345',
- 'HTTP_DEPTH' => '0',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467/UUID-2345', ['Depth' => '0']);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Received an unexpected status. Full response body: ' . $this->response->body);
-
- $xml = simplexml_load_string(DAV\XMLUtil::convertDAVNamespace($this->response->body));
-
- $xml->registerXPathNamespace('d','urn:DAV');
- $xml->registerXPathNamespace('c','urn:ietf:params:xml:ns:caldav');
+ $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body);
- $check = array(
- '/d:multistatus',
- '/d:multistatus/d:response',
- '/d:multistatus/d:response/d:href',
- '/d:multistatus/d:response/d:propstat',
- '/d:multistatus/d:response/d:propstat/d:prop',
- '/d:multistatus/d:response/d:propstat/d:prop/d:getetag',
- '/d:multistatus/d:response/d:propstat/d:prop/c:calendar-data',
- '/d:multistatus/d:response/d:propstat/d:status' => 'HTTP/1.1 200 OK',
+ $expectedIcal = TestUtil::getTestCalendarData();
+ $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal);
+ $expectedIcal = $expectedIcal->expand(
+ new DateTime('2000-01-01 00:00:00', new DateTimeZone('UTC')),
+ new DateTime('2010-12-31 23:59:59', new DateTimeZone('UTC'))
);
-
- foreach($check as $v1=>$v2) {
-
- $xpath = is_int($v1)?$v2:$v1;
-
- $result = $xml->xpath($xpath);
- $this->assertEquals(1,count($result), 'We expected 1 ' . $xpath . ' elements. We\'ve found ' . count($result) . '. Full result: ' . $this->response->body);
-
- if (!is_int($v1)) $this->assertEquals($v2,(string)$result[0]);
-
- }
+ $expectedIcal = str_replace("\r\n", "&#xD;\n", $expectedIcal->serialize());
+
+ $expected = <<<XML
+<?xml version="1.0"?>
+<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
+<d:response>
+ <d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>
+ <d:propstat>
+ <d:prop>
+ <cal:calendar-data>$expectedIcal</cal:calendar-data>
+ <d:getetag>"e207e33c10e5fb9c12cfb35b5d9116e1"</d:getetag>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+</d:response>
+</d:multistatus>
+XML;
+
+ $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString());
}
@@ -879,77 +940,40 @@ END:VCALENDAR';
'</c:filter>' .
'</c:calendar-query>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1/UUID-123467/UUID-2345',
- 'HTTP_DEPTH' => '0',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467/UUID-2345', ['Depth' => '0']);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Received an unexpected status. Full response body: ' . $this->response->body);
-
- $xml = simplexml_load_string(DAV\XMLUtil::convertDAVNamespace($this->response->body));
-
- $xml->registerXPathNamespace('d','urn:DAV');
- $xml->registerXPathNamespace('c','urn:ietf:params:xml:ns:caldav');
-
- $check = array(
- '/d:multistatus',
- '/d:multistatus/d:response',
- '/d:multistatus/d:response/d:href',
- '/d:multistatus/d:response/d:propstat',
- '/d:multistatus/d:response/d:propstat/d:prop',
- '/d:multistatus/d:response/d:propstat/d:prop/d:getetag',
- '/d:multistatus/d:response/d:propstat/d:status' => 'HTTP/1.1 200 OK',
- );
-
- foreach($check as $v1=>$v2) {
-
- $xpath = is_int($v1)?$v2:$v1;
-
- $result = $xml->xpath($xpath);
- $this->assertEquals(1,count($result), 'We expected 1 ' . $xpath . ' elements. We\'ve found ' . count($result) . '. Full result: ' . $this->response->body);
-
- if (!is_int($v1)) $this->assertEquals($v2,(string)$result[0]);
-
- }
+ $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body);
+
+ $expected = <<<XML
+<?xml version="1.0"?>
+<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
+<d:response>
+ <d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>
+ <d:propstat>
+ <d:prop>
+ <d:getetag>"e207e33c10e5fb9c12cfb35b5d9116e1"</d:getetag>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+</d:response>
+</d:multistatus>
+XML;
+
+ $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString());
}
function testHTMLActionsPanel() {
$output = '';
- $r = $this->server->broadcastEvent('onHTMLActionsPanel', array($this->server->tree->getNodeForPath('calendars/user1'), &$output));
+ $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('calendars/user1'), &$output]);
$this->assertFalse($r);
- $this->assertTrue(!!strpos($output,'Display name'));
-
- }
-
- function testBrowserPostAction() {
-
- $r = $this->server->broadcastEvent('onBrowserPostAction', array('calendars/user1', 'mkcalendar', array(
- 'name' => 'NEWCALENDAR',
- '{DAV:}displayname' => 'foo',
- )));
- $this->assertFalse($r);
-
- $calendars = $this->caldavBackend->getCalendarsForUser('principals/user1');
- $this->assertEquals(3, count($calendars));
-
- $newCalendar = null;
- foreach($calendars as $calendar) {
- if ($calendar['uri'] === 'NEWCALENDAR') {
- $newCalendar = $calendar;
- break;
- }
- }
- if (!$newCalendar)
- $this->fail('Could not find newly created calendar');
-
+ $this->assertTrue(!!strpos($output, 'Display name'));
}
@@ -970,17 +994,13 @@ END:VCALENDAR';
'<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' .
'</c:calendar-multiget>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1',
- 'HTTP_DEPTH' => '1',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status,'Invalid HTTP status received. Full response body: ' . $this->response->body);
+ $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body);
}
@@ -1001,17 +1021,13 @@ END:VCALENDAR';
'<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' .
'</c:calendar-multiget>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1',
- 'HTTP_DEPTH' => '1',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status,'Invalid HTTP status received. Full response body: ' . $this->response->body);
+ $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body);
}
@@ -1032,95 +1048,34 @@ END:VCALENDAR';
'<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>' .
'</c:calendar-multiget>';
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'REPORT',
- 'REQUEST_URI' => '/calendars/user1',
- 'HTTP_DEPTH' => '1',
- ));
+ $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status,'Invalid HTTP status received. Full response body: ' . $this->response->body);
+ $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body);
}
- function testNotificationProperties() {
-
- $request = array(
- '{' . Plugin::NS_CALENDARSERVER . '}notificationtype',
- );
- $result = array();
- $notification = new Notifications\Node(
- $this->caldavBackend,
- 'principals/user1',
- new Notifications\Notification\SystemStatus('foo','"1"')
- );
- $this->plugin->beforeGetProperties('foo', $notification, $request, $result);
-
- $this->assertEquals(
- array(
- 200 => array(
- '{' . Plugin::NS_CALENDARSERVER . '}notificationtype' => $notification->getNotificationType()
- )
- ), $result);
-
- }
-
- function testNotificationGet() {
-
- $notification = new Notifications\Node(
- $this->caldavBackend,
- 'principals/user1',
- new Notifications\Notification\SystemStatus('foo','"1"')
- );
-
- $server = new DAV\Server(array($notification));
- $caldav = new Plugin();
-
- $server->httpRequest = new HTTP\Request(array(
- 'REQUEST_URI' => '/foo.xml',
- ));
- $httpResponse = new HTTP\ResponseMock();
- $server->httpResponse = $httpResponse;
-
- $server->addPlugin($caldav);
-
- $caldav->beforeMethod('GET','foo.xml');
-
- $this->assertEquals('HTTP/1.1 200 OK', $httpResponse->status);
- $this->assertEquals(array(
- 'Content-Type' => 'application/xml',
- 'ETag' => '"1"',
- ), $httpResponse->headers);
-
- $expected =
-'<?xml version="1.0" encoding="UTF-8"?>
-<cs:notification xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/">
- <cs:systemstatus type="high"/>
-</cs:notification>
-';
-
- $this->assertEquals($expected, $httpResponse->body);
-
- }
-
- function testGETPassthrough() {
-
- $server = new DAV\Server();
- $caldav = new Plugin();
-
- $httpResponse = new HTTP\ResponseMock();
- $server->httpResponse = $httpResponse;
-
- $server->addPlugin($caldav);
+ /**
+ * @depends testSupportedReportSetPropertyNonCalendar
+ */
+ function testCalendarProperties() {
- $caldav->beforeMethod('GET','foo');
+ $ns = '{urn:ietf:params:xml:ns:caldav}';
+ $props = $this->server->getProperties('calendars/user1/UUID-123467', [
+ $ns . 'max-resource-size',
+ $ns . 'supported-calendar-data',
+ $ns . 'supported-collation-set',
+ ]);
- $this->assertNull($caldav->beforeMethod('GET','foozz'));
+ $this->assertEquals([
+ $ns . 'max-resource-size' => 10000000,
+ $ns . 'supported-calendar-data' => new Xml\Property\SupportedCalendarData(),
+ $ns . 'supported-collation-set' => new Xml\Property\SupportedCollationSet(),
+ ], $props);
}
-
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php
index d41692f2a..37b5eae97 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php
@@ -103,7 +103,7 @@ class UserTest extends \PHPUnit_Framework_TestCase {
$expected = array(
array(
'privilege' => '{DAV:}read',
- 'principal' => 'principals/user',
+ 'principal' => '{DAV:}authenticated',
'protected' => true,
),
array(
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/AllowedSharingModesTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Property/AllowedSharingModesTest.php
deleted file mode 100644
index 733ea1108..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/AllowedSharingModesTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class AllowedSharingModesTest extends \PHPUnit_Framework_TestCase {
-
- function testSimple() {
-
- $sccs = new AllowedSharingModes(true,true);
-
- }
-
- /**
- * @depends testSimple
- */
- function testSerialize() {
-
- $property = new AllowedSharingModes(true,true);
-
- $doc = new \DOMDocument();
- $root = $doc->createElement('d:root');
- $root->setAttribute('xmlns:d','DAV:');
- $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV);
- $root->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER);
-
- $doc->appendChild($root);
- $server = new DAV\Server();
-
- $property->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '" xmlns:cs="' . CalDAV\Plugin::NS_CALENDARSERVER . '">' .
-'<cs:can-be-shared/>' .
-'<cs:can-be-published/>' .
-'</d:root>
-', $xml);
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/InviteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Property/InviteTest.php
deleted file mode 100644
index 349a6e080..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/InviteTest.php
+++ /dev/null
@@ -1,196 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class InviteTest extends \PHPUnit_Framework_TestCase {
-
- function testSimple() {
-
- $sccs = new Invite(array());
-
- }
-
- /**
- * @depends testSimple
- */
- function testSerialize() {
-
- $property = new Invite(array(
- array(
- 'href' => 'mailto:user1@example.org',
- 'status' => CalDAV\SharingPlugin::STATUS_ACCEPTED,
- 'readOnly' => false,
- ),
- array(
- 'href' => 'mailto:user2@example.org',
- 'commonName' => 'John Doe',
- 'status' => CalDAV\SharingPlugin::STATUS_DECLINED,
- 'readOnly' => true,
- ),
- array(
- 'href' => 'mailto:user3@example.org',
- 'commonName' => 'Joe Shmoe',
- 'status' => CalDAV\SharingPlugin::STATUS_NORESPONSE,
- 'readOnly' => true,
- 'summary' => 'Something, something',
- ),
- array(
- 'href' => 'mailto:user4@example.org',
- 'commonName' => 'Hoe Boe',
- 'status' => CalDAV\SharingPlugin::STATUS_INVALID,
- 'readOnly' => true,
- ),
- ), array(
- 'href' => 'mailto:thedoctor@example.org',
- 'commonName' => 'The Doctor',
- 'firstName' => 'The',
- 'lastName' => 'Doctor',
- ));
-
- $doc = new \DOMDocument();
- $doc->formatOutput = true;
- $root = $doc->createElement('d:root');
- $root->setAttribute('xmlns:d','DAV:');
- $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV);
- $root->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER);
-
- $doc->appendChild($root);
- $server = new DAV\Server();
-
- $property->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '" xmlns:cs="' . CalDAV\Plugin::NS_CALENDARSERVER . '">
- <cs:organizer>
- <d:href>mailto:thedoctor@example.org</d:href>
- <cs:common-name>The Doctor</cs:common-name>
- <cs:first-name>The</cs:first-name>
- <cs:last-name>Doctor</cs:last-name>
- </cs:organizer>
- <cs:user>
- <d:href>mailto:user1@example.org</d:href>
- <cs:invite-accepted/>
- <cs:access>
- <cs:read-write/>
- </cs:access>
- </cs:user>
- <cs:user>
- <d:href>mailto:user2@example.org</d:href>
- <cs:common-name>John Doe</cs:common-name>
- <cs:invite-declined/>
- <cs:access>
- <cs:read/>
- </cs:access>
- </cs:user>
- <cs:user>
- <d:href>mailto:user3@example.org</d:href>
- <cs:common-name>Joe Shmoe</cs:common-name>
- <cs:invite-noresponse/>
- <cs:access>
- <cs:read/>
- </cs:access>
- <cs:summary>Something, something</cs:summary>
- </cs:user>
- <cs:user>
- <d:href>mailto:user4@example.org</d:href>
- <cs:common-name>Hoe Boe</cs:common-name>
- <cs:invite-invalid/>
- <cs:access>
- <cs:read/>
- </cs:access>
- </cs:user>
-</d:root>
-', $xml);
-
- }
-
- /**
- * @depends testSerialize
- */
- public function testUnserialize() {
-
- $input = array(
- array(
- 'href' => 'mailto:user1@example.org',
- 'status' => CalDAV\SharingPlugin::STATUS_ACCEPTED,
- 'readOnly' => false,
- 'commonName' => '',
- 'summary' => '',
- ),
- array(
- 'href' => 'mailto:user2@example.org',
- 'commonName' => 'John Doe',
- 'status' => CalDAV\SharingPlugin::STATUS_DECLINED,
- 'readOnly' => true,
- 'summary' => '',
- ),
- array(
- 'href' => 'mailto:user3@example.org',
- 'commonName' => 'Joe Shmoe',
- 'status' => CalDAV\SharingPlugin::STATUS_NORESPONSE,
- 'readOnly' => true,
- 'summary' => 'Something, something',
- ),
- array(
- 'href' => 'mailto:user4@example.org',
- 'commonName' => 'Hoe Boe',
- 'status' => CalDAV\SharingPlugin::STATUS_INVALID,
- 'readOnly' => true,
- 'summary' => '',
- ),
- );
-
- // Creating the xml
- $doc = new \DOMDocument();
- $doc->formatOutput = true;
- $root = $doc->createElement('d:root');
- $root->setAttribute('xmlns:d','DAV:');
- $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV);
- $root->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER);
-
- $doc->appendChild($root);
- $server = new DAV\Server();
-
- $inputProperty = new Invite($input);
- $inputProperty->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- // Parsing it again
-
- $doc2 = DAV\XMLUtil::loadDOMDocument($xml);
-
- $outputProperty = Invite::unserialize($doc2->firstChild);
-
- $this->assertEquals($input, $outputProperty->getValue());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception
- */
- function testUnserializeNoStatus() {
-
-$xml = '<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '" xmlns:cs="' . CalDAV\Plugin::NS_CALENDARSERVER . '">
- <cs:user>
- <d:href>mailto:user1@example.org</d:href>
- <!-- <cs:invite-accepted/> -->
- <cs:access>
- <cs:read-write/>
- </cs:access>
- </cs:user>
-</d:root>';
-
- $doc2 = DAV\XMLUtil::loadDOMDocument($xml);
- $outputProperty = Invite::unserialize($doc2->firstChild);
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/ScheduleCalendarTranspTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Property/ScheduleCalendarTranspTest.php
deleted file mode 100644
index 1ace0b18f..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/ScheduleCalendarTranspTest.php
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class ScheduleCalendarTranspTest extends \PHPUnit_Framework_TestCase {
-
- function testSimple() {
-
- $sccs = new ScheduleCalendarTransp('transparent');
- $this->assertEquals('transparent', $sccs->getValue());
-
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- function testBadArg() {
-
- $sccs = new ScheduleCalendarTransp('foo');
-
- }
-
- function values() {
-
- return array(
- array('transparent'),
- array('opaque'),
- );
-
- }
-
- /**
- * @depends testSimple
- * @dataProvider values
- */
- function testSerialize($value) {
-
- $property = new ScheduleCalendarTransp($value);
-
- $doc = new \DOMDocument();
- $root = $doc->createElement('d:root');
- $root->setAttribute('xmlns:d','DAV:');
- $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV);
-
- $doc->appendChild($root);
- $server = new DAV\Server();
-
- $property->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">' .
-'<cal:' . $value . '/>' .
-'</d:root>
-', $xml);
-
- }
-
- /**
- * @depends testSimple
- * @dataProvider values
- */
- function testUnserializer($value) {
-
- $xml = '<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">' .
-'<cal:'.$value.'/>' .
-'</d:root>';
-
- $dom = DAV\XMLUtil::loadDOMDocument($xml);
-
- $property = ScheduleCalendarTransp::unserialize($dom->firstChild);
-
- $this->assertTrue($property instanceof ScheduleCalendarTransp);
- $this->assertEquals($value, $property->getValue());
-
- }
-
- /**
- * @depends testSimple
- */
- function testUnserializerBadData() {
-
- $xml = '<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">' .
-'<cal:foo/>' .
-'</d:root>';
-
- $dom = DAV\XMLUtil::loadDOMDocument($xml);
-
- $this->assertNull(ScheduleCalendarTransp::unserialize($dom->firstChild));
-
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCalendarComponentSetTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCalendarComponentSetTest.php
deleted file mode 100644
index 3e5d5f5fc..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCalendarComponentSetTest.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-class SupportedCalendarComponentSetTest extends \PHPUnit_Framework_TestCase {
-
- function testSimple() {
-
- $sccs = new SupportedCalendarComponentSet(array('VEVENT'));
- $this->assertEquals(array('VEVENT'), $sccs->getValue());
-
- }
-
- /**
- * @depends testSimple
- */
- function testSerialize() {
-
- $property = new SupportedCalendarComponentSet(array('VEVENT','VJOURNAL'));
-
- $doc = new \DOMDocument();
- $root = $doc->createElement('d:root');
- $root->setAttribute('xmlns:d','DAV:');
- $root->setAttribute('xmlns:cal',\Sabre\CalDAV\Plugin::NS_CALDAV);
-
- $doc->appendChild($root);
- $server = new \Sabre\DAV\Server();
-
- $property->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . \Sabre\CalDAV\Plugin::NS_CALDAV . '">' .
-'<cal:comp name="VEVENT"/>' .
-'<cal:comp name="VJOURNAL"/>' .
-'</d:root>
-', $xml);
-
- }
-
- /**
- * @depends testSimple
- */
- function testUnserializer() {
-
- $xml = '<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . \Sabre\CalDAV\Plugin::NS_CALDAV . '">' .
-'<cal:comp name="VEVENT"/>' .
-'<cal:comp name="VJOURNAL"/>' .
-'</d:root>';
-
- $dom = \Sabre\DAV\XMLUtil::loadDOMDocument($xml);
-
- $property = SupportedCalendarComponentSet::unserialize($dom->firstChild);
-
- $this->assertTrue($property instanceof SupportedCalendarComponentSet);
- $this->assertEquals(array(
- 'VEVENT',
- 'VJOURNAL',
- ),
- $property->getValue());
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php
deleted file mode 100644
index 3e016368c..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class SupportedCalendarDataTest extends \PHPUnit_Framework_TestCase {
-
- function testSimple() {
-
- $sccs = new SupportedCalendarData();
-
- }
-
- /**
- * @depends testSimple
- */
- function testSerialize() {
-
- $property = new SupportedCalendarData();
-
- $doc = new \DOMDocument();
- $root = $doc->createElement('d:root');
- $root->setAttribute('xmlns:d','DAV:');
- $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV);
-
- $doc->appendChild($root);
- $server = new DAV\Server();
-
- $property->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">' .
-'<cal:calendar-data content-type="text/calendar" version="2.0"/>' .
-'</d:root>
-', $xml);
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php
deleted file mode 100644
index 669e31553..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Property;
-
-use Sabre\CalDAV;
-use Sabre\DAV;
-
-class SupportedCollationSetTest extends \PHPUnit_Framework_TestCase {
-
- function testSimple() {
-
- $scs = new SupportedCollationSet();
-
- }
-
- /**
- * @depends testSimple
- */
- function testSerialize() {
-
- $property = new SupportedCollationSet();
-
- $doc = new \DOMDocument();
- $root = $doc->createElement('d:root');
- $root->setAttribute('xmlns:d','DAV:');
- $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV);
-
- $doc->appendChild($root);
- $server = new DAV\Server();
-
- $property->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">' .
-'<cal:supported-collation>i;ascii-casemap</cal:supported-collation>' .
-'<cal:supported-collation>i;octet</cal:supported-collation>' .
-'<cal:supported-collation>i;unicode-casemap</cal:supported-collation>' .
-'</d:root>
-', $xml);
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/IMip/Mock.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/IMip/Mock.php
deleted file mode 100644
index ce0946dc8..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/IMip/Mock.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV\Schedule\IMip;
-
-/**
- * iMIP handler.
- *
- * This class is responsible for sending out iMIP messages. iMIP is the
- * email-based transport for iTIP. iTIP deals with scheduling operations for
- * iCalendar objects.
- *
- * If you want to customize the email that gets sent out, you can do so by
- * extending this class and overriding the sendMessage method.
- *
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class Mock extends \Sabre\CalDAV\Schedule\IMip {
-
- protected $emails = array();
-
- /**
- * This function is reponsible for sending the actual email.
- *
- * @param string $to Recipient email address
- * @param string $subject Subject of the email
- * @param string $body iCalendar body
- * @param array $headers List of headers
- * @return void
- */
- protected function mail($to, $subject, $body, array $headers) {
-
- $this->emails[] = array(
- 'to' => $to,
- 'subject' => $subject,
- 'body' => $body,
- 'headers' => $headers,
- );
-
- }
-
- public function getSentEmails() {
-
- return $this->emails;
-
- }
-
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php
index 60ce9a2ad..933c7157b 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php
@@ -20,6 +20,7 @@ class OutboxTest extends \PHPUnit_Framework_TestCase {
'principal' => 'principals/user1',
'protected' => true,
),
+
array(
'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent',
'principal' => 'principals/user1',
@@ -30,6 +31,26 @@ class OutboxTest extends \PHPUnit_Framework_TestCase {
'principal' => 'principals/user1',
'protected' => true,
),
+ array(
+ 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy',
+ 'principal' => 'principals/user1/calendar-proxy-write',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent',
+ 'principal' => 'principals/user1/calendar-proxy-write',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/user1/calendar-proxy-read',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/user1/calendar-proxy-write',
+ 'protected' => true,
+ ),
), $outbox->getACL());
$ok = false;
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ShareableCalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ShareableCalendarTest.php
index 2f79351f1..15b869d50 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/ShareableCalendarTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ShareableCalendarTest.php
@@ -15,10 +15,8 @@ class ShareableCalendarTest extends \PHPUnit_Framework_TestCase {
'id' => 1,
);
- $this->backend = new Backend\Mock(
- array($props),
- array(),
- array()
+ $this->backend = new Backend\MockSharing(
+ array($props)
);
$this->backend->updateShares(1, array(
array(
@@ -55,8 +53,8 @@ class ShareableCalendarTest extends \PHPUnit_Framework_TestCase {
function testPublish() {
- $this->instance->setPublishStatus(true);
- $this->instance->setPublishStatus(false);
+ $this->assertNull($this->instance->setPublishStatus(true));
+ $this->assertNull($this->instance->setPublishStatus(false));
}
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php
index 955831917..337b658f4 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php
@@ -20,7 +20,7 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
);
}
- $this->backend = new Backend\Mock(
+ $this->backend = new Backend\MockSharing(
array($props),
array(),
array()
@@ -64,18 +64,58 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
'principal' => 'principals/owner',
'protected' => true,
),
+
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/owner/calendar-proxy-write',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/owner/calendar-proxy-read',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
+ 'principal' => '{DAV:}authenticated',
+ 'protected' => true,
+ ),
array(
'privilege' => '{DAV:}write',
'principal' => 'principals/owner',
'protected' => true,
),
array(
- 'privilege' => '{DAV:}read',
+ 'privilege' => '{DAV:}write',
'principal' => 'principals/owner/calendar-proxy-write',
'protected' => true,
),
array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/sharee',
+ 'protected' => true,
+ ),
+ array(
'privilege' => '{DAV:}write',
+ 'principal' => 'principals/sharee',
+ 'protected' => true,
+ ),
+ );
+
+ $this->assertEquals($expected, $this->getInstance()->getACL());
+
+ }
+
+ function testGetChildACL() {
+
+ $expected = array(
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/owner',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}read',
'principal' => 'principals/owner/calendar-proxy-write',
'protected' => true,
),
@@ -85,8 +125,13 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
'protected' => true,
),
array(
- 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
- 'principal' => '{DAV:}authenticated',
+ 'privilege' => '{DAV:}write',
+ 'principal' => 'principals/owner',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}write',
+ 'principal' => 'principals/owner/calendar-proxy-write',
'protected' => true,
),
array(
@@ -101,7 +146,43 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
),
);
- $this->assertEquals($expected, $this->getInstance()->getACL());
+ $this->assertEquals($expected, $this->getInstance()->getChildACL());
+
+ }
+
+ function testGetChildACLReadOnly() {
+
+ $expected = array(
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/owner',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/owner/calendar-proxy-write',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/owner/calendar-proxy-read',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/sharee',
+ 'protected' => true,
+ ),
+ );
+
+ $props = array(
+ 'id' => 1,
+ '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original',
+ '{http://sabredav.org/ns}owner-principal' => 'principals/owner',
+ '{http://sabredav.org/ns}read-only' => true,
+ 'principaluri' => 'principals/sharee',
+ );
+ $this->assertEquals($expected, $this->getInstance($props)->getChildACL());
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php
index 60a71fd7f..b4270da7d 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php
@@ -33,7 +33,7 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
'id' => 3,
'uri' => 'cal3',
),
- );
+ );
parent::setUp();
@@ -46,6 +46,10 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
function testSimple() {
$this->assertInstanceOf('Sabre\\CalDAV\\SharingPlugin', $this->server->getPlugin('caldav-sharing'));
+ $this->assertEquals(
+ 'caldav-sharing',
+ $this->caldavSharingPlugin->getPluginInfo()['name']
+ );
}
@@ -58,14 +62,14 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
function testBeforeGetShareableCalendar() {
// Forcing the server to authenticate:
- $this->authPlugin->beforeMethod('GET','');
+ $this->authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
$props = $this->server->getProperties('calendars/user1/cal1', array(
'{' . Plugin::NS_CALENDARSERVER . '}invite',
'{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes',
));
- $this->assertInstanceOf('Sabre\\CalDAV\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
- $this->assertInstanceOf('Sabre\\CalDAV\\Property\\AllowedSharingModes', $props['{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes']);
+ $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
+ $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes']);
}
@@ -76,8 +80,8 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
'{' . Plugin::NS_CALENDARSERVER . '}invite',
));
- $this->assertInstanceOf('Sabre\\CalDAV\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
- $this->assertInstanceOf('Sabre\\DAV\\Property\\IHref', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']);
+ $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
+ $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']);
}
@@ -92,15 +96,12 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
array()
);
$result = $this->server->updateProperties('calendars/user1/cal1', array(
- '{DAV:}resourcetype' => new DAV\Property\ResourceType(array('{DAV:}collection'))
+ '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection'])
));
- $this->assertEquals(array(
- 200 => array(
- '{DAV:}resourcetype' => null,
- ),
- 'href' => 'calendars/user1/cal1',
- ), $result);
+ $this->assertEquals([
+ '{DAV:}resourcetype' => 200
+ ], $result);
$this->assertEquals(0, count($this->caldavBackend->getShares(1)));
@@ -113,30 +114,27 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
));
$this->assertEquals(array(
- 403 => array(
- '{DAV:}foo' => null,
- ),
- 'href' => 'calendars/user1/cal3',
+ '{DAV:}foo' => 403,
), $result);
}
function testUnknownMethodNoPOST() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PATCH',
'REQUEST_URI' => '/',
));
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $response->status, $response->body);
+ $this->assertEquals(501, $response->status, $response->body);
}
function testUnknownMethodNoXML() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/',
'CONTENT_TYPE' => 'text/plain',
@@ -144,13 +142,13 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $response->status, $response->body);
+ $this->assertEquals(501, $response->status, $response->body);
}
function testUnknownMethodNoNode() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/foo',
'CONTENT_TYPE' => 'text/xml',
@@ -158,13 +156,13 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $response->status, $response->body);
+ $this->assertEquals(501, $response->status, $response->body);
}
function testShareRequest() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1/cal1',
'CONTENT_TYPE' => 'text/xml',
@@ -187,7 +185,7 @@ RRR;
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 200 OK', $response->status, $response->body);
+ $this->assertEquals(200, $response->status, $response->body);
$this->assertEquals(array(array(
'href' => 'mailto:joe@example.org',
@@ -207,7 +205,7 @@ RRR;
function testShareRequestNoShareableCalendar() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1/cal2',
'CONTENT_TYPE' => 'text/xml',
@@ -229,13 +227,13 @@ RRR;
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $response->status, $response->body);
+ $this->assertEquals(501, $response->status, $response->body);
}
function testInviteReply() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1',
'CONTENT_TYPE' => 'text/xml',
@@ -250,13 +248,13 @@ RRR;
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 200 OK', $response->status, $response->body);
+ $this->assertEquals(200, $response->status, $response->body);
}
function testInviteBadXML() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1',
'CONTENT_TYPE' => 'text/xml',
@@ -268,13 +266,13 @@ RRR;
';
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, $response->body);
+ $this->assertEquals(400, $response->status, $response->body);
}
function testInviteWrongUrl() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1/cal1',
'CONTENT_TYPE' => 'text/xml',
@@ -287,7 +285,7 @@ RRR;
';
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $response->status, $response->body);
+ $this->assertEquals(501, $response->status, $response->body);
// If the plugin did not handle this request, it must ensure that the
// body is still accessible by other plugins.
@@ -297,7 +295,7 @@ RRR;
function testPublish() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1/cal1',
'CONTENT_TYPE' => 'text/xml',
@@ -310,13 +308,13 @@ RRR;
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 202 Accepted', $response->status, $response->body);
+ $this->assertEquals(202, $response->status, $response->body);
}
function testUnpublish() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1/cal1',
'CONTENT_TYPE' => 'text/xml',
@@ -329,13 +327,13 @@ RRR;
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 200 OK', $response->status, $response->body);
+ $this->assertEquals(200, $response->status, $response->body);
}
function testPublishWrongUrl() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1/cal2',
'CONTENT_TYPE' => 'text/xml',
@@ -348,13 +346,13 @@ RRR;
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $response->status, $response->body);
+ $this->assertEquals(501, $response->status, $response->body);
}
function testUnpublishWrongUrl() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1/cal2',
'CONTENT_TYPE' => 'text/xml',
@@ -367,13 +365,13 @@ RRR;
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $response->status, $response->body);
+ $this->assertEquals(501, $response->status, $response->body);
}
function testUnknownXmlDoc() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'POST',
'REQUEST_URI' => '/calendars/user1/cal2',
'CONTENT_TYPE' => 'text/xml',
@@ -385,7 +383,7 @@ RRR;
$request->setBody($xml);
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 501 Not Implemented', $response->status, $response->body);
+ $this->assertEquals(501, $response->status, $response->body);
}
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/UserCalendarsSharedCalendarsTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/UserCalendarsSharedCalendarsTest.php
deleted file mode 100644
index 4c3bae3a4..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/UserCalendarsSharedCalendarsTest.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV;
-
-use Sabre\DAVACL;
-
-require_once 'Sabre/CalDAV/TestUtil.php';
-
-/**
- * @covers Sabre\CalDAV\UserCalendars
- */
-class UserCalendarsSharedCalendarsTest extends \PHPUnit_Framework_TestCase {
-
- protected $backend;
-
- function getInstance() {
-
- $calendars = array(
- array(
- 'id' => 1,
- 'principaluri' => 'principals/user1',
- ),
- array(
- 'id' => 2,
- '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/cal1',
- '{http://sabredav.org/ns}owner-principal' => 'principal/owner',
- '{http://sabredav.org/ns}read-only' => false,
- 'principaluri' => 'principals/user1',
- ),
- );
-
- $this->backend = new Backend\Mock(
- $calendars,
- array(),
- array()
- );
-
- return new UserCalendars($this->backend, array(
- 'uri' => 'principals/user1'
- ));
-
- }
-
- function testSimple() {
-
- $instance = $this->getInstance();
- $this->assertEquals('user1', $instance->getName());
-
- }
-
- function testGetChildren() {
-
- $instance = $this->getInstance();
- $children = $instance->getChildren();
- $this->assertEquals(4, count($children));
-
- // Testing if we got all the objects back.
- $hasShareable = false;
- $hasShared = false;
- $hasOutbox = false;
- $hasNotifications = false;
-
- foreach($children as $child) {
-
- if ($child instanceof IShareableCalendar) {
- $hasShareable = true;
- }
- if ($child instanceof ISharedCalendar) {
- $hasShared = true;
- }
- if ($child instanceof Schedule\IOutbox) {
- $hasOutbox = true;
- }
- if ($child instanceof Notifications\ICollection) {
- $hasNotifications = true;
- }
-
- }
- if (!$hasShareable) $this->fail('Missing node!');
- if (!$hasShared) $this->fail('Missing node!');
- if (!$hasOutbox) $this->fail('Missing node!');
- if (!$hasNotifications) $this->fail('Missing node!');
-
- }
-
- function testShareReply() {
-
- $instance = $this->getInstance();
- $instance->shareReply('uri', SharingPlugin::STATUS_DECLINED, 'curi', '1');
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/UserCalendarsTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/UserCalendarsTest.php
deleted file mode 100644
index 453c872e5..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/UserCalendarsTest.php
+++ /dev/null
@@ -1,207 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV;
-use Sabre\DAVACL;
-use Sabre\DAV;
-
-require_once 'Sabre/CalDAV/TestUtil.php';
-
-/**
- * @covers Sabre\CalDAV\UserCalendars
- */
-class UserCalendarsTest extends \PHPUnit_Framework_TestCase {
-
- /**
- * @var Sabre\CalDAV\UserCalendars
- */
- protected $usercalendars;
- /**
- * @var Sabre\CalDAV\Backend\PDO
- */
- protected $backend;
-
- function setup() {
-
- if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
- $this->backend = TestUtil::getBackend();
- $this->usercalendars = new UserCalendars($this->backend, array(
- 'uri' => 'principals/user1'
- ));
-
- }
-
- function testSimple() {
-
- $this->assertEquals('user1',$this->usercalendars->getName());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\NotFound
- * @depends testSimple
- */
- function testGetChildNotFound() {
-
- $this->usercalendars->getChild('randomname');
-
- }
-
- function testChildExists() {
-
- $this->assertFalse($this->usercalendars->childExists('foo'));
- $this->assertTrue($this->usercalendars->childExists('UUID-123467'));
-
- }
-
- function testGetOwner() {
-
- $this->assertEquals('principals/user1', $this->usercalendars->getOwner());
-
- }
-
- function testGetGroup() {
-
- $this->assertNull($this->usercalendars->getGroup());
-
- }
-
- function testGetACL() {
-
- $expected = array(
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/user1',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/user1',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/user1/calendar-proxy-write',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/user1/calendar-proxy-write',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/user1/calendar-proxy-read',
- 'protected' => true,
- ),
- );
- $this->assertEquals($expected, $this->usercalendars->getACL());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\MethodNotAllowed
- */
- function testSetACL() {
-
- $this->usercalendars->setACL(array());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\Forbidden
- * @depends testSimple
- */
- function testSetName() {
-
- $this->usercalendars->setName('bla');
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\Forbidden
- * @depends testSimple
- */
- function testDelete() {
-
- $this->usercalendars->delete();
-
- }
-
- /**
- * @depends testSimple
- */
- function testGetLastModified() {
-
- $this->assertNull($this->usercalendars->getLastModified());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\MethodNotAllowed
- * @depends testSimple
- */
- function testCreateFile() {
-
- $this->usercalendars->createFile('bla');
-
- }
-
-
- /**
- * @expectedException Sabre\DAV\Exception\MethodNotAllowed
- * @depends testSimple
- */
- function testCreateDirectory() {
-
- $this->usercalendars->createDirectory('bla');
-
- }
-
- /**
- * @depends testSimple
- */
- function testCreateExtendedCollection() {
-
- $result = $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'), array());
- $this->assertNull($result);
- $cals = $this->backend->getCalendarsForUser('principals/user1');
- $this->assertEquals(3,count($cals));
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\InvalidResourceType
- * @depends testSimple
- */
- function testCreateExtendedCollectionBadResourceType() {
-
- $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection','{DAV:}blabla'), array());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\InvalidResourceType
- * @depends testSimple
- */
- function testCreateExtendedCollectionNotACalendar() {
-
- $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection'), array());
-
- }
-
- function testGetSupportedPrivilegesSet() {
-
- $this->assertNull($this->usercalendars->getSupportedPrivilegeSet());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\NotImplemented
- */
- function testShareReplyFail() {
-
- $this->usercalendars->shareReply('uri', SharingPlugin::STATUS_DECLINED, 'curi', '1');
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
index 6634b9c3b..be166d9e6 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
@@ -26,24 +26,25 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
'id' => 'calendar1',
'principaluri' => 'principals/admin',
'uri' => 'calendar1',
- '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet( array('VEVENT','VTODO','VJOURNAL') ),
+ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet( ['VEVENT','VTODO','VJOURNAL'] ),
),
array(
'id' => 'calendar2',
'principaluri' => 'principals/admin',
'uri' => 'calendar2',
- '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet( array('VTODO','VJOURNAL') ),
+ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet( ['VTODO','VJOURNAL'] ),
)
);
- $this->calBackend = new Backend\Mock($calendars,array());
+ $this->calBackend = new Backend\Mock($calendars, []);
$principalBackend = new DAVACL\PrincipalBackend\Mock();
- $tree = array(
- new CalendarRootNode($principalBackend, $this->calBackend),
- );
+ $tree = [
+ new CalendarRoot($principalBackend, $this->calBackend),
+ ];
$this->server = new DAV\Server($tree);
+ $this->server->sapi = new HTTP\SapiMock();
$this->server->debugExceptions = true;
$plugin = new Plugin();
@@ -65,20 +66,20 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
function testCreateFile() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status);
+ $this->assertEquals(415, $response->status);
}
function testCreateFileValid() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -86,11 +87,18 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 201 Created', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(array(
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Length' => ['0'],
+ 'ETag' => ['"' . md5("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n") . '"'],
+ ), $response->getHeaders());
+
$expected = array(
'uri' => 'blabla.ics',
'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
'calendarid' => 'calendar1',
+ 'lastmodified' => null,
);
$this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1','blabla.ics'));
@@ -99,7 +107,7 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
function testCreateFileNoComponents() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -107,13 +115,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testCreateFileNoUID() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -121,13 +129,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testCreateFileVCard() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -135,13 +143,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testCreateFile2Components() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -149,13 +157,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testCreateFile2UIDS() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -163,13 +171,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testCreateFileWrongComponent() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -177,28 +185,28 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testUpdateFile() {
$this->calBackend->createCalendarObject('calendar1','blabla.ics','foo');
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status);
+ $this->assertEquals(415, $response->status);
}
function testUpdateFileParsableBody() {
$this->calBackend->createCalendarObject('calendar1','blabla.ics','foo');
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -207,12 +215,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 204 No Content', $response->status);
+ $this->assertEquals(204, $response->status);
$expected = array(
'uri' => 'blabla.ics',
'calendardata' => $body,
'calendarid' => 'calendar1',
+ 'lastmodified' => null,
);
$this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1','blabla.ics'));
@@ -221,7 +230,7 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
function testCreateFileInvalidComponent() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics',
));
@@ -229,14 +238,14 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 403 Forbidden', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testUpdateFileInvalidComponent() {
$this->calBackend->createCalendarObject('calendar2','blabla.ics','foo');
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics',
));
@@ -244,7 +253,29 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 403 Forbidden', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+
+ }
+
+ /**
+ * What we are testing here, is if we send in a latin1 character, the
+ * server should automatically transform this into UTF-8.
+ *
+ * More importantly. If any transformation happens, the etag must no longer
+ * be returned by the server.
+ */
+ function testCreateFileModified() {
+
+ $request = HTTP\Sapi::createFromServerArray(array(
+ 'REQUEST_METHOD' => 'PUT',
+ 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
+ ));
+ $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nSUMMARY:Meeting in M\xfcnster\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
+
+ $response = $this->request($request);
+
+ $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertNull($response->getHeader('ETag'));
}
}
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/VersionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/VersionTest.php
deleted file mode 100644
index a4e093e35..000000000
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/VersionTest.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV;
-
-class VersionTest extends \PHPUnit_Framework_TestCase {
-
- function testString() {
-
- $v = Version::VERSION;
- $this->assertEquals(-1, version_compare('1.0.0',$v));
-
- $s = Version::STABILITY;
- $this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable');
-
- }
-
-}