1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\CalDAV\Subscriptions; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse Sabre\CalDAV; 6*a1a3b679SAndreas Boehleruse Sabre\HTTP\Request; 7*a1a3b679SAndreas Boehler 8*a1a3b679SAndreas Boehlerclass CreateSubscriptionTest extends \Sabre\DAVServerTest { 9*a1a3b679SAndreas Boehler 10*a1a3b679SAndreas Boehler protected $setupCalDAV = true; 11*a1a3b679SAndreas Boehler protected $setupCalDAVSubscriptions = true; 12*a1a3b679SAndreas Boehler 13*a1a3b679SAndreas Boehler /** 14*a1a3b679SAndreas Boehler * OS X 10.7 - 10.9.1 15*a1a3b679SAndreas Boehler */ 16*a1a3b679SAndreas Boehler function testMKCOL() { 17*a1a3b679SAndreas Boehler 18*a1a3b679SAndreas Boehler $body = <<<XML 19*a1a3b679SAndreas Boehler<A:mkcol xmlns:A="DAV:"> 20*a1a3b679SAndreas Boehler <A:set> 21*a1a3b679SAndreas Boehler <A:prop> 22*a1a3b679SAndreas Boehler <B:subscribed-strip-attachments xmlns:B="http://calendarserver.org/ns/" /> 23*a1a3b679SAndreas Boehler <B:subscribed-strip-todos xmlns:B="http://calendarserver.org/ns/" /> 24*a1a3b679SAndreas Boehler <A:resourcetype> 25*a1a3b679SAndreas Boehler <A:collection /> 26*a1a3b679SAndreas Boehler <B:subscribed xmlns:B="http://calendarserver.org/ns/" /> 27*a1a3b679SAndreas Boehler </A:resourcetype> 28*a1a3b679SAndreas Boehler <E:calendar-color xmlns:E="http://apple.com/ns/ical/">#1C4587FF</E:calendar-color> 29*a1a3b679SAndreas Boehler <A:displayname>Jewish holidays</A:displayname> 30*a1a3b679SAndreas Boehler <C:calendar-description xmlns:C="urn:ietf:params:xml:ns:caldav">Foo</C:calendar-description> 31*a1a3b679SAndreas Boehler <E:calendar-order xmlns:E="http://apple.com/ns/ical/">19</E:calendar-order> 32*a1a3b679SAndreas Boehler <B:source xmlns:B="http://calendarserver.org/ns/"> 33*a1a3b679SAndreas Boehler <A:href>webcal://www.example.org/</A:href> 34*a1a3b679SAndreas Boehler </B:source> 35*a1a3b679SAndreas Boehler <E:refreshrate xmlns:E="http://apple.com/ns/ical/">P1W</E:refreshrate> 36*a1a3b679SAndreas Boehler <B:subscribed-strip-alarms xmlns:B="http://calendarserver.org/ns/" /> 37*a1a3b679SAndreas Boehler </A:prop> 38*a1a3b679SAndreas Boehler </A:set> 39*a1a3b679SAndreas Boehler</A:mkcol> 40*a1a3b679SAndreas BoehlerXML; 41*a1a3b679SAndreas Boehler 42*a1a3b679SAndreas Boehler $headers = [ 43*a1a3b679SAndreas Boehler 'Content-Type' => 'application/xml', 44*a1a3b679SAndreas Boehler ]; 45*a1a3b679SAndreas Boehler $request = new Request('MKCOL', '/calendars/user1/subscription1', $headers, $body); 46*a1a3b679SAndreas Boehler 47*a1a3b679SAndreas Boehler $response = $this->request($request); 48*a1a3b679SAndreas Boehler $this->assertEquals(201, $response->getStatus()); 49*a1a3b679SAndreas Boehler $subscriptions = $this->caldavBackend->getSubscriptionsForUser('principals/user1'); 50*a1a3b679SAndreas Boehler $this->assertSubscription($subscriptions[0]); 51*a1a3b679SAndreas Boehler 52*a1a3b679SAndreas Boehler 53*a1a3b679SAndreas Boehler } 54*a1a3b679SAndreas Boehler /** 55*a1a3b679SAndreas Boehler * OS X 10.9.2 and up 56*a1a3b679SAndreas Boehler */ 57*a1a3b679SAndreas Boehler function testMKCALENDAR() { 58*a1a3b679SAndreas Boehler 59*a1a3b679SAndreas Boehler $body = <<<XML 60*a1a3b679SAndreas Boehler<B:mkcalendar xmlns:B="urn:ietf:params:xml:ns:caldav"> 61*a1a3b679SAndreas Boehler <A:set xmlns:A="DAV:"> 62*a1a3b679SAndreas Boehler <A:prop> 63*a1a3b679SAndreas Boehler <B:supported-calendar-component-set> 64*a1a3b679SAndreas Boehler <B:comp name="VEVENT" /> 65*a1a3b679SAndreas Boehler </B:supported-calendar-component-set> 66*a1a3b679SAndreas Boehler <C:subscribed-strip-alarms xmlns:C="http://calendarserver.org/ns/" /> 67*a1a3b679SAndreas Boehler <C:subscribed-strip-attachments xmlns:C="http://calendarserver.org/ns/" /> 68*a1a3b679SAndreas Boehler <A:resourcetype> 69*a1a3b679SAndreas Boehler <A:collection /> 70*a1a3b679SAndreas Boehler <C:subscribed xmlns:C="http://calendarserver.org/ns/" /> 71*a1a3b679SAndreas Boehler </A:resourcetype> 72*a1a3b679SAndreas Boehler <D:refreshrate xmlns:D="http://apple.com/ns/ical/">P1W</D:refreshrate> 73*a1a3b679SAndreas Boehler <C:source xmlns:C="http://calendarserver.org/ns/"> 74*a1a3b679SAndreas Boehler <A:href>webcal://www.example.org/</A:href> 75*a1a3b679SAndreas Boehler </C:source> 76*a1a3b679SAndreas Boehler <D:calendar-color xmlns:D="http://apple.com/ns/ical/">#1C4587FF</D:calendar-color> 77*a1a3b679SAndreas Boehler <D:calendar-order xmlns:D="http://apple.com/ns/ical/">19</D:calendar-order> 78*a1a3b679SAndreas Boehler <B:calendar-description>Foo</B:calendar-description> 79*a1a3b679SAndreas Boehler <C:subscribed-strip-todos xmlns:C="http://calendarserver.org/ns/" /> 80*a1a3b679SAndreas Boehler <A:displayname>Jewish holidays</A:displayname> 81*a1a3b679SAndreas Boehler </A:prop> 82*a1a3b679SAndreas Boehler </A:set> 83*a1a3b679SAndreas Boehler</B:mkcalendar> 84*a1a3b679SAndreas BoehlerXML; 85*a1a3b679SAndreas Boehler 86*a1a3b679SAndreas Boehler $headers = [ 87*a1a3b679SAndreas Boehler 'Content-Type' => 'application/xml', 88*a1a3b679SAndreas Boehler ]; 89*a1a3b679SAndreas Boehler $request = new Request('MKCALENDAR', '/calendars/user1/subscription1', $headers, $body); 90*a1a3b679SAndreas Boehler 91*a1a3b679SAndreas Boehler $response = $this->request($request); 92*a1a3b679SAndreas Boehler $this->assertEquals(201, $response->getStatus()); 93*a1a3b679SAndreas Boehler $subscriptions = $this->caldavBackend->getSubscriptionsForUser('principals/user1'); 94*a1a3b679SAndreas Boehler $this->assertSubscription($subscriptions[0]); 95*a1a3b679SAndreas Boehler 96*a1a3b679SAndreas Boehler // Also seeing if it works when calling this as a PROPFIND. 97*a1a3b679SAndreas Boehler $this->assertEquals([ 98*a1a3b679SAndreas Boehler '{http://calendarserver.org/ns/}subscribed-strip-alarms' => '', 99*a1a3b679SAndreas Boehler ], 100*a1a3b679SAndreas Boehler $this->server->getProperties('calendars/user1/subscription1', ['{http://calendarserver.org/ns/}subscribed-strip-alarms']) 101*a1a3b679SAndreas Boehler ); 102*a1a3b679SAndreas Boehler 103*a1a3b679SAndreas Boehler 104*a1a3b679SAndreas Boehler } 105*a1a3b679SAndreas Boehler 106*a1a3b679SAndreas Boehler function assertSubscription($subscription) { 107*a1a3b679SAndreas Boehler 108*a1a3b679SAndreas Boehler $this->assertEquals('', $subscription['{http://calendarserver.org/ns/}subscribed-strip-attachments']); 109*a1a3b679SAndreas Boehler $this->assertEquals('', $subscription['{http://calendarserver.org/ns/}subscribed-strip-todos']); 110*a1a3b679SAndreas Boehler $this->assertEquals('#1C4587FF', $subscription['{http://apple.com/ns/ical/}calendar-color']); 111*a1a3b679SAndreas Boehler $this->assertEquals('Jewish holidays', $subscription['{DAV:}displayname']); 112*a1a3b679SAndreas Boehler $this->assertEquals('Foo', $subscription['{urn:ietf:params:xml:ns:caldav}calendar-description']); 113*a1a3b679SAndreas Boehler $this->assertEquals('19', $subscription['{http://apple.com/ns/ical/}calendar-order']); 114*a1a3b679SAndreas Boehler $this->assertEquals('webcal://www.example.org/', $subscription['{http://calendarserver.org/ns/}source']->getHref()); 115*a1a3b679SAndreas Boehler $this->assertEquals('P1W', $subscription['{http://apple.com/ns/ical/}refreshrate']); 116*a1a3b679SAndreas Boehler $this->assertEquals('subscription1', $subscription['uri']); 117*a1a3b679SAndreas Boehler $this->assertEquals('principals/user1', $subscription['principaluri']); 118*a1a3b679SAndreas Boehler $this->assertEquals('webcal://www.example.org/', $subscription['source']); 119*a1a3b679SAndreas Boehler $this->assertEquals(['principals/user1', 1], $subscription['id']); 120*a1a3b679SAndreas Boehler 121*a1a3b679SAndreas Boehler } 122*a1a3b679SAndreas Boehler 123*a1a3b679SAndreas Boehler} 124