Skip to content

Commit d5fd00b

Browse files
committed
fixup! Use recurrence instance to build iMip email
1 parent 597f1cb commit d5fd00b

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed

apps/dav/tests/unit/CalDAV/Schedule/IMipServiceTest.php

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
use PHPUnit\Framework\MockObject\MockObject;
4242
use Sabre\VObject\Component\VCalendar;
4343
use Sabre\VObject\Component\VEvent;
44+
use Sabre\VObject\Property\ICalendar\DateTime;
4445
use Test\TestCase;
4546

4647
class IMipServiceTest extends TestCase
@@ -171,30 +172,57 @@ public function testBuildBodyDataUpdate(): void
171172
$this->assertEquals($expected, $actual);
172173
}
173174

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 {
175205
//
176206
// $vCalendar = new VCalendar();
177207
// $vevent = new VEvent($vCalendar, 'two', [
178208
// 'UID' => 'uid-1234',
179209
// 'SEQUENCE' => 1,
180210
// 'LAST-MODIFIED' => 456789,
181211
// 'SUMMARY' => 'Elevenses',
182-
// 'TZID' => 'Europe/Vienna'
212+
// 'TZID' => 'Europe/Vienna',
213+
// 'DTSTART' => new \DateTime('2016-01-01'),
214+
// 'DTEND' => new \DateTime('2016-01-02'),
183215
// ]);
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);
188216
// $this->l10n->expects(self::exactly(3))
189217
// ->method('l')
190218
// ->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']]
194222
// )->willReturnOnConsecutiveCalls(
195-
// ['Fr.'],
196-
// ['01.01. 08:00'],
197-
// ['09:00']
223+
// 'Fr.',
224+
// '01.01. 08:00',
225+
// '09:00'
198226
// );
199227
// // Fr., 06.01.2023, 11:00
200228
// // 12:00

0 commit comments

Comments
 (0)