mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-09 18:08:49 +00:00
Heavily refactored, including multiple calendars per user and recurring events. Not in an installable state yet, though
This commit is contained in:
parent
4a5e30ec84
commit
fefee23e90
78 changed files with 8026 additions and 1205 deletions
|
@ -1,14 +1,16 @@
|
|||
<?php
|
||||
|
||||
class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
|
||||
class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract implements Sabre_CalDAV_Backend_NotificationSupport {
|
||||
|
||||
private $calendarData;
|
||||
private $calendars;
|
||||
private $notifications;
|
||||
|
||||
function __construct(array $calendars, array $calendarData) {
|
||||
function __construct(array $calendars, array $calendarData, array $notifications = array()) {
|
||||
|
||||
$this->calendars = $calendars;
|
||||
$this->calendarData = $calendarData;
|
||||
$this->notifications = $notifications;
|
||||
|
||||
}
|
||||
|
||||
|
@ -58,7 +60,15 @@ class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
|
|||
*/
|
||||
function createCalendar($principalUri,$calendarUri,array $properties) {
|
||||
|
||||
throw new Exception('Not implemented');
|
||||
$id = Sabre_DAV_UUIDUtil::getUUID();
|
||||
$this->calendars[] = array_merge(array(
|
||||
'id' => $id,
|
||||
'principaluri' => $principalUri,
|
||||
'uri' => $calendarUri,
|
||||
'{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT','VTODO')),
|
||||
), $properties);
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
|
@ -112,7 +122,11 @@ class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
|
|||
*/
|
||||
public function deleteCalendar($calendarId) {
|
||||
|
||||
throw new Exception('Not implemented');
|
||||
foreach($this->calendars as $k=>$calendar) {
|
||||
if ($calendar['id'] === $calendarId) {
|
||||
unset($this->calendars[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -227,4 +241,37 @@ class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, Sabre_CalDAV_Notifications_INotificationType $notification) {
|
||||
|
||||
throw new Sabre_DAV_Exception_NotImplemented('This doesn\'t work!');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,56 @@ class Sabre_CalDAV_ICSExportPluginTest extends PHPUnit_Framework_TestCase {
|
|||
$this->assertEquals(1,count($obj->VERSION));
|
||||
$this->assertEquals(1,count($obj->CALSCALE));
|
||||
$this->assertEquals(1,count($obj->PRODID));
|
||||
$this->assertTrue(strpos((string)$obj->PRODID, Sabre_DAV_Version::VERSION)!==false);
|
||||
$this->assertEquals(1,count($obj->VTIMEZONE));
|
||||
$this->assertEquals(1,count($obj->VEVENT));
|
||||
|
||||
}
|
||||
function testBeforeMethodNoVersion() {
|
||||
|
||||
if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
|
||||
$cbackend = Sabre_CalDAV_TestUtil::getBackend();
|
||||
$pbackend = new Sabre_DAVACL_MockPrincipalBackend();
|
||||
|
||||
$props = array(
|
||||
'uri'=>'UUID-123467',
|
||||
'principaluri' => 'admin',
|
||||
'id' => 1,
|
||||
);
|
||||
$tree = array(
|
||||
new Sabre_CalDAV_Calendar($pbackend,$cbackend,$props),
|
||||
);
|
||||
|
||||
$p = new Sabre_CalDAV_ICSExportPlugin();
|
||||
|
||||
$s = new Sabre_DAV_Server($tree);
|
||||
|
||||
$s->addPlugin($p);
|
||||
$s->addPlugin(new Sabre_CalDAV_Plugin());
|
||||
|
||||
$h = new Sabre_HTTP_Request(array(
|
||||
'QUERY_STRING' => 'export',
|
||||
));
|
||||
|
||||
$s->httpRequest = $h;
|
||||
$s->httpResponse = new Sabre_HTTP_ResponseMock();
|
||||
|
||||
Sabre_DAV_Server::$exposeVersion = false;
|
||||
$this->assertFalse($p->beforeMethod('GET','UUID-123467?export'));
|
||||
Sabre_DAV_Server::$exposeVersion = true;
|
||||
|
||||
$this->assertEquals('HTTP/1.1 200 OK',$s->httpResponse->status);
|
||||
$this->assertEquals(array(
|
||||
'Content-Type' => 'text/calendar',
|
||||
), $s->httpResponse->headers);
|
||||
|
||||
$obj = Sabre_VObject_Reader::read($s->httpResponse->body);
|
||||
|
||||
$this->assertEquals(5,count($obj->children()));
|
||||
$this->assertEquals(1,count($obj->VERSION));
|
||||
$this->assertEquals(1,count($obj->CALSCALE));
|
||||
$this->assertEquals(1,count($obj->PRODID));
|
||||
$this->assertFalse(strpos((string)$obj->PRODID, Sabre_DAV_Version::VERSION)!==false);
|
||||
$this->assertEquals(1,count($obj->VTIMEZONE));
|
||||
$this->assertEquals(1,count($obj->VEVENT));
|
||||
|
||||
|
|
96
dav/SabreDAV/tests/Sabre/CalDAV/Issue220Test.php
Normal file
96
dav/SabreDAV/tests/Sabre/CalDAV/Issue220Test.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This unittest is created to check for an endless loop in Sabre_CalDAV_CalendarQueryValidator
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Issue220Test extends Sabre_DAVServerTest {
|
||||
|
||||
protected $setupCalDAV = true;
|
||||
|
||||
protected $caldavCalendars = array(
|
||||
array(
|
||||
'id' => 1,
|
||||
'name' => 'Calendar',
|
||||
'principaluri' => 'principals/user1',
|
||||
'uri' => 'calendar1',
|
||||
)
|
||||
);
|
||||
|
||||
protected $caldavCalendarObjects = array(
|
||||
1 => array(
|
||||
'event.ics' => array(
|
||||
'calendardata' => 'BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
BEGIN:VEVENT
|
||||
DTSTART;TZID=Europe/Berlin:20120601T180000
|
||||
SUMMARY:Brot backen
|
||||
RRULE:FREQ=DAILY;INTERVAL=1;WKST=MO
|
||||
TRANSP:OPAQUE
|
||||
DURATION:PT20M
|
||||
LAST-MODIFIED:20120601T064634Z
|
||||
CREATED:20120601T064634Z
|
||||
DTSTAMP:20120601T064634Z
|
||||
UID:b64f14c5-dccc-4eda-947f-bdb1f763fbcd
|
||||
BEGIN:VALARM
|
||||
TRIGGER;VALUE=DURATION:-PT5M
|
||||
ACTION:DISPLAY
|
||||
DESCRIPTION:Default Event Notification
|
||||
X-WR-ALARMUID:cd952c1b-b3d6-41fb-b0a6-ec3a1a5bdd58
|
||||
END:VALARM
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
DTSTART;TZID=Europe/Berlin:20120606T180000
|
||||
SUMMARY:Brot backen
|
||||
TRANSP:OPAQUE
|
||||
STATUS:CANCELLED
|
||||
DTEND;TZID=Europe/Berlin:20120606T182000
|
||||
LAST-MODIFIED:20120605T094310Z
|
||||
SEQUENCE:1
|
||||
RECURRENCE-ID:20120606T160000Z
|
||||
UID:b64f14c5-dccc-4eda-947f-bdb1f763fbcd
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
function testIssue220() {
|
||||
|
||||
$request = new Sabre_HTTP_Request(array(
|
||||
'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">
|
||||
<D:prop>
|
||||
<C:calendar-data/>
|
||||
<D:getetag/>
|
||||
</D:prop>
|
||||
<C:filter>
|
||||
<C:comp-filter name="VCALENDAR">
|
||||
<C:comp-filter name="VEVENT">
|
||||
<C:comp-filter name="VALARM">
|
||||
<C:time-range start="20120607T161646Z" end="20120612T161646Z"/>
|
||||
</C:comp-filter>
|
||||
</C:comp-filter>
|
||||
</C:comp-filter>
|
||||
</C:filter>
|
||||
</C:calendar-query>');
|
||||
|
||||
$response = $this->request($request);
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
class Sabre_CalDAV_Notifications_CollectionTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
function testGetChildren() {
|
||||
|
||||
$principalUri = 'principals/user1';
|
||||
|
||||
$systemStatus = new Sabre_CalDAV_Notifications_Notification_SystemStatus(1);
|
||||
|
||||
$caldavBackend = new Sabre_CalDAV_Backend_Mock(array(),array(), array(
|
||||
'principals/user1' => array(
|
||||
$systemStatus
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$col = new Sabre_CalDAV_Notifications_Collection($caldavBackend, $principalUri);
|
||||
$this->assertEquals('notifications', $col->getName());
|
||||
|
||||
$this->assertEquals(array(
|
||||
new Sabre_CalDAV_Notifications_Node($caldavBackend, $systemStatus)
|
||||
), $col->getChildren());
|
||||
|
||||
}
|
||||
|
||||
}
|
23
dav/SabreDAV/tests/Sabre/CalDAV/Notifications/NodeTest.php
Normal file
23
dav/SabreDAV/tests/Sabre/CalDAV/Notifications/NodeTest.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
class Sabre_CalDAV_Notifications_NodeTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
function testGetId() {
|
||||
|
||||
$principalUri = 'principals/user1';
|
||||
|
||||
$systemStatus = new Sabre_CalDAV_Notifications_Notification_SystemStatus(1);
|
||||
|
||||
$caldavBackend = new Sabre_CalDAV_Backend_Mock(array(),array(), array(
|
||||
'principals/user1' => array(
|
||||
$systemStatus
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$node = new Sabre_CalDAV_Notifications_Node($caldavBackend, $systemStatus);
|
||||
$this->assertEquals($systemStatus->getId(), $node->getName());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
class Sabre_CalDAV_Notifications_Notification extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* @dataProvider dataProvider
|
||||
*/
|
||||
function testSerializers($notification, $expected1, $expected2) {
|
||||
|
||||
$this->assertEquals('foo', $notification->getId());
|
||||
|
||||
|
||||
$dom = new DOMDocument('1.0','UTF-8');
|
||||
$elem = $dom->createElement('cs:root');
|
||||
$elem->setAttribute('xmlns:cs',Sabre_CalDAV_Plugin::NS_CALENDARSERVER);
|
||||
$dom->appendChild($elem);
|
||||
$notification->serialize(new Sabre_DAV_Server(), $elem);
|
||||
$this->assertEquals($expected1, $dom->saveXML());
|
||||
|
||||
$dom = new DOMDocument('1.0','UTF-8');
|
||||
$elem = $dom->createElement('cs:root');
|
||||
$elem->setAttribute('xmlns:cs',Sabre_CalDAV_Plugin::NS_CALENDARSERVER);
|
||||
$dom->appendChild($elem);
|
||||
$notification->serializeBody(new Sabre_DAV_Server(), $elem);
|
||||
$this->assertEquals($expected2, $dom->saveXML());
|
||||
|
||||
|
||||
}
|
||||
|
||||
function dataProvider() {
|
||||
|
||||
return array(
|
||||
|
||||
array(
|
||||
new Sabre_CalDAV_Notifications_Notification_SystemStatus('foo'),
|
||||
'<?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 Sabre_CalDAV_Notifications_Notification_SystemStatus('foo',Sabre_CalDAV_Notifications_Notification_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 Sabre_CalDAV_Notifications_Notification_SystemStatus('foo',Sabre_CalDAV_Notifications_Notification_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",
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -191,7 +191,17 @@ class Sabre_CalDAV_OutboxPostTest extends Sabre_DAVServerTest {
|
|||
|
||||
$req->setBody(implode("\r\n",$body));
|
||||
|
||||
$this->assertHTTPStatus(501, $req);
|
||||
|
||||
$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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -218,7 +228,66 @@ class Sabre_CalDAV_OutboxPostTest extends Sabre_DAVServerTest {
|
|||
$handler = new Sabre_CalDAV_Schedule_IMip_Mock('server@example.org');
|
||||
|
||||
$this->caldavPlugin->setIMIPhandler($handler);
|
||||
$this->assertHTTPStatus(200, $req);
|
||||
|
||||
$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: ' . Sabre_DAV_Version::VERSION . '-' . Sabre_DAV_Version::STABILITY,
|
||||
),
|
||||
)
|
||||
), $handler->getSentEmails());
|
||||
|
||||
}
|
||||
|
||||
function testSuccessRequestUpperCased() {
|
||||
|
||||
$req = new Sabre_HTTP_Request(array(
|
||||
'REQUEST_METHOD' => 'POST',
|
||||
'REQUEST_URI' => '/calendars/user1/outbox',
|
||||
'HTTP_ORIGINATOR' => 'MAILTO:user1.sabredav@sabredav.org',
|
||||
'HTTP_RECIPIENT' => 'MAILTO:user2@example.org',
|
||||
));
|
||||
|
||||
$body = array(
|
||||
'BEGIN:VCALENDAR',
|
||||
'METHOD:REQUEST',
|
||||
'BEGIN:VEVENT',
|
||||
'SUMMARY:An invitation',
|
||||
'END:VEVENT',
|
||||
'END:VCALENDAR',
|
||||
);
|
||||
|
||||
$req->setBody(implode("\r\n",$body));
|
||||
|
||||
$handler = new Sabre_CalDAV_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(
|
||||
|
|
|
@ -23,8 +23,34 @@ class Sabre_CalDAV_PluginTest extends PHPUnit_Framework_TestCase {
|
|||
|
||||
function setup() {
|
||||
|
||||
if (!SABRE_HASSQLITE) $this->markTestSkipped('No PDO SQLite support');
|
||||
$this->caldavBackend = Sabre_CalDAV_TestUtil::getBackend();
|
||||
$this->caldavBackend = new Sabre_CalDAV_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 Sabre_CalDAV_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 Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT','VTODO')),
|
||||
)
|
||||
), array(
|
||||
1 => array(
|
||||
'UUID-2345' => array(
|
||||
'calendardata' => Sabre_CalDAV_TestUtil::getTestCalendarData(),
|
||||
)
|
||||
)
|
||||
));
|
||||
$principalBackend = new Sabre_DAVACL_MockPrincipalBackend();
|
||||
$principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read',array('principals/user1'));
|
||||
$principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write',array('principals/user1'));
|
||||
|
@ -398,6 +424,7 @@ END:VCALENDAR';
|
|||
'{urn:ietf:params:xml:ns:caldav}calendar-user-address-set',
|
||||
'{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}calendar-proxy-read-for',
|
||||
'{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}calendar-proxy-write-for',
|
||||
'{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}notification-URL',
|
||||
));
|
||||
|
||||
$this->assertArrayHasKey(0,$props);
|
||||
|
@ -414,6 +441,12 @@ END:VCALENDAR';
|
|||
$this->assertTrue($prop instanceof Sabre_DAV_Property_Href);
|
||||
$this->assertEquals('calendars/user1/outbox',$prop->getHref());
|
||||
|
||||
$this->assertArrayHasKey('{'.Sabre_CalDAV_Plugin::NS_CALENDARSERVER .'}notification-URL',$props[0][200]);
|
||||
$prop = $props[0][200]['{'.Sabre_CalDAV_Plugin::NS_CALENDARSERVER .'}notification-URL'];
|
||||
$this->assertTrue($prop instanceof Sabre_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 Sabre_DAV_Property_HrefList);
|
||||
|
@ -429,6 +462,7 @@ END:VCALENDAR';
|
|||
$this->assertInstanceOf('Sabre_DAV_Property_HrefList', $prop);
|
||||
$this->assertEquals(array('principals/admin'), $prop->getHrefs());
|
||||
|
||||
|
||||
}
|
||||
|
||||
function testSupportedReportSetPropertyNonCalendar() {
|
||||
|
@ -755,7 +789,7 @@ END:VCALENDAR';
|
|||
'<d:prop>' .
|
||||
' <c:calendar-data>' .
|
||||
' <c:expand start="20000101T000000Z" end="20101231T235959Z" />' .
|
||||
' </c:calendar-data>' .
|
||||
' </c:calendar-data>' .
|
||||
' <d:getetag />' .
|
||||
'</d:prop>' .
|
||||
'<c:filter>' .
|
||||
|
@ -991,4 +1025,60 @@ END:VCALENDAR';
|
|||
$this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status,'Invalid HTTP status received. Full response body: ' . $this->response->body);
|
||||
|
||||
}
|
||||
|
||||
function testNotificationProperties() {
|
||||
|
||||
$request = array(
|
||||
'{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}notificationtype',
|
||||
);
|
||||
$result = array();
|
||||
$notification = new Sabre_CalDAV_Notifications_Node(
|
||||
$this->caldavBackend,
|
||||
new Sabre_CalDAV_Notifications_Notification_SystemStatus('foo')
|
||||
);
|
||||
$this->plugin->beforeGetProperties('foo', $notification, $request, $result);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
200 => array(
|
||||
'{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}notificationtype' => $notification->getNotificationType()
|
||||
)
|
||||
), $result);
|
||||
|
||||
}
|
||||
|
||||
function testNotificationGet() {
|
||||
|
||||
$notification = new Sabre_CalDAV_Notifications_Node(
|
||||
$this->caldavBackend,
|
||||
new Sabre_CalDAV_Notifications_Notification_SystemStatus('foo')
|
||||
);
|
||||
|
||||
$server = new Sabre_DAV_Server(array($notification));
|
||||
$caldav = new Sabre_CalDAV_Plugin();
|
||||
|
||||
$httpResponse = new Sabre_HTTP_ResponseMock();
|
||||
$server->httpResponse = $httpResponse;
|
||||
|
||||
$server->addPlugin($caldav);
|
||||
|
||||
$caldav->beforeMethod('GET','foo');
|
||||
|
||||
$this->assertEquals('HTTP/1.1 200 OK', $httpResponse->status);
|
||||
$this->assertEquals(array(
|
||||
'Content-Type' => 'application/xml',
|
||||
), $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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,13 @@ class Sabre_CalDAV_ValidateICalTest extends PHPUnit_Framework_TestCase {
|
|||
'id' => 'calendar1',
|
||||
'principaluri' => 'principals/admin',
|
||||
'uri' => 'calendar1',
|
||||
'{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet( array('VEVENT','VTODO','VJOURNAL') ),
|
||||
),
|
||||
array(
|
||||
'id' => 'calendar2',
|
||||
'principaluri' => 'principals/admin',
|
||||
'uri' => 'calendar2',
|
||||
'{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet( array('VTODO','VJOURNAL') ),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -207,4 +214,33 @@ class Sabre_CalDAV_ValidateICalTest extends PHPUnit_Framework_TestCase {
|
|||
$this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1','blabla.ics'));
|
||||
|
||||
}
|
||||
|
||||
function testCreateFileInvalidComponent() {
|
||||
|
||||
$request = new Sabre_HTTP_Request(array(
|
||||
'REQUEST_METHOD' => 'PUT',
|
||||
'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics',
|
||||
));
|
||||
$request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
|
||||
|
||||
$response = $this->request($request);
|
||||
|
||||
$this->assertEquals('HTTP/1.1 403 Forbidden', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
|
||||
|
||||
}
|
||||
|
||||
function testUpdateFileInvalidComponent() {
|
||||
|
||||
$this->calBackend->createCalendarObject('calendar2','blabla.ics','foo');
|
||||
$request = new Sabre_HTTP_Request(array(
|
||||
'REQUEST_METHOD' => 'PUT',
|
||||
'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics',
|
||||
));
|
||||
$request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
|
||||
|
||||
$response = $this->request($request);
|
||||
|
||||
$this->assertEquals('HTTP/1.1 403 Forbidden', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue