6use PHPUnit\Framework\TestCase;
27 $valarm1 =
$calendar->createComponent(
'VALARM');
29 $calendar->createProperty(
'TRIGGER',
'20120312T130000Z', [
'VALUE' =>
'DATE-TIME'])
32 $tests[] = [$valarm1,
new DateTime(
'2012-03-01 01:00:00'),
new DateTime(
'2012-04-01 01:00:00'),
true];
33 $tests[] = [$valarm1,
new DateTime(
'2012-03-01 01:00:00'),
new DateTime(
'2012-03-10 01:00:00'),
false];
36 $valarm2 =
$calendar->createComponent(
'VALARM');
38 $calendar->createProperty(
'TRIGGER',
'-P1D', [
'VALUE' =>
'DURATION'])
41 $vevent2 =
$calendar->createComponent(
'VEVENT');
42 $vevent2->DTSTART =
'20120313T130000Z';
43 $vevent2->add($valarm2);
45 $tests[] = [$valarm2,
new DateTime(
'2012-03-01 01:00:00'),
new DateTime(
'2012-04-01 01:00:00'),
true];
46 $tests[] = [$valarm2,
new DateTime(
'2012-03-01 01:00:00'),
new DateTime(
'2012-03-10 01:00:00'),
false];
49 $valarm3 =
$calendar->createComponent(
'VALARM');
50 $valarm3->add(
$calendar->createProperty(
'TRIGGER',
'-P1D', [
'VALUE' =>
'DURATION',
'RELATED' =>
'END']));
52 $vevent3 =
$calendar->createComponent(
'VEVENT');
53 $vevent3->DTSTART =
'20120301T130000Z';
54 $vevent3->DTEND =
'20120401T130000Z';
55 $vevent3->add($valarm3);
57 $tests[] = [$valarm3,
new DateTime(
'2012-02-25 01:00:00'),
new DateTime(
'2012-03-05 01:00:00'),
false];
58 $tests[] = [$valarm3,
new DateTime(
'2012-03-25 01:00:00'),
new DateTime(
'2012-04-05 01:00:00'),
true];
61 $valarm4 =
$calendar->createComponent(
'VALARM');
62 $valarm4->TRIGGER =
'-P1D';
63 $valarm4->TRIGGER[
'VALUE'] =
'DURATION';
64 $valarm4->TRIGGER[
'RELATED'] =
'END';
66 $vtodo4 =
$calendar->createComponent(
'VTODO');
67 $vtodo4->DTSTART =
'20120301T130000Z';
68 $vtodo4->DUE =
'20120401T130000Z';
69 $vtodo4->add($valarm4);
71 $tests[] = [$valarm4,
new DateTime(
'2012-02-25 01:00:00'),
new DateTime(
'2012-03-05 01:00:00'),
false];
72 $tests[] = [$valarm4,
new DateTime(
'2012-03-25 01:00:00'),
new DateTime(
'2012-04-05 01:00:00'),
true];
75 $valarm5 =
$calendar->createComponent(
'VALARM');
76 $valarm5->TRIGGER =
'-P1D';
77 $valarm5->TRIGGER[
'VALUE'] =
'DURATION';
78 $valarm5->REPEAT = 10;
79 $valarm5->DURATION =
'P1D';
81 $vevent5 =
$calendar->createComponent(
'VEVENT');
82 $vevent5->DTSTART =
'20120301T130000Z';
83 $vevent5->add($valarm5);
85 $tests[] = [$valarm5,
new DateTime(
'2012-03-09 01:00:00'),
new DateTime(
'2012-03-10 01:00:00'),
true];
88 $valarm6 =
$calendar->createComponent(
'VALARM');
89 $valarm6->TRIGGER =
'-P1D';
90 $valarm6->TRIGGER[
'VALUE'] =
'DURATION';
91 $valarm6->DURATION =
'P1D';
93 $vevent6 =
$calendar->createComponent(
'VEVENT');
94 $vevent6->DTSTART =
'20120313T130000Z';
95 $vevent6->add($valarm6);
97 $tests[] = [$valarm6,
new DateTime(
'2012-03-01 01:00:00'),
new DateTime(
'2012-04-01 01:00:00'),
true];
98 $tests[] = [$valarm6,
new DateTime(
'2012-03-01 01:00:00'),
new DateTime(
'2012-03-10 01:00:00'),
false];
102 $valarm7 =
$calendar->createComponent(
'VALARM');
103 $valarm7->TRIGGER =
'-P1D';
104 $valarm7->TRIGGER[
'VALUE'] =
'DURATION';
105 $valarm7->TRIGGER[
'RELATED'] =
'END';
107 $vevent7 =
$calendar->createComponent(
'VEVENT');
108 $vevent7->DTSTART =
'20120301T130000Z';
109 $vevent7->DURATION =
'P30D';
110 $vevent7->add($valarm7);
112 $tests[] = [$valarm7,
new DateTime(
'2012-02-25 01:00:00'),
new DateTime(
'2012-03-05 01:00:00'),
false];
113 $tests[] = [$valarm7,
new DateTime(
'2012-03-25 01:00:00'),
new DateTime(
'2012-04-05 01:00:00'),
true];
116 $valarm7 =
$calendar->createComponent(
'VALARM');
117 $valarm7->TRIGGER =
'-P1D';
118 $valarm7->TRIGGER[
'VALUE'] =
'DURATION';
119 $valarm7->TRIGGER[
'RELATED'] =
'END';
121 $vevent7 =
$calendar->createComponent(
'VEVENT');
122 $vevent7->DTSTART =
'20120301T130000Z';
123 $vevent7->add($valarm7);
125 $tests[] = [$valarm7,
new DateTime(
'2012-02-25 01:00:00'),
new DateTime(
'2012-03-05 01:00:00'),
true];
126 $tests[] = [$valarm7,
new DateTime(
'2012-03-25 01:00:00'),
new DateTime(
'2012-04-05 01:00:00'),
false];
138 $valarm =
$calendar->createComponent(
'VALARM');
139 $valarm->TRIGGER =
'-P1D';
140 $valarm->TRIGGER[
'RELATED'] =
'END';
142 $vjournal =
$calendar->createComponent(
'VJOURNAL');
143 $vjournal->add($valarm);
145 $valarm->isInTimeRange(
new DateTime(
'2012-02-25 01:00:00'),
new DateTime(
'2012-03-05 01:00:00'));
157DTSTAMP:20121003T064931Z
158UID:b848cb9a7bb16e464a06c222ca1f8102@examle.com
162CATEGORIES:AlarmCategory
174 $this->assertTrue(
$vobj->VTODO->VALARM->isInTimeRange(
new \DateTime(
'2012-10-01 00:00:00'),
new \DateTime(
'2012-11-01 00:00:00')));
An exception for terminatinating execution or to throw for unit testing.
testInTimeRangeBuggy()
This bug was found and reported on the mailing list.
testInTimeRangeInvalidComponent()
@expectedException \Sabre\VObject\InvalidDataException
testInTimeRange(VAlarm $valarm, $start, $end, $outcome)
@dataProvider timeRangeTestData
isInTimeRange(DateTimeInterface $start, DateTimeInterface $end)
Returns true or false depending on if the event falls in the specified time-range.
iCalendar/vCard/jCal/jCard/xCal/xCard reader object.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
foreach($paths as $path) if($argc< 3) $input