示例#1
0
    public function testMultiCalendarObjects()
    {
        $calendarId = $this->createTestCalendar();
        // create an event
        $calData = <<<'EOD'
BEGIN:VCALENDAR
VERSION:2.0
PRODID:ownCloud Calendar
BEGIN:VEVENT
CREATED;VALUE=DATE-TIME:20130910T125139Z
UID:47d15e3ec8
LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z
DTSTAMP;VALUE=DATE-TIME:20130910T125139Z
SUMMARY:Test Event
DTSTART;VALUE=DATE-TIME:20130912T130000Z
DTEND;VALUE=DATE-TIME:20130912T140000Z
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
EOD;
        $uri0 = $this->getUniqueID('card');
        $this->backend->createCalendarObject($calendarId, $uri0, $calData);
        $uri1 = $this->getUniqueID('card');
        $this->backend->createCalendarObject($calendarId, $uri1, $calData);
        $uri2 = $this->getUniqueID('card');
        $this->backend->createCalendarObject($calendarId, $uri2, $calData);
        // get all the cards
        $calendarObjects = $this->backend->getCalendarObjects($calendarId);
        $this->assertEquals(3, count($calendarObjects));
        // get the cards
        $calendarObjects = $this->backend->getMultipleCalendarObjects($calendarId, [$uri1, $uri2]);
        $this->assertEquals(2, count($calendarObjects));
        foreach ($calendarObjects as $card) {
            $this->assertArrayHasKey('id', $card);
            $this->assertArrayHasKey('uri', $card);
            $this->assertArrayHasKey('lastmodified', $card);
            $this->assertArrayHasKey('etag', $card);
            $this->assertArrayHasKey('size', $card);
            $this->assertEquals($calData, $card['calendardata']);
        }
        // delete the card
        $this->backend->deleteCalendarObject($calendarId, $uri0);
        $this->backend->deleteCalendarObject($calendarId, $uri1);
        $this->backend->deleteCalendarObject($calendarId, $uri2);
        $calendarObjects = $this->backend->getCalendarObjects($calendarId);
        $this->assertEquals(0, count($calendarObjects));
    }