function testMkCalendarEmptyBodySucceed() { $request = new HTTP\Request('MKCALENDAR', '/calendars/user1/NEWCALENDAR'); $request->setBody(''); $this->server->httpRequest = $request; $this->server->exec(); $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) { if ($calendar['uri'] === 'NEWCALENDAR') { $newCalendar = $calendar; break; } } $this->assertInternalType('array', $newCalendar); $keys = ['uri' => 'NEWCALENDAR', 'id' => null, '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null]; foreach ($keys as $key => $value) { $this->assertArrayHasKey($key, $newCalendar); if (is_null($value)) { continue; } $this->assertEquals($value, $newCalendar[$key]); } $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet); $this->assertEquals(['VEVENT', 'VTODO'], $newCalendar[$sccs]->getValue()); }
/** * @depends testCreateCalendarAndFetch */ 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!')); $backend->deleteCalendar($returnedId); $calendars = $backend->getCalendarsForUser('principals/user2'); $this->assertEquals(array(), $calendars); }
/** * @depends testUpdateInvites */ function testDeleteSharedCalendar() { $backend = new PDO($this->pdo); // creating a new calendar $backend->createCalendar('principals/user1', 'somerandomid', []); $calendar = $backend->getCalendarsForUser('principals/user1')[0]; $ownerSharee = new Sharee(['href' => 'principals/user1', 'principal' => 'principals/user1', 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED]); // Add a new invite $backend->updateInvites($calendar['id'], [new Sharee(['href' => 'mailto:user@example.org', 'principal' => 'principals/user2', 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, 'properties' => ['{DAV:}displayname' => 'User 2']])]); $expectedCalendar = ['id' => [1, 2], 'principaluri' => 'principals/user2', '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/1', '{http://sabredav.org/ns}sync-token' => '1', 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'read-only' => true, 'share-resource-uri' => '/ns/share/1']; $calendars = $backend->getCalendarsForUser('principals/user2'); foreach ($expectedCalendar as $k => $v) { $this->assertEquals($v, $calendars[0][$k], "Key " . $k . " in calendars array did not have the expected value."); } // Removing the shared calendar. $backend->deleteCalendar($calendars[0]['id']); $this->assertEquals([], $backend->getCalendarsForUser('principals/user2')); $result = $backend->getInvites($calendar['id']); $expected = [new Sharee(['href' => 'principals/user1', 'principal' => 'principals/user1', 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED])]; $this->assertEquals($expected, $result); }