Heavily refactored, including multiple calendars per user and recurring events. Not in an installable state yet, though

This commit is contained in:
Tobias Hößl 2012-07-08 17:12:58 +00:00
parent 4a5e30ec84
commit fefee23e90
78 changed files with 8026 additions and 1205 deletions

View file

@ -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);
}
}