From a1df91da9d1c2ea7e81601e2cf66ae747536d61f Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 9 Jun 2017 12:13:02 +0200 Subject: [PATCH] Sabre/VObject returns DateTimeImmutable, not a simple DateTime Signed-off-by: Georg Ehrke --- apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 6 ++++-- .../tests/unit/CalDAV/Schedule/IMipPluginTest.php | 14 +++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 711d54d7f8..8e1d7e2563 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -160,11 +160,13 @@ class IMipPlugin extends SabreIMipPlugin { $lastOccurrence = $component->DTEND->getDateTime()->getTimeStamp(); } elseif (isset($component->DURATION)) { $endDate = clone $component->DTSTART->getDateTime(); - $endDate->add(DateTimeParser::parse($component->DURATION->getValue())); + // $component->DTEND->getDateTime() returns DateTimeImmutable + $endDate = $endDate->add(DateTimeParser::parse($component->DURATION->getValue())); $lastOccurrence = $endDate->getTimeStamp(); } elseif (!$component->DTSTART->hasTime()) { $endDate = clone $component->DTSTART->getDateTime(); - $endDate->modify('+1 day'); + // $component->DTSTART->getDateTime() returns DateTimeImmutable + $endDate = $endDate->modify('+1 day'); $lastOccurrence = $endDate->getTimeStamp(); } else { $lastOccurrence = $firstOccurrence; diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index d498639ff7..56eb00406d 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -107,7 +107,11 @@ class IMipPluginTest extends TestCase { /** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */ $mailer = $this->getMockBuilder('OC\Mail\Mailer')->disableOriginalConstructor()->getMock(); $mailer->method('createMessage')->willReturn($mailMessage); - $mailer->expects($this->once())->method('send'); + if ($expectsMail) { + $mailer->expects($this->once())->method('send'); + } else { + $mailer->expects($this->never())->method('send'); + } /** @var ILogger | \PHPUnit_Framework_MockObject_MockObject $logger */ $logger = $this->getMockBuilder('OC\Log')->disableOriginalConstructor()->getMock(); $timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock(); @@ -118,8 +122,8 @@ class IMipPluginTest extends TestCase { $message->method = 'REQUEST'; $message->message = new VCalendar(); $message->message->add('VEVENT', array_merge([ - 'UID' => $message->uid, - 'SEQUENCE' => $message->sequence, + 'UID' => 'uid1337', + 'SEQUENCE' => 42, 'SUMMARY' => 'Fellowship meeting', ], $veventParams)); $message->sender = 'mailto:gandalf@wiz.ard'; @@ -139,8 +143,8 @@ class IMipPluginTest extends TestCase { [['DTSTART' => new \DateTime('2017-01-01 00:00:00')], false], [['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00')], false], [['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-12-31 00:00:00')], true], - [['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DURATION' => new \DateInterval('P1D')], false], - [['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DURATION' => new \DateInterval('P1Y')], true], + [['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DURATION' => 'P1D'], false], + [['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DURATION' => 'P52W'], true], [['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00'), 'RRULE' => 'FREQ=WEEKLY'], true], [['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00'), 'RRULE' => 'FREQ=WEEKLY;COUNT=3'], false], [['DTSTART' => new \DateTime('2017-01-01 00:00:00'), 'DTEND' => new \DateTime('2017-01-01 00:00:00'), 'RRULE' => 'FREQ=WEEKLY;UNTIL=20170301T000000Z'], false],