diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-14 16:14:03 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-14 16:14:03 +0100 |
commit | 2609bf35000b2a62de722e1d2249945fae144857 (patch) | |
tree | e209a8d646f723d710f8b484e4edeee8d385f43e /apps/dav | |
parent | f79195853ec5236559bda3db01690ac492f5304b (diff) | |
parent | 36b543c4903e3ea8f344578b521aee6f091ff29f (diff) | |
download | nextcloud-server-2609bf35000b2a62de722e1d2249945fae144857.tar.gz nextcloud-server-2609bf35000b2a62de722e1d2249945fae144857.zip |
Merge pull request #23114 from owncloud/no-fatal-error-if-DSTART-is-not-set-stable9
No fatal error if dstart is not set stable9
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/caldav/caldavbackend.php | 4 | ||||
-rw-r--r-- | apps/dav/tests/unit/caldav/caldavbackendtest.php | 19 |
2 files changed, 19 insertions, 4 deletions
diff --git a/apps/dav/lib/caldav/caldavbackend.php b/apps/dav/lib/caldav/caldavbackend.php index 521d1b1de5e..fdfc8c399ed 100644 --- a/apps/dav/lib/caldav/caldavbackend.php +++ b/apps/dav/lib/caldav/caldavbackend.php @@ -1294,7 +1294,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription if (!$componentType) { throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component'); } - if ($componentType === 'VEVENT') { + if ($componentType === 'VEVENT' && $component->DTSTART) { $firstOccurence = $component->DTSTART->getDateTime()->getTimeStamp(); // Finding the last occurence is a bit harder if (!isset($component->RRULE)) { @@ -1333,7 +1333,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription 'etag' => md5($calendarData), 'size' => strlen($calendarData), 'componentType' => $componentType, - 'firstOccurence' => $firstOccurence, + 'firstOccurence' => is_null($firstOccurence) ? null : max(0, $firstOccurence), 'lastOccurence' => $lastOccurence, 'uid' => $uid, ]; diff --git a/apps/dav/tests/unit/caldav/caldavbackendtest.php b/apps/dav/tests/unit/caldav/caldavbackendtest.php index aece738166a..87a700a473d 100644 --- a/apps/dav/tests/unit/caldav/caldavbackendtest.php +++ b/apps/dav/tests/unit/caldav/caldavbackendtest.php @@ -57,11 +57,11 @@ class CalDavBackendTest extends TestCase { ->disableOriginalConstructor() ->setMethods(['getPrincipalByPath', 'getGroupMembership']) ->getMock(); - $this->principal->method('getPrincipalByPath') + $this->principal->expects($this->any())->method('getPrincipalByPath') ->willReturn([ 'uri' => 'principals/best-friend' ]); - $this->principal->method('getGroupMembership') + $this->principal->expects($this->any())->method('getGroupMembership') ->withAnyParameters() ->willReturn([self::UNIT_TEST_GROUP]); @@ -446,6 +446,21 @@ EOD; $this->assertEquals(0, count($sos)); } + /** + * @dataProvider providesCalDataForGetDenormalizedData + */ + public function testGetDenormalizedData($expectedFirstOccurance, $calData) { + $actual = $this->invokePrivate($this->backend, 'getDenormalizedData', [$calData]); + $this->assertEquals($expectedFirstOccurance, $actual['firstOccurence']); + } + + public function providesCalDataForGetDenormalizedData() { + return [ + [0, "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:413F269B-B51B-46B1-AFB6-40055C53A4DC\r\nDTSTAMP:20160309T095056Z\r\nDTSTART;VALUE=DATE:16040222\r\nDTEND;VALUE=DATE:16040223\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:SUMMARY\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"], + [null, "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:413F269B-B51B-46B1-AFB6-40055C53A4DC\r\nDTSTAMP:20160309T095056Z\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:SUMMARY\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"] + ]; + } + private function assertAcl($principal, $privilege, $acl) { foreach($acl as $a) { if ($a['principal'] === $principal && $a['privilege'] === $privilege) { |