44
55use PHPUnit \Framework \TestCase ;
66use Sabre \VObject \InvalidDataException ;
7+ use Sabre \VObject \Property \IntegerValue ;
78use Sabre \VObject \Reader ;
9+ use Sabre \VObject \TestHelper ;
810
911class VAlarmTest extends TestCase
1012{
@@ -44,7 +46,7 @@ public function timeRangeTestData(): array
4446
4547 /** @var VEvent<int, mixed> $vevent2 */
4648 $ vevent2 = $ calendar ->createComponent ('VEVENT ' );
47- $ vevent2 ->DTSTART = '20120313T130000Z ' ;
49+ $ vevent2 ->DTSTART = TestHelper:: createDtStart ( $ calendar , '20120313T130000Z ' ) ;
4850 $ vevent2 ->add ($ valarm2 );
4951
5052 $ tests [] = [$ valarm2 , new \DateTime ('2012-03-01 01:00:00 ' ), new \DateTime ('2012-04-01 01:00:00 ' ), true ];
@@ -56,8 +58,8 @@ public function timeRangeTestData(): array
5658
5759 /** @var VEvent<int, mixed> $vevent3 */
5860 $ vevent3 = $ calendar ->createComponent ('VEVENT ' );
59- $ vevent3 ->DTSTART = '20120301T130000Z ' ;
60- $ vevent3 ->DTEND = '20120401T130000Z ' ;
61+ $ vevent3 ->DTSTART = TestHelper:: createDtStart ( $ calendar , '20120301T130000Z ' ) ;
62+ $ vevent3 ->DTEND = TestHelper:: createDtEnd ( $ calendar , '20120401T130000Z ' ) ;
6163 $ vevent3 ->add ($ valarm3 );
6264
6365 $ tests [] = [$ valarm3 , new \DateTime ('2012-02-25 01:00:00 ' ), new \DateTime ('2012-03-05 01:00:00 ' ), false ];
@@ -66,15 +68,14 @@ public function timeRangeTestData(): array
6668 // Relation to end time of todo
6769 /** @var VAlarm<int, mixed> $valarm4 */
6870 $ valarm4 = $ calendar ->createComponent ('VALARM ' );
69- $ valarm4 ->TRIGGER = '-P1D ' ;
70- /* @phpstan-ignore-next-line Cannot assign offset 'VALUE' to string. Magic is here. */
71+ $ valarm4 ->TRIGGER = TestHelper::createTrigger ($ calendar , '-P1D ' );
7172 $ valarm4 ->TRIGGER ['VALUE ' ] = 'DURATION ' ;
7273 $ valarm4 ->TRIGGER ['RELATED ' ] = 'END ' ;
7374
7475 /** @var VTodo<int, mixed> $vtodo4 */
7576 $ vtodo4 = $ calendar ->createComponent ('VTODO ' );
76- $ vtodo4 ->DTSTART = '20120301T130000Z ' ;
77- $ vtodo4 ->DUE = '20120401T130000Z ' ;
77+ $ vtodo4 ->DTSTART = TestHelper:: createDtStart ( $ calendar , '20120301T130000Z ' ) ;
78+ $ vtodo4 ->DUE = TestHelper:: createDateDue ( $ calendar , '20120401T130000Z ' ) ;
7879 $ vtodo4 ->add ($ valarm4 );
7980
8081 $ tests [] = [$ valarm4 , new \DateTime ('2012-02-25 01:00:00 ' ), new \DateTime ('2012-03-05 01:00:00 ' ), false ];
@@ -83,30 +84,31 @@ public function timeRangeTestData(): array
8384 // Relation to start time of event + repeat
8485 /** @var VAlarm<int, mixed> $valarm5 */
8586 $ valarm5 = $ calendar ->createComponent ('VALARM ' );
86- $ valarm5 ->TRIGGER = '-P1D ' ;
87- /* @phpstan-ignore-next-line Cannot assign offset 'VALUE' to string. Magic is here. */
87+ $ valarm5 ->TRIGGER = TestHelper::createTrigger ($ calendar , '-P1D ' );
8888 $ valarm5 ->TRIGGER ['VALUE ' ] = 'DURATION ' ;
89- $ valarm5 ->REPEAT = 10 ;
90- $ valarm5 ->DURATION = 'P1D ' ;
89+ /** @var IntegerValue<mixed, mixed> $property */
90+ $ property = $ calendar ->createProperty ('REPEAT ' );
91+ $ property ->setValue ([10 ]);
92+ $ valarm5 ->REPEAT = $ property ;
93+ $ valarm5 ->DURATION = TestHelper::createDuration ($ calendar , 'P1D ' );
9194
9295 /** @var VEvent<int, mixed> $vevent5 */
9396 $ vevent5 = $ calendar ->createComponent ('VEVENT ' );
94- $ vevent5 ->DTSTART = '20120301T130000Z ' ;
97+ $ vevent5 ->DTSTART = TestHelper:: createDtStart ( $ calendar , '20120301T130000Z ' ) ;
9598 $ vevent5 ->add ($ valarm5 );
9699
97100 $ tests [] = [$ valarm5 , new \DateTime ('2012-03-09 01:00:00 ' ), new \DateTime ('2012-03-10 01:00:00 ' ), true ];
98101
99102 // Relation to start time of event + duration, but no repeat
100103 /** @var VAlarm<int, mixed> $valarm6 */
101104 $ valarm6 = $ calendar ->createComponent ('VALARM ' );
102- $ valarm6 ->TRIGGER = '-P1D ' ;
103- /* @phpstan-ignore-next-line Cannot assign offset 'VALUE' to string. Magic is here. */
105+ $ valarm6 ->TRIGGER = TestHelper::createTrigger ($ calendar , '-P1D ' );
104106 $ valarm6 ->TRIGGER ['VALUE ' ] = 'DURATION ' ;
105- $ valarm6 ->DURATION = 'P1D ' ;
107+ $ valarm6 ->DURATION = TestHelper:: createDuration ( $ calendar , 'P1D ' ) ;
106108
107109 /** @var VEvent<int, mixed> $vevent6 */
108110 $ vevent6 = $ calendar ->createComponent ('VEVENT ' );
109- $ vevent6 ->DTSTART = '20120313T130000Z ' ;
111+ $ vevent6 ->DTSTART = TestHelper:: createDtStart ( $ calendar , '20120313T130000Z ' ) ;
110112 $ vevent6 ->add ($ valarm6 );
111113
112114 $ tests [] = [$ valarm6 , new \DateTime ('2012-03-01 01:00:00 ' ), new \DateTime ('2012-04-01 01:00:00 ' ), true ];
@@ -115,15 +117,14 @@ public function timeRangeTestData(): array
115117 // Relation to end time of event (DURATION instead of DTEND)
116118 /** @var VAlarm<int, mixed> $valarm7 */
117119 $ valarm7 = $ calendar ->createComponent ('VALARM ' );
118- $ valarm7 ->TRIGGER = '-P1D ' ;
119- /* @phpstan-ignore-next-line Cannot assign offset 'VALUE' to string. Magic is here. */
120+ $ valarm7 ->TRIGGER = TestHelper::createTrigger ($ calendar , '-P1D ' );
120121 $ valarm7 ->TRIGGER ['VALUE ' ] = 'DURATION ' ;
121122 $ valarm7 ->TRIGGER ['RELATED ' ] = 'END ' ;
122123
123124 /** @var VEvent<int, mixed> $vevent7 */
124125 $ vevent7 = $ calendar ->createComponent ('VEVENT ' );
125- $ vevent7 ->DTSTART = '20120301T130000Z ' ;
126- $ vevent7 ->DURATION = 'P30D ' ;
126+ $ vevent7 ->DTSTART = TestHelper:: createDtStart ( $ calendar , '20120301T130000Z ' ) ;
127+ $ vevent7 ->DURATION = TestHelper:: createDuration ( $ calendar , 'P30D ' ) ;
127128 $ vevent7 ->add ($ valarm7 );
128129
129130 $ tests [] = [$ valarm7 , new \DateTime ('2012-02-25 01:00:00 ' ), new \DateTime ('2012-03-05 01:00:00 ' ), false ];
@@ -132,14 +133,13 @@ public function timeRangeTestData(): array
132133 // Relation to end time of event (No DTEND or DURATION)
133134 /** @var VAlarm<int, mixed> $valarm7 */
134135 $ valarm7 = $ calendar ->createComponent ('VALARM ' );
135- $ valarm7 ->TRIGGER = '-P1D ' ;
136- /* @phpstan-ignore-next-line Cannot assign offset 'VALUE' to string. Magic is here. */
136+ $ valarm7 ->TRIGGER = TestHelper::createTrigger ($ calendar , '-P1D ' );
137137 $ valarm7 ->TRIGGER ['VALUE ' ] = 'DURATION ' ;
138138 $ valarm7 ->TRIGGER ['RELATED ' ] = 'END ' ;
139139
140140 /** @var VEvent<int, mixed> $vevent7 */
141141 $ vevent7 = $ calendar ->createComponent ('VEVENT ' );
142- $ vevent7 ->DTSTART = '20120301T130000Z ' ;
142+ $ vevent7 ->DTSTART = TestHelper:: createDtStart ( $ calendar , '20120301T130000Z ' ) ;
143143 $ vevent7 ->add ($ valarm7 );
144144
145145 $ tests [] = [$ valarm7 , new \DateTime ('2012-02-25 01:00:00 ' ), new \DateTime ('2012-03-05 01:00:00 ' ), true ];
@@ -154,8 +154,7 @@ public function testInTimeRangeInvalidComponent(): void
154154 $ calendar = new VCalendar ();
155155 /** @var VAlarm<int, mixed> $valarm */
156156 $ valarm = $ calendar ->createComponent ('VALARM ' );
157- $ valarm ->TRIGGER = '-P1D ' ;
158- /* @phpstan-ignore-next-line Cannot assign offset 'RELATED' to string. Magic is here. */
157+ $ valarm ->TRIGGER = TestHelper::createTrigger ($ calendar , '-P1D ' );
159158 $ valarm ->TRIGGER ['RELATED ' ] = 'END ' ;
160159
161160 $ vjournal = $ calendar ->createComponent ('VJOURNAL ' );
0 commit comments