Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit arbitrary quantity of lines to be fed into Recurrence Tests #247

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 57 additions & 42 deletions tests/RecurrencesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public function testYearlyFullDayTimeZoneBerlin()
);
$this->assertVEVENT(
'Europe/Berlin',
'DTSTART;VALUE=DATE:20000301',
'DTEND;VALUE=DATE:20000302',
'RRULE:FREQ=YEARLY;WKST=SU;COUNT=3',
array(
'DTSTART;VALUE=DATE:20000301',
'DTEND;VALUE=DATE:20000302',
'RRULE:FREQ=YEARLY;WKST=SU;COUNT=3',
),
3,
$checks
);
Expand All @@ -48,9 +50,11 @@ public function testMonthlyFullDayTimeZoneBerlin()
);
$this->assertVEVENT(
'Europe/Berlin',
'DTSTART;VALUE=DATE:20000301',
'DTEND;VALUE=DATE:20000302',
'RRULE:FREQ=MONTHLY;BYMONTHDAY=1;WKST=SU;COUNT=3',
array(
'DTSTART;VALUE=DATE:20000301',
'DTEND;VALUE=DATE:20000302',
'RRULE:FREQ=MONTHLY;BYMONTHDAY=1;WKST=SU;COUNT=3',
),
3,
$checks
);
Expand All @@ -65,9 +69,11 @@ public function testMonthlyFullDayTimeZoneBerlinSummerTime()
);
$this->assertVEVENT(
'Europe/Berlin',
'DTSTART;VALUE=DATE:20180701',
'DTEND;VALUE=DATE:20180702',
'RRULE:FREQ=MONTHLY;BYMONTHDAY=1;WKST=SU;COUNT=3',
array(
'DTSTART;VALUE=DATE:20180701',
'DTEND;VALUE=DATE:20180702',
'RRULE:FREQ=MONTHLY;BYMONTHDAY=1;WKST=SU;COUNT=3',
),
3,
$checks
);
Expand Down Expand Up @@ -118,9 +124,11 @@ public function testWeeklyFullDayTimeZoneBerlin()
);
$this->assertVEVENT(
'Europe/Berlin',
'DTSTART;VALUE=DATE:20000301',
'DTEND;VALUE=DATE:20000302',
'RRULE:FREQ=WEEKLY;WKST=SU;COUNT=6',
array(
'DTSTART;VALUE=DATE:20000301',
'DTEND;VALUE=DATE:20000302',
'RRULE:FREQ=WEEKLY;WKST=SU;COUNT=6',
),
6,
$checks
);
Expand All @@ -135,9 +143,11 @@ public function testDailyFullDayTimeZoneBerlin()
);
$this->assertVEVENT(
'Europe/Berlin',
'DTSTART;VALUE=DATE:20000301',
'DTEND;VALUE=DATE:20000302',
'RRULE:FREQ=DAILY;WKST=SU;COUNT=31',
array(
'DTSTART;VALUE=DATE:20000301',
'DTEND;VALUE=DATE:20000302',
'RRULE:FREQ=DAILY;WKST=SU;COUNT=31',
),
31,
$checks
);
Expand All @@ -155,9 +165,11 @@ public function testWeeklyFullDayTimeZoneBerlinLocal()
);
$this->assertVEVENT(
'Europe/Berlin',
'DTSTART;TZID=Europe/Berlin:20000301T000000',
'DTEND;TZID=Europe/Berlin:20000302T000000',
'RRULE:FREQ=WEEKLY;WKST=SU;COUNT=6',
array(
'DTSTART;TZID=Europe/Berlin:20000301T000000',
'DTEND;TZID=Europe/Berlin:20000302T000000',
'RRULE:FREQ=WEEKLY;WKST=SU;COUNT=6',
),
6,
$checks
);
Expand All @@ -172,9 +184,10 @@ public function testRFCDaily10NewYork()
);
$this->assertVEVENT(
'Europe/Berlin',
'DTSTART;TZID=America/New_York:19970902T090000',
'',
'RRULE:FREQ=DAILY;COUNT=10',
array(
'DTSTART;TZID=America/New_York:19970902T090000',
'RRULE:FREQ=DAILY;COUNT=10',
),
10,
$checks
);
Expand All @@ -189,9 +202,10 @@ public function testRFCDaily10Berlin()
);
$this->assertVEVENT(
'Europe/Berlin',
'DTSTART;TZID=Europe/Berlin:19970902T090000',
'',
'RRULE:FREQ=DAILY;COUNT=10',
array(
'DTSTART;TZID=Europe/Berlin:19970902T090000',
'RRULE:FREQ=DAILY;COUNT=10',
),
10,
$checks
);
Expand All @@ -206,21 +220,22 @@ public function testRFCDaily10BerlinFromNewYork()
);
$this->assertVEVENT(
'America/New_York',
'DTSTART;TZID=Europe/Berlin:19970902T090000',
'',
'RRULE:FREQ=DAILY;COUNT=10',
array(
'DTSTART;TZID=Europe/Berlin:19970902T090000',
'RRULE:FREQ=DAILY;COUNT=10',
),
10,
$checks
);
}

public function assertVEVENT($defaultTimezone, $dtstart, $dtend, $rrule, $count, $checks)
public function assertVEVENT($defaultTimezone, $veventParts, $count, $checks)
{
$options = $this->getOptions($defaultTimezone);

$testIcal = implode(PHP_EOL, $this->getIcalHeader());
$testIcal .= PHP_EOL;
$testIcal .= implode(PHP_EOL, $this->formatIcalEvent($dtstart, $dtend, $rrule));
$testIcal .= implode(PHP_EOL, $this->formatIcalEvent($veventParts));
$testIcal .= PHP_EOL;
$testIcal .= implode(PHP_EOL, $this->getIcalFooter());

Expand Down Expand Up @@ -280,20 +295,20 @@ public function getOptions($defaultTimezone)
return $options;
}

public function formatIcalEvent($dtstart, $dtend, $rrule)
public function formatIcalEvent($veventParts)
{
return array(
'BEGIN:VEVENT',
'CREATED:20090213T195947Z',
'UID:M2CD-1-1-5FB000FB-BBE4-4F3F-9E7E-217F1FF97209',
$rrule,
$dtstart,
$dtend,
'SUMMARY:test',
'LAST-MODIFIED:20110429T222101Z',
'DTSTAMP:20170630T105724Z',
'SEQUENCE:0',
'END:VEVENT',
return array_merge(
array(
'BEGIN:VEVENT',
'CREATED:' . gmdate('Ymd\THis\Z'),
'UID:M2CD-1-1-5FB000FB-BBE4-4F3F-9E7E-217F1FF97209',
),
$veventParts,
array(
'SUMMARY:test',
'LAST-MODIFIED:' . gmdate('Ymd\THis\Z', filemtime(__FILE__)),
'END:VEVENT',
)
);
}

Expand Down