|
41 | 41 | use PHPUnit\Framework\MockObject\MockObject; |
42 | 42 | use Sabre\VObject\Component\VCalendar; |
43 | 43 | use Sabre\VObject\Component\VEvent; |
| 44 | +use Sabre\VObject\Property\ICalendar\DateTime; |
44 | 45 | use Test\TestCase; |
45 | 46 |
|
46 | 47 | class IMipServiceTest extends TestCase |
@@ -171,30 +172,57 @@ public function testBuildBodyDataUpdate(): void |
171 | 172 | $this->assertEquals($expected, $actual); |
172 | 173 | } |
173 | 174 |
|
174 | | -// public function testGenerateWhenStringHourlyEvent(): void { |
| 175 | + public function testGenerateWhenStringHourlyEvent(): void { |
| 176 | + $vCalendar = new VCalendar(); |
| 177 | + $vevent = new VEvent($vCalendar, 'two', [ |
| 178 | + 'UID' => 'uid-1234', |
| 179 | + 'SEQUENCE' => 1, |
| 180 | + 'LAST-MODIFIED' => 456789, |
| 181 | + 'SUMMARY' => 'Elevenses', |
| 182 | + 'TZID' => 'Europe/Vienna', |
| 183 | + 'DTSTART' => (new \DateTime('2016-01-01 08:00:00'))->setTimezone(new \DateTimeZone('Europe/Vienna')), |
| 184 | + 'DTEND' => (new \DateTime('2016-01-01 09:00:00'))->setTimezone(new \DateTimeZone('Europe/Vienna')), |
| 185 | + ]); |
| 186 | + |
| 187 | + $this->l10n->expects(self::exactly(3)) |
| 188 | + ->method('l') |
| 189 | + ->withConsecutive( |
| 190 | + ['weekdayName', (new \DateTime('2016-01-01 08:00:00'))->setTimezone(new \DateTimeZone('Europe/Vienna')), ['width' => 'abbreviated']], |
| 191 | + ['datetime', (new \DateTime('2016-01-01 08:00:00'))->setTimezone(new \DateTimeZone('Europe/Vienna')), ['width' => 'medium|short']], |
| 192 | + ['time', (new \DateTime('2016-01-01 09:00:00'))->setTimezone(new \DateTimeZone('Europe/Vienna')), ['width' => 'short']] |
| 193 | + )->willReturnOnConsecutiveCalls( |
| 194 | + 'Fr.', |
| 195 | + '01.01. 08:00', |
| 196 | + '09:00' |
| 197 | + ); |
| 198 | + |
| 199 | + $expected = 'Fr., 01.01. 08:00 - 09:00 (Europe/Vienna)'; |
| 200 | + $actual = $this->service->generateWhenString($vevent); |
| 201 | + $this->assertEquals($expected, $actual); |
| 202 | + } |
| 203 | + |
| 204 | +// public function testGenerateWhenStringAllDayEvent(): void { |
175 | 205 | // |
176 | 206 | // $vCalendar = new VCalendar(); |
177 | 207 | // $vevent = new VEvent($vCalendar, 'two', [ |
178 | 208 | // 'UID' => 'uid-1234', |
179 | 209 | // 'SEQUENCE' => 1, |
180 | 210 | // 'LAST-MODIFIED' => 456789, |
181 | 211 | // 'SUMMARY' => 'Elevenses', |
182 | | -// 'TZID' => 'Europe/Vienna' |
| 212 | +// 'TZID' => 'Europe/Vienna', |
| 213 | +// 'DTSTART' => new \DateTime('2016-01-01'), |
| 214 | +// 'DTEND' => new \DateTime('2016-01-02'), |
183 | 215 | // ]); |
184 | | -// $start = (new DateTime($vevent,'start', null))->setValue('2016-01-01 08:00:00'); |
185 | | -// $end = new DateTime($vevent,'end', '2016-01-01 09:00:00'); |
186 | | -// $vevent->add($start); |
187 | | -// $vevent->add($end); |
188 | 216 | // $this->l10n->expects(self::exactly(3)) |
189 | 217 | // ->method('l') |
190 | 218 | // ->withConsecutive( |
191 | | -// ['weekdayName', $start->getDateTime(), ['width' => 'abbreviated']], |
192 | | -// ['datetime', $start->getDateTime(), ['width' => 'medium|short']], |
193 | | -// ['time', $end->getDateTime(), ['width' => 'medium|short']] |
| 219 | +// ['weekdayName', new \DateTime('2016-01-01'), ['width' => 'abbreviated']], |
| 220 | +// ['datetime', new \DateTime('2016-01-01'), ['width' => 'medium|short']], |
| 221 | +// ['time', new \DateTime('2016-01-01 09:00:00'), ['width' => 'short']] |
194 | 222 | // )->willReturnOnConsecutiveCalls( |
195 | | -// ['Fr.'], |
196 | | -// ['01.01. 08:00'], |
197 | | -// ['09:00'] |
| 223 | +// 'Fr.', |
| 224 | +// '01.01. 08:00', |
| 225 | +// '09:00' |
198 | 226 | // ); |
199 | 227 | // // Fr., 06.01.2023, 11:00 |
200 | 228 | // // 12:00 |
|
0 commit comments