12 use \Sabre\VObject\PHPUnitAssertions;
17 $recur =
$vcal->add(
'RRULE',
'FREQ=Daily');
19 $this->assertInstanceOf(
'Sabre\VObject\Property\ICalendar\Recur', $recur);
21 $this->assertEquals([
'FREQ' =>
'DAILY'], $recur->getParts());
22 $recur->setParts([
'freq' =>
'MONTHLY']);
24 $this->assertEquals([
'FREQ' =>
'MONTHLY'], $recur->getParts());
34 $recur =
$vcal->add(
'RRULE',
'FREQ=Daily');
41 $recur =
$vcal->add(
'RRULE',
'FREQ=Daily');
42 $recur->setValue([
'COUNT' => 3]);
43 $this->assertEquals($recur->getParts()[
'COUNT'], 3);
49 UID:908d53c0-e1a3-4883-b69f-530954d6bd62 51 DTSTART;TZID=Europe/Berlin:20160301T150000 52 DTEND;TZID=Europe/Berlin:20160301T170000 54 RRULE:FREQ=DAILY;COUNT=3 55 ORGANIZER;CN=robert pipo:mailto:robert@example.org 61 $rrule =
$vcal->VEVENT->RRULE;
62 $count = $rrule->getJsonValue()[0][
'count'];
63 $this->assertTrue(is_int($count));
64 $this->assertEquals(3, $count);
70 $recur =
$vcal->add(
'RRULE', [
'FREQ' =>
'DAILY',
'BYDAY' =>
'mo,tu',
'BYMONTH' => [0, 1]]);
74 'BYDAY' => [
'MO',
'TU'],
76 ], $recur->getParts());
83 UID:908d53c0-e1a3-4883-b69f-530954d6bd62 85 DTSTART;TZID=Europe/Berlin:20160301T150000 86 DTEND;TZID=Europe/Berlin:20160301T170000 88 RRULE:FREQ=DAILY;UNTIL=20160305T230000Z 89 ORGANIZER;CN=robert pipo:mailto:robert@example.org 95 $rrule =
$vcal->VEVENT->RRULE;
96 $untilJsonString = $rrule->getJsonValue()[0][
'until'];
97 $this->assertEquals(
'2016-03-05T23:00:00Z', $untilJsonString);
107 UID:908d53c0-e1a3-4883-b69f-530954d6bd62 109 DTSTART;TZID=Europe/Berlin:20160301T150000 110 DTEND;TZID=Europe/Berlin:20160301T170000 112 RRULE:FREQ=DAILY;BYMONTH=;UNTIL=20160305T230000Z 113 ORGANIZER;CN=robert pipo:mailto:robert@example.org 114 DTSTAMP:20160312T183800Z 129 $expected =
'BEGIN:VCALENDAR 133 UID:908d53c0-e1a3-4883-b69f-530954d6bd62 135 DTSTART;TZID=Europe/Berlin:20160301T150000 136 DTEND;TZID=Europe/Berlin:20160301T170000 138 RRULE:FREQ=DAILY;UNTIL=20160305T230000Z 139 ORGANIZER;CN=robert pipo:mailto:robert@example.org 140 DTSTAMP:20160312T183800Z 145 $this->assertVObjectEqualsVObject(
158 UID:908d53c0-e1a3-4883-b69f-530954d6bd62 160 DTSTART;TZID=Europe/Berlin:20160301T150000 161 DTEND;TZID=Europe/Berlin:20160301T170000 163 RRULE:UNTIL=20160305T230000Z 164 ORGANIZER;CN=robert pipo:mailto:robert@example.org 165 DTSTAMP:20160312T183800Z 180 $expected =
'BEGIN:VCALENDAR 184 UID:908d53c0-e1a3-4883-b69f-530954d6bd62 186 DTSTART;TZID=Europe/Berlin:20160301T150000 187 DTEND;TZID=Europe/Berlin:20160301T170000 189 ORGANIZER;CN=robert pipo:mailto:robert@example.org 190 DTSTAMP:20160312T183800Z 195 $this->assertVObjectEqualsVObject(
205 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=0');
208 $this->assertCount(1,
$result);
209 $this->assertEquals(
'BYMONTH in RRULE must have value(s) between 1 and 12!',
$result[0][
'message']);
210 $this->assertEquals(1,
$result[0][
'level']);
211 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24', $property->getValue());
218 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=0');
219 $result = $property->validate();
221 $this->assertCount(1,
$result);
222 $this->assertEquals(
'BYMONTH in RRULE must have value(s) between 1 and 12!',
$result[0][
'message']);
223 $this->assertEquals(3,
$result[0][
'level']);
224 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=0', $property->getValue());
231 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=bla');
234 $this->assertCount(1,
$result);
235 $this->assertEquals(
'BYMONTH in RRULE must have value(s) between 1 and 12!',
$result[0][
'message']);
236 $this->assertEquals(1,
$result[0][
'level']);
237 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24', $property->getValue());
244 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=bla');
245 $result = $property->validate();
247 $this->assertCount(1,
$result);
248 $this->assertEquals(
'BYMONTH in RRULE must have value(s) between 1 and 12!',
$result[0][
'message']);
249 $this->assertEquals(3,
$result[0][
'level']);
251 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=BLA', $property->getValue());
258 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=14');
261 $this->assertCount(1,
$result);
262 $this->assertEquals(
'BYMONTH in RRULE must have value(s) between 1 and 12!',
$result[0][
'message']);
263 $this->assertEquals(1,
$result[0][
'level']);
264 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24', $property->getValue());
271 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=0,1,2,3,4,14');
274 $this->assertCount(2,
$result);
275 $this->assertEquals(
'BYMONTH in RRULE must have value(s) between 1 and 12!',
$result[0][
'message']);
276 $this->assertEquals(1,
$result[0][
'level']);
277 $this->assertEquals(
'BYMONTH in RRULE must have value(s) between 1 and 12!',
$result[1][
'message']);
278 $this->assertEquals(1,
$result[1][
'level']);
279 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=1,2,3,4', $property->getValue());
286 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=bla,3,foo');
289 $this->assertCount(2,
$result);
290 $this->assertEquals(
'BYMONTH in RRULE must have value(s) between 1 and 12!',
$result[0][
'message']);
291 $this->assertEquals(1,
$result[0][
'level']);
292 $this->assertEquals(
'BYMONTH in RRULE must have value(s) between 1 and 12!',
$result[1][
'message']);
293 $this->assertEquals(1,
$result[1][
'level']);
294 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=3', $property->getValue());
301 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=2,3');
302 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYMONTHDAY=24;BYMONTH=2,3', $property->getValue());
312 $property =
$calendar->createProperty(
'RRULE',
'FREQ=DAILY;BYHOUR=10;BYMINUTE=30;BYSECOND=0;UNTIL=20150616T153000Z');
317 $this->assertEquals(
'FREQ=DAILY;BYHOUR=10;BYMINUTE=30;BYSECOND=0;UNTIL=20150616T153000Z', $property->getValue());
324 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYWEEKNO=11');
327 $this->assertCount(0,
$result);
328 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYWEEKNO=11', $property->getValue());
335 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYWEEKNO=55;BYDAY=WE');
338 $this->assertCount(1,
$result);
339 $this->assertEquals(
'BYWEEKNO in RRULE must have value(s) from -53 to -1, or 1 to 53!',
$result[0][
'message']);
340 $this->assertEquals(1,
$result[0][
'level']);
341 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYDAY=WE', $property->getValue());
348 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYWEEKNO=55,2,-80;BYDAY=WE');
351 $this->assertCount(2,
$result);
352 $this->assertEquals(
'BYWEEKNO in RRULE must have value(s) from -53 to -1, or 1 to 53!',
$result[0][
'message']);
353 $this->assertEquals(1,
$result[0][
'level']);
354 $this->assertEquals(
'BYWEEKNO in RRULE must have value(s) from -53 to -1, or 1 to 53!',
$result[1][
'message']);
355 $this->assertEquals(1,
$result[1][
'level']);
356 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYWEEKNO=2;BYDAY=WE', $property->getValue());
363 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYWEEKNO=55,-80;BYDAY=WE');
366 $this->assertCount(2,
$result);
367 $this->assertEquals(
'BYWEEKNO in RRULE must have value(s) from -53 to -1, or 1 to 53!',
$result[0][
'message']);
368 $this->assertEquals(1,
$result[0][
'level']);
369 $this->assertEquals(
'BYWEEKNO in RRULE must have value(s) from -53 to -1, or 1 to 53!',
$result[1][
'message']);
370 $this->assertEquals(1,
$result[1][
'level']);
371 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYDAY=WE', $property->getValue());
378 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYWEEKNO=55;BYDAY=WE');
379 $result = $property->validate();
381 $this->assertCount(1,
$result);
382 $this->assertEquals(
'BYWEEKNO in RRULE must have value(s) from -53 to -1, or 1 to 53!',
$result[0][
'message']);
383 $this->assertEquals(3,
$result[0][
'level']);
384 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYWEEKNO=55;BYDAY=WE', $property->getValue());
391 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYYEARDAY=119');
394 $this->assertCount(0,
$result);
395 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYYEARDAY=119', $property->getValue());
402 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYYEARDAY=367;BYDAY=WE');
405 $this->assertCount(1,
$result);
406 $this->assertEquals(
'BYYEARDAY in RRULE must have value(s) from -366 to -1, or 1 to 366!',
$result[0][
'message']);
407 $this->assertEquals(1,
$result[0][
'level']);
408 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYDAY=WE', $property->getValue());
415 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYYEARDAY=380,2,-390;BYDAY=WE');
418 $this->assertCount(2,
$result);
419 $this->assertEquals(
'BYYEARDAY in RRULE must have value(s) from -366 to -1, or 1 to 366!',
$result[0][
'message']);
420 $this->assertEquals(1,
$result[0][
'level']);
421 $this->assertEquals(
'BYYEARDAY in RRULE must have value(s) from -366 to -1, or 1 to 366!',
$result[1][
'message']);
422 $this->assertEquals(1,
$result[1][
'level']);
423 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYYEARDAY=2;BYDAY=WE', $property->getValue());
430 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYYEARDAY=455,-480;BYDAY=WE');
433 $this->assertCount(2,
$result);
434 $this->assertEquals(
'BYYEARDAY in RRULE must have value(s) from -366 to -1, or 1 to 366!',
$result[0][
'message']);
435 $this->assertEquals(1,
$result[0][
'level']);
436 $this->assertEquals(
'BYYEARDAY in RRULE must have value(s) from -366 to -1, or 1 to 366!',
$result[1][
'message']);
437 $this->assertEquals(1,
$result[1][
'level']);
438 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYDAY=WE', $property->getValue());
445 $property =
$calendar->createProperty(
'RRULE',
'FREQ=YEARLY;COUNT=6;BYYEARDAY=380;BYDAY=WE');
446 $result = $property->validate();
448 $this->assertCount(1,
$result);
449 $this->assertEquals(
'BYYEARDAY in RRULE must have value(s) from -366 to -1, or 1 to 366!',
$result[0][
'message']);
450 $this->assertEquals(3,
$result[0][
'level']);
451 $this->assertEquals(
'FREQ=YEARLY;COUNT=6;BYYEARDAY=380;BYDAY=WE', $property->getValue());
testValidateInvalidByWeekNoWithRepair()
testValidateInvalidByYearDayWithoutRepair()
testValidateInvalidByMonthRruleWithRepair()
testValidateAllInvalidByYearDayWithRepair()
testValidateInvalidByMonthRruleWithRepair2()
testValidateRruleBySecondZero()
test for issue #336
testValidateValidByWeekNoWithRepair()
testValidateMultipleInvalidByYearDayWithRepair()
testValidateOneOfManyInvalidByMonthRruleWithRepair()
testValidateValidByMonthRrule()
testValidateStripEmpties()
testValidateInvalidByMonthRruleValue14WithRepair()
testValidateInvalidByWeekNoWithoutRepair()
testValidateValidByYearDayWithRepair()
testValidateInvalidByYearDayWithRepair()
testValidateMultipleInvalidByWeekNoWithRepair()
testValidateAllInvalidByWeekNoWithRepair()
testValidateInvalidByMonthRruleWithoutRepair()
const REPAIR
The following constants are used by the validate() method.
testValidateInvalidByMonthRruleMultipleWithRepair()
count()
Returns the number of elements.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
testValidateInvalidByMonthRruleWithoutRepair2()
testValidateStripNoFreq()