Skip to content

Commit

Permalink
Test calendar object with various characters
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed May 17, 2017
1 parent ec7c026 commit ae0d6fa
Showing 1 changed file with 101 additions and 26 deletions.
127 changes: 101 additions & 26 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,8 @@ public function testCalendarSharing($userCanRead, $userCanWrite, $groupCanRead,
$this->assertEquals(0, count($books));
}

public function testCalendarObjectsOperations() {

$calendarId = $this->createTestCalendar();

// create a card
$uri = $this->getUniqueID('calobj');
$calData = <<<'EOD'
public function providesCalendarData() {
$initialCalendar = <<<'EOD'
BEGIN:VCALENDAR
VERSION:2.0
PRODID:ownCloud Calendar
Expand All @@ -177,7 +172,102 @@ public function testCalendarObjectsOperations() {
END:VCALENDAR
EOD;

$this->backend->createCalendarObject($calendarId, $uri, $calData);
$updatedCalendar = <<<'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
END:VEVENT
END:VCALENDAR
EOD;

$initialCalendar2 = <<< 'EOD'
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Sabre//Sabre VObject 3.5.0//EN
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VTIMEZONE
TZID:Europe/Warsaw
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20170320T131655Z
LAST-MODIFIED:20170320T135019Z
DTSTAMP:20170320T135019Z
UID:7e908a6d-4c4e-48d7-bd62-59ab80fbf1a3
SUMMARY:TEST Z pg_escape_bytea
ORGANIZER;RSVP=TRUE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:k.klimczak@gromar.e
u
ATTENDEE;RSVP=TRUE;CN=Zuzanna Leszek;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICI
PANT:mailto:z.leszek@gromar.eu
ATTENDEE;RSVP=TRUE;CN=Marcin Pisarski;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTIC
IPANT:mailto:m.pisarski@gromar.eu
ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:klimcz
ak.k@gmail.com
ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:k_klim
czak@tlen.pl
DTSTART;TZID=Europe/Warsaw:20170325T150000
DTEND;TZID=Europe/Warsaw:20170325T160000
TRANSP:OPAQUE
DESCRIPTION:Magiczna treść uzyskana za pomocą magicznego proszku.\n\nę
żźćńłóÓŻŹĆŁĘ€śśśŚŚ\n \,\,))))))))\;\,\n
__))))))))))))))\,\n \\|/ -\\(((((''''((((((((.\n -*-==///
///(('' . `))))))\,\n /|\\ ))| o \;-. '(((((
\,(\,\n ( `| / ) \;))))'
\,_))^\;(~\n | | | \,))((((_ _____-
-----~~~-. %\,\;(\;(>'\;'~\n o_)\; \; )))(((` ~---
~ `:: \\ %%~~)(v\;(`('~\n \; ''''````
`: `:::|\\\,__\,%% )\;`'\; ~\n | _
) / `:|`----' `-'\n ______/\\/~ |
/ /\n /~\;\;.____/\;\;' / ___--\
,-( `\;\;\;/\n / // _\;______\;'------~~~~~ /\;\;/\\ /\n
// | | / \; \\\;\;\,\\\n (<_ | \;
/'\,/-----' _>\n \\_| ||_
//~\;~~~~~~~~~\n `\\_| (\,~~ -Tua Xiong\n
\\~\\\n
~~\n\n
SEQUENCE:1
X-MOZ-GENERATION:1
END:VEVENT
END:VCALENDAR
EOD;

return[
[$initialCalendar, $updatedCalendar],
[$initialCalendar2, $initialCalendar2],
];
}
/**
* @dataProvider providesCalendarData
*/
public function testCalendarObjectsOperations($initialCalendar, $updatedCalendar) {

$calendarId = $this->createTestCalendar();

// create a card
$uri = $this->getUniqueID('calobj');
$this->backend->createCalendarObject($calendarId, $uri, $initialCalendar);

// get all the cards
$calendarObjects = $this->backend->getCalendarObjects($calendarId);
Expand All @@ -194,27 +284,12 @@ public function testCalendarObjectsOperations() {
$this->assertArrayHasKey('etag', $calendarObject);
$this->assertArrayHasKey('size', $calendarObject);
$this->assertArrayHasKey('classification', $calendarObject);
$this->assertEquals($calData, $calendarObject['calendardata']);
$this->assertEquals($initialCalendar, $calendarObject['calendardata']);

// update the card
$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
END:VEVENT
END:VCALENDAR
EOD;
$this->backend->updateCalendarObject($calendarId, $uri, $calData);
$this->backend->updateCalendarObject($calendarId, $uri, $updatedCalendar);
$calendarObject = $this->backend->getCalendarObject($calendarId, $uri);
$this->assertEquals($calData, $calendarObject['calendardata']);
$this->assertEquals($updatedCalendar, $calendarObject['calendardata']);

// delete the card
$this->backend->deleteCalendarObject($calendarId, $uri);
Expand Down

0 comments on commit ae0d6fa

Please sign in to comment.