1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\CalDAV\Schedule; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse 6*a1a3b679SAndreas Boehler Sabre\DAV, 7*a1a3b679SAndreas Boehler Sabre\DAVACL, 8*a1a3b679SAndreas Boehler Sabre\HTTP, 9*a1a3b679SAndreas Boehler Sabre\CalDAV, 10*a1a3b679SAndreas Boehler Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp; 11*a1a3b679SAndreas Boehler 12*a1a3b679SAndreas Boehlerclass FreeBusyRequestTest extends \PHPUnit_Framework_TestCase { 13*a1a3b679SAndreas Boehler 14*a1a3b679SAndreas Boehler protected $plugin; 15*a1a3b679SAndreas Boehler protected $server; 16*a1a3b679SAndreas Boehler protected $aclPlugin; 17*a1a3b679SAndreas Boehler protected $request; 18*a1a3b679SAndreas Boehler protected $authPlugin; 19*a1a3b679SAndreas Boehler protected $caldavBackend; 20*a1a3b679SAndreas Boehler 21*a1a3b679SAndreas Boehler function setUp() { 22*a1a3b679SAndreas Boehler 23*a1a3b679SAndreas Boehler $calendars = [ 24*a1a3b679SAndreas Boehler [ 25*a1a3b679SAndreas Boehler 'principaluri' => 'principals/user2', 26*a1a3b679SAndreas Boehler 'id' => 1, 27*a1a3b679SAndreas Boehler 'uri' => 'calendar1', 28*a1a3b679SAndreas Boehler '{' . CalDAV\Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR", 29*a1a3b679SAndreas Boehler ], 30*a1a3b679SAndreas Boehler [ 31*a1a3b679SAndreas Boehler 'principaluri' => 'principals/user2', 32*a1a3b679SAndreas Boehler 'id' => 2, 33*a1a3b679SAndreas Boehler 'uri' => 'calendar2', 34*a1a3b679SAndreas Boehler '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp(ScheduleCalendarTransp::TRANSPARENT), 35*a1a3b679SAndreas Boehler ], 36*a1a3b679SAndreas Boehler ]; 37*a1a3b679SAndreas Boehler $calendarobjects = [ 38*a1a3b679SAndreas Boehler 1 => [ '1.ics' => [ 39*a1a3b679SAndreas Boehler 'uri' => '1.ics', 40*a1a3b679SAndreas Boehler 'calendardata' => 'BEGIN:VCALENDAR 41*a1a3b679SAndreas BoehlerBEGIN:VEVENT 42*a1a3b679SAndreas BoehlerDTSTART:20110101T130000 43*a1a3b679SAndreas BoehlerDURATION:PT1H 44*a1a3b679SAndreas BoehlerEND:VEVENT 45*a1a3b679SAndreas BoehlerEND:VCALENDAR', 46*a1a3b679SAndreas Boehler 'calendarid' => 1, 47*a1a3b679SAndreas Boehler ]], 48*a1a3b679SAndreas Boehler 2 => [ '2.ics' => [ 49*a1a3b679SAndreas Boehler 'uri' => '2.ics', 50*a1a3b679SAndreas Boehler 'calendardata' => 'BEGIN:VCALENDAR 51*a1a3b679SAndreas BoehlerBEGIN:VEVENT 52*a1a3b679SAndreas BoehlerDTSTART:20110101T080000 53*a1a3b679SAndreas BoehlerDURATION:PT1H 54*a1a3b679SAndreas BoehlerEND:VEVENT 55*a1a3b679SAndreas BoehlerEND:VCALENDAR', 56*a1a3b679SAndreas Boehler 'calendarid' => 2, 57*a1a3b679SAndreas Boehler ]] 58*a1a3b679SAndreas Boehler 59*a1a3b679SAndreas Boehler ]; 60*a1a3b679SAndreas Boehler 61*a1a3b679SAndreas Boehler $principalBackend = new DAVACL\PrincipalBackend\Mock(); 62*a1a3b679SAndreas Boehler $this->caldavBackend = new CalDAV\Backend\MockScheduling($calendars, $calendarobjects); 63*a1a3b679SAndreas Boehler 64*a1a3b679SAndreas Boehler $tree = [ 65*a1a3b679SAndreas Boehler new DAVACL\PrincipalCollection($principalBackend), 66*a1a3b679SAndreas Boehler new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend), 67*a1a3b679SAndreas Boehler ]; 68*a1a3b679SAndreas Boehler 69*a1a3b679SAndreas Boehler $this->request = HTTP\Sapi::createFromServerArray([ 70*a1a3b679SAndreas Boehler 'CONTENT_TYPE' => 'text/calendar', 71*a1a3b679SAndreas Boehler ]); 72*a1a3b679SAndreas Boehler $this->response = new HTTP\ResponseMock(); 73*a1a3b679SAndreas Boehler 74*a1a3b679SAndreas Boehler $this->server = new DAV\Server($tree); 75*a1a3b679SAndreas Boehler $this->server->httpRequest = $this->request; 76*a1a3b679SAndreas Boehler $this->server->httpResponse = $this->response; 77*a1a3b679SAndreas Boehler 78*a1a3b679SAndreas Boehler $this->aclPlugin = new DAVACL\Plugin(); 79*a1a3b679SAndreas Boehler $this->server->addPlugin($this->aclPlugin); 80*a1a3b679SAndreas Boehler 81*a1a3b679SAndreas Boehler $authBackend = new DAV\Auth\Backend\Mock(); 82*a1a3b679SAndreas Boehler $authBackend->setPrincipal('principals/user1'); 83*a1a3b679SAndreas Boehler $this->authPlugin = new DAV\Auth\Plugin($authBackend,'SabreDAV'); 84*a1a3b679SAndreas Boehler // Forcing authentication to work. 85*a1a3b679SAndreas Boehler $this->authPlugin->beforeMethod($this->request, $this->response); 86*a1a3b679SAndreas Boehler $this->server->addPlugin($this->authPlugin); 87*a1a3b679SAndreas Boehler 88*a1a3b679SAndreas Boehler // CalDAV plugin 89*a1a3b679SAndreas Boehler $this->plugin = new CalDAV\Plugin(); 90*a1a3b679SAndreas Boehler $this->server->addPlugin($this->plugin); 91*a1a3b679SAndreas Boehler 92*a1a3b679SAndreas Boehler // Scheduling plugin 93*a1a3b679SAndreas Boehler $this->plugin = new Plugin(); 94*a1a3b679SAndreas Boehler $this->server->addPlugin($this->plugin); 95*a1a3b679SAndreas Boehler 96*a1a3b679SAndreas Boehler } 97*a1a3b679SAndreas Boehler 98*a1a3b679SAndreas Boehler function testWrongContentType() { 99*a1a3b679SAndreas Boehler 100*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 101*a1a3b679SAndreas Boehler 'POST', 102*a1a3b679SAndreas Boehler '/calendars/user1/outbox', 103*a1a3b679SAndreas Boehler ['Content-Type' => 'text/plain'] 104*a1a3b679SAndreas Boehler ); 105*a1a3b679SAndreas Boehler 106*a1a3b679SAndreas Boehler $this->assertNull( 107*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse) 108*a1a3b679SAndreas Boehler ); 109*a1a3b679SAndreas Boehler 110*a1a3b679SAndreas Boehler } 111*a1a3b679SAndreas Boehler 112*a1a3b679SAndreas Boehler function testNotFound() { 113*a1a3b679SAndreas Boehler 114*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 115*a1a3b679SAndreas Boehler 'POST', 116*a1a3b679SAndreas Boehler '/calendars/user1/blabla', 117*a1a3b679SAndreas Boehler ['Content-Type' => 'text/calendar'] 118*a1a3b679SAndreas Boehler ); 119*a1a3b679SAndreas Boehler 120*a1a3b679SAndreas Boehler $this->assertNull( 121*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse) 122*a1a3b679SAndreas Boehler ); 123*a1a3b679SAndreas Boehler 124*a1a3b679SAndreas Boehler } 125*a1a3b679SAndreas Boehler 126*a1a3b679SAndreas Boehler function testNotOutbox() { 127*a1a3b679SAndreas Boehler 128*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 129*a1a3b679SAndreas Boehler 'POST', 130*a1a3b679SAndreas Boehler '/calendars/user1/inbox', 131*a1a3b679SAndreas Boehler ['Content-Type' => 'text/calendar'] 132*a1a3b679SAndreas Boehler ); 133*a1a3b679SAndreas Boehler 134*a1a3b679SAndreas Boehler $this->assertNull( 135*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse) 136*a1a3b679SAndreas Boehler ); 137*a1a3b679SAndreas Boehler 138*a1a3b679SAndreas Boehler } 139*a1a3b679SAndreas Boehler 140*a1a3b679SAndreas Boehler /** 141*a1a3b679SAndreas Boehler * @expectedException Sabre\DAV\Exception\BadRequest 142*a1a3b679SAndreas Boehler */ 143*a1a3b679SAndreas Boehler function testNoItipMethod() { 144*a1a3b679SAndreas Boehler 145*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 146*a1a3b679SAndreas Boehler 'POST', 147*a1a3b679SAndreas Boehler '/calendars/user1/outbox', 148*a1a3b679SAndreas Boehler ['Content-Type' => 'text/calendar'] 149*a1a3b679SAndreas Boehler ); 150*a1a3b679SAndreas Boehler 151*a1a3b679SAndreas Boehler $body = <<<ICS 152*a1a3b679SAndreas BoehlerBEGIN:VCALENDAR 153*a1a3b679SAndreas BoehlerBEGIN:VFREEBUSY 154*a1a3b679SAndreas BoehlerEND:VFREEBUSY 155*a1a3b679SAndreas BoehlerEND:VCALENDAR 156*a1a3b679SAndreas BoehlerICS; 157*a1a3b679SAndreas Boehler 158*a1a3b679SAndreas Boehler $this->server->httpRequest->setBody($body); 159*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse); 160*a1a3b679SAndreas Boehler 161*a1a3b679SAndreas Boehler } 162*a1a3b679SAndreas Boehler 163*a1a3b679SAndreas Boehler /** 164*a1a3b679SAndreas Boehler * @expectedException \Sabre\DAV\Exception\NotImplemented 165*a1a3b679SAndreas Boehler */ 166*a1a3b679SAndreas Boehler function testNoVFreeBusy() { 167*a1a3b679SAndreas Boehler 168*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 169*a1a3b679SAndreas Boehler 'POST', 170*a1a3b679SAndreas Boehler '/calendars/user1/outbox', 171*a1a3b679SAndreas Boehler ['Content-Type' => 'text/calendar'] 172*a1a3b679SAndreas Boehler ); 173*a1a3b679SAndreas Boehler 174*a1a3b679SAndreas Boehler $body = <<<ICS 175*a1a3b679SAndreas BoehlerBEGIN:VCALENDAR 176*a1a3b679SAndreas BoehlerMETHOD:REQUEST 177*a1a3b679SAndreas BoehlerBEGIN:VEVENT 178*a1a3b679SAndreas BoehlerEND:VEVENT 179*a1a3b679SAndreas BoehlerEND:VCALENDAR 180*a1a3b679SAndreas BoehlerICS; 181*a1a3b679SAndreas Boehler 182*a1a3b679SAndreas Boehler $this->server->httpRequest->setBody($body); 183*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse); 184*a1a3b679SAndreas Boehler 185*a1a3b679SAndreas Boehler } 186*a1a3b679SAndreas Boehler 187*a1a3b679SAndreas Boehler /** 188*a1a3b679SAndreas Boehler * @expectedException Sabre\DAV\Exception\Forbidden 189*a1a3b679SAndreas Boehler */ 190*a1a3b679SAndreas Boehler function testIncorrectOrganizer() { 191*a1a3b679SAndreas Boehler 192*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 193*a1a3b679SAndreas Boehler 'POST', 194*a1a3b679SAndreas Boehler '/calendars/user1/outbox', 195*a1a3b679SAndreas Boehler ['Content-Type' => 'text/calendar'] 196*a1a3b679SAndreas Boehler ); 197*a1a3b679SAndreas Boehler 198*a1a3b679SAndreas Boehler 199*a1a3b679SAndreas Boehler $body = <<<ICS 200*a1a3b679SAndreas BoehlerBEGIN:VCALENDAR 201*a1a3b679SAndreas BoehlerMETHOD:REQUEST 202*a1a3b679SAndreas BoehlerBEGIN:VFREEBUSY 203*a1a3b679SAndreas BoehlerORGANIZER:mailto:john@wayne.org 204*a1a3b679SAndreas BoehlerEND:VFREEBUSY 205*a1a3b679SAndreas BoehlerEND:VCALENDAR 206*a1a3b679SAndreas BoehlerICS; 207*a1a3b679SAndreas Boehler 208*a1a3b679SAndreas Boehler $this->server->httpRequest->setBody($body); 209*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse); 210*a1a3b679SAndreas Boehler 211*a1a3b679SAndreas Boehler } 212*a1a3b679SAndreas Boehler 213*a1a3b679SAndreas Boehler /** 214*a1a3b679SAndreas Boehler * @expectedException Sabre\DAV\Exception\BadRequest 215*a1a3b679SAndreas Boehler */ 216*a1a3b679SAndreas Boehler function testNoAttendees() { 217*a1a3b679SAndreas Boehler 218*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 219*a1a3b679SAndreas Boehler 'POST', 220*a1a3b679SAndreas Boehler '/calendars/user1/outbox', 221*a1a3b679SAndreas Boehler ['Content-Type' => 'text/calendar'] 222*a1a3b679SAndreas Boehler ); 223*a1a3b679SAndreas Boehler 224*a1a3b679SAndreas Boehler $body = <<<ICS 225*a1a3b679SAndreas BoehlerBEGIN:VCALENDAR 226*a1a3b679SAndreas BoehlerMETHOD:REQUEST 227*a1a3b679SAndreas BoehlerBEGIN:VFREEBUSY 228*a1a3b679SAndreas BoehlerORGANIZER:mailto:user1.sabredav@sabredav.org 229*a1a3b679SAndreas BoehlerEND:VFREEBUSY 230*a1a3b679SAndreas BoehlerEND:VCALENDAR 231*a1a3b679SAndreas BoehlerICS; 232*a1a3b679SAndreas Boehler 233*a1a3b679SAndreas Boehler $this->server->httpRequest->setBody($body); 234*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse); 235*a1a3b679SAndreas Boehler 236*a1a3b679SAndreas Boehler } 237*a1a3b679SAndreas Boehler 238*a1a3b679SAndreas Boehler /** 239*a1a3b679SAndreas Boehler * @expectedException Sabre\DAV\Exception\BadRequest 240*a1a3b679SAndreas Boehler */ 241*a1a3b679SAndreas Boehler function testNoDTStart() { 242*a1a3b679SAndreas Boehler 243*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 244*a1a3b679SAndreas Boehler 'POST', 245*a1a3b679SAndreas Boehler '/calendars/user1/outbox', 246*a1a3b679SAndreas Boehler ['Content-Type' => 'text/calendar'] 247*a1a3b679SAndreas Boehler ); 248*a1a3b679SAndreas Boehler 249*a1a3b679SAndreas Boehler $body = <<<ICS 250*a1a3b679SAndreas BoehlerBEGIN:VCALENDAR 251*a1a3b679SAndreas BoehlerMETHOD:REQUEST 252*a1a3b679SAndreas BoehlerBEGIN:VFREEBUSY 253*a1a3b679SAndreas BoehlerORGANIZER:mailto:user1.sabredav@sabredav.org 254*a1a3b679SAndreas BoehlerATTENDEE:mailto:user2.sabredav@sabredav.org 255*a1a3b679SAndreas BoehlerEND:VFREEBUSY 256*a1a3b679SAndreas BoehlerEND:VCALENDAR 257*a1a3b679SAndreas BoehlerICS; 258*a1a3b679SAndreas Boehler 259*a1a3b679SAndreas Boehler $this->server->httpRequest->setBody($body); 260*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse); 261*a1a3b679SAndreas Boehler 262*a1a3b679SAndreas Boehler } 263*a1a3b679SAndreas Boehler 264*a1a3b679SAndreas Boehler function testSucceed() { 265*a1a3b679SAndreas Boehler 266*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 267*a1a3b679SAndreas Boehler 'POST', 268*a1a3b679SAndreas Boehler '/calendars/user1/outbox', 269*a1a3b679SAndreas Boehler ['Content-Type' => 'text/calendar'] 270*a1a3b679SAndreas Boehler ); 271*a1a3b679SAndreas Boehler 272*a1a3b679SAndreas Boehler $body = <<<ICS 273*a1a3b679SAndreas BoehlerBEGIN:VCALENDAR 274*a1a3b679SAndreas BoehlerMETHOD:REQUEST 275*a1a3b679SAndreas BoehlerBEGIN:VFREEBUSY 276*a1a3b679SAndreas BoehlerORGANIZER:mailto:user1.sabredav@sabredav.org 277*a1a3b679SAndreas BoehlerATTENDEE:mailto:user2.sabredav@sabredav.org 278*a1a3b679SAndreas BoehlerATTENDEE:mailto:user3.sabredav@sabredav.org 279*a1a3b679SAndreas BoehlerDTSTART:20110101T080000Z 280*a1a3b679SAndreas BoehlerDTEND:20110101T180000Z 281*a1a3b679SAndreas BoehlerEND:VFREEBUSY 282*a1a3b679SAndreas BoehlerEND:VCALENDAR 283*a1a3b679SAndreas BoehlerICS; 284*a1a3b679SAndreas Boehler 285*a1a3b679SAndreas Boehler $this->server->httpRequest->setBody($body); 286*a1a3b679SAndreas Boehler 287*a1a3b679SAndreas Boehler // Lazily making the current principal an admin. 288*a1a3b679SAndreas Boehler $this->aclPlugin->adminPrincipals[] = 'principals/user1'; 289*a1a3b679SAndreas Boehler 290*a1a3b679SAndreas Boehler $this->assertFalse( 291*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->response) 292*a1a3b679SAndreas Boehler ); 293*a1a3b679SAndreas Boehler 294*a1a3b679SAndreas Boehler $this->assertEquals(200, $this->response->status); 295*a1a3b679SAndreas Boehler $this->assertEquals(array( 296*a1a3b679SAndreas Boehler 'Content-Type' => ['application/xml'], 297*a1a3b679SAndreas Boehler ), $this->response->getHeaders()); 298*a1a3b679SAndreas Boehler 299*a1a3b679SAndreas Boehler $strings = array( 300*a1a3b679SAndreas Boehler '<d:href>mailto:user2.sabredav@sabredav.org</d:href>', 301*a1a3b679SAndreas Boehler '<d:href>mailto:user3.sabredav@sabredav.org</d:href>', 302*a1a3b679SAndreas Boehler '<cal:request-status>2.0;Success</cal:request-status>', 303*a1a3b679SAndreas Boehler '<cal:request-status>3.7;Could not find principal</cal:request-status>', 304*a1a3b679SAndreas Boehler 'FREEBUSY;FBTYPE=BUSY:20110101T120000Z/20110101T130000Z', 305*a1a3b679SAndreas Boehler ); 306*a1a3b679SAndreas Boehler 307*a1a3b679SAndreas Boehler foreach($strings as $string) { 308*a1a3b679SAndreas Boehler $this->assertTrue( 309*a1a3b679SAndreas Boehler strpos($this->response->body, $string)!==false, 310*a1a3b679SAndreas Boehler 'The response body did not contain: ' . $string .'Full response: ' . $this->response->body 311*a1a3b679SAndreas Boehler ); 312*a1a3b679SAndreas Boehler } 313*a1a3b679SAndreas Boehler 314*a1a3b679SAndreas Boehler $this->assertTrue( 315*a1a3b679SAndreas Boehler strpos($this->response->body, 'FREEBUSY;FBTYPE=BUSY:20110101T080000Z/20110101T090000Z')==false, 316*a1a3b679SAndreas Boehler 'The response body did contain free busy info from a transparent calendar.' 317*a1a3b679SAndreas Boehler ); 318*a1a3b679SAndreas Boehler 319*a1a3b679SAndreas Boehler } 320*a1a3b679SAndreas Boehler 321*a1a3b679SAndreas Boehler /** 322*a1a3b679SAndreas Boehler * Testing if the freebusy request still works, even if there are no 323*a1a3b679SAndreas Boehler * calendars in the target users' account. 324*a1a3b679SAndreas Boehler */ 325*a1a3b679SAndreas Boehler function testSucceedNoCalendars() { 326*a1a3b679SAndreas Boehler 327*a1a3b679SAndreas Boehler // Deleting calendars 328*a1a3b679SAndreas Boehler $this->caldavBackend->deleteCalendar(1); 329*a1a3b679SAndreas Boehler $this->caldavBackend->deleteCalendar(2); 330*a1a3b679SAndreas Boehler 331*a1a3b679SAndreas Boehler $this->server->httpRequest = new HTTP\Request( 332*a1a3b679SAndreas Boehler 'POST', 333*a1a3b679SAndreas Boehler '/calendars/user1/outbox', 334*a1a3b679SAndreas Boehler ['Content-Type' => 'text/calendar'] 335*a1a3b679SAndreas Boehler ); 336*a1a3b679SAndreas Boehler 337*a1a3b679SAndreas Boehler $body = <<<ICS 338*a1a3b679SAndreas BoehlerBEGIN:VCALENDAR 339*a1a3b679SAndreas BoehlerMETHOD:REQUEST 340*a1a3b679SAndreas BoehlerBEGIN:VFREEBUSY 341*a1a3b679SAndreas BoehlerORGANIZER:mailto:user1.sabredav@sabredav.org 342*a1a3b679SAndreas BoehlerATTENDEE:mailto:user2.sabredav@sabredav.org 343*a1a3b679SAndreas BoehlerDTSTART:20110101T080000Z 344*a1a3b679SAndreas BoehlerDTEND:20110101T180000Z 345*a1a3b679SAndreas BoehlerEND:VFREEBUSY 346*a1a3b679SAndreas BoehlerEND:VCALENDAR 347*a1a3b679SAndreas BoehlerICS; 348*a1a3b679SAndreas Boehler 349*a1a3b679SAndreas Boehler $this->server->httpRequest->setBody($body); 350*a1a3b679SAndreas Boehler 351*a1a3b679SAndreas Boehler // Lazily making the current principal an admin. 352*a1a3b679SAndreas Boehler $this->aclPlugin->adminPrincipals[] = 'principals/user1'; 353*a1a3b679SAndreas Boehler 354*a1a3b679SAndreas Boehler $this->assertFalse( 355*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->response) 356*a1a3b679SAndreas Boehler ); 357*a1a3b679SAndreas Boehler 358*a1a3b679SAndreas Boehler $this->assertEquals(200, $this->response->status); 359*a1a3b679SAndreas Boehler $this->assertEquals(array( 360*a1a3b679SAndreas Boehler 'Content-Type' => ['application/xml'], 361*a1a3b679SAndreas Boehler ), $this->response->getHeaders()); 362*a1a3b679SAndreas Boehler 363*a1a3b679SAndreas Boehler $strings = array( 364*a1a3b679SAndreas Boehler '<d:href>mailto:user2.sabredav@sabredav.org</d:href>', 365*a1a3b679SAndreas Boehler '<cal:request-status>2.0;Success</cal:request-status>', 366*a1a3b679SAndreas Boehler ); 367*a1a3b679SAndreas Boehler 368*a1a3b679SAndreas Boehler foreach($strings as $string) { 369*a1a3b679SAndreas Boehler $this->assertTrue( 370*a1a3b679SAndreas Boehler strpos($this->response->body, $string)!==false, 371*a1a3b679SAndreas Boehler 'The response body did not contain: ' . $string .'Full response: ' . $this->response->body 372*a1a3b679SAndreas Boehler ); 373*a1a3b679SAndreas Boehler } 374*a1a3b679SAndreas Boehler 375*a1a3b679SAndreas Boehler } 376*a1a3b679SAndreas Boehler 377*a1a3b679SAndreas Boehler /* 378*a1a3b679SAndreas Boehler function testNoPrivilege() { 379*a1a3b679SAndreas Boehler 380*a1a3b679SAndreas Boehler $this->markTestIncomplete('Currently there\'s no "no privilege" situation'); 381*a1a3b679SAndreas Boehler 382*a1a3b679SAndreas Boehler $this->server->httpRequest = HTTP\Sapi::createFromServerArray(array( 383*a1a3b679SAndreas Boehler 'CONTENT_TYPE' => 'text/calendar', 384*a1a3b679SAndreas Boehler 'REQUEST_METHOD' => 'POST', 385*a1a3b679SAndreas Boehler 'REQUEST_URI' => '/calendars/user1/outbox', 386*a1a3b679SAndreas Boehler )); 387*a1a3b679SAndreas Boehler 388*a1a3b679SAndreas Boehler $body = <<<ICS 389*a1a3b679SAndreas BoehlerBEGIN:VCALENDAR 390*a1a3b679SAndreas BoehlerMETHOD:REQUEST 391*a1a3b679SAndreas BoehlerBEGIN:VFREEBUSY 392*a1a3b679SAndreas BoehlerORGANIZER:mailto:user1.sabredav@sabredav.org 393*a1a3b679SAndreas BoehlerATTENDEE:mailto:user2.sabredav@sabredav.org 394*a1a3b679SAndreas BoehlerDTSTART:20110101T080000Z 395*a1a3b679SAndreas BoehlerDTEND:20110101T180000Z 396*a1a3b679SAndreas BoehlerEND:VFREEBUSY 397*a1a3b679SAndreas BoehlerEND:VCALENDAR 398*a1a3b679SAndreas BoehlerICS; 399*a1a3b679SAndreas Boehler 400*a1a3b679SAndreas Boehler $this->server->httpRequest->setBody($body); 401*a1a3b679SAndreas Boehler 402*a1a3b679SAndreas Boehler $this->assertFalse( 403*a1a3b679SAndreas Boehler $this->plugin->httpPost($this->server->httpRequest, $this->response) 404*a1a3b679SAndreas Boehler ); 405*a1a3b679SAndreas Boehler 406*a1a3b679SAndreas Boehler $this->assertEquals(200, $this->response->status); 407*a1a3b679SAndreas Boehler $this->assertEquals([ 408*a1a3b679SAndreas Boehler 'Content-Type' => 'application/xml', 409*a1a3b679SAndreas Boehler ], $this->response->getHeaders()); 410*a1a3b679SAndreas Boehler 411*a1a3b679SAndreas Boehler $strings = [ 412*a1a3b679SAndreas Boehler '<d:href>mailto:user2.sabredav@sabredav.org</d:href>', 413*a1a3b679SAndreas Boehler '<cal:request-status>3.7;No calendar-home-set property found</cal:request-status>', 414*a1a3b679SAndreas Boehler ]; 415*a1a3b679SAndreas Boehler 416*a1a3b679SAndreas Boehler foreach($strings as $string) { 417*a1a3b679SAndreas Boehler $this->assertTrue( 418*a1a3b679SAndreas Boehler strpos($this->response->body, $string)!==false, 419*a1a3b679SAndreas Boehler 'The response body did not contain: ' . $string .'Full response: ' . $this->response->body 420*a1a3b679SAndreas Boehler ); 421*a1a3b679SAndreas Boehler } 422*a1a3b679SAndreas Boehler 423*a1a3b679SAndreas Boehler 424*a1a3b679SAndreas Boehler }*/ 425*a1a3b679SAndreas Boehler 426*a1a3b679SAndreas Boehler} 427