summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2017-06-09 12:13:02 +0200
committerGeorg Ehrke <developer@georgehrke.com>2017-07-23 09:36:35 +0200
commit7b113bb18ac1fd1b4041537ce87e760afeb752bd (patch)
tree864741826b5831af75a41e23fad9aab000cb0ca9 /apps/dav
parent702d13cc796114bfa292c66137fcda0b14815fac (diff)
downloadnextcloud-server-7b113bb18ac1fd1b4041537ce87e760afeb752bd.tar.gz
nextcloud-server-7b113bb18ac1fd1b4041537ce87e760afeb752bd.zip
Sabre/VObject returns DateTimeImmutable, not a simple DateTime
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CalDAV/Schedule/IMipPlugin.php6
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php14
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 711d54d7f8e..8e1d7e2563d 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 d498639ff71..56eb00406da 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],