Skip to content

Commit

Permalink
Merge pull request #23048 from owncloud/no-fatal-error-if-DSTART-is-n…
Browse files Browse the repository at this point in the history
…ot-set

No fatal error if dstart is not set
  • Loading branch information
DeepDiver1975 committed Mar 10, 2016
2 parents ad61c55 + 6133253 commit 7f16aae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/dav/lib/caldav/caldavbackend.php
Expand Up @@ -1294,7 +1294,7 @@ protected function getDenormalizedData($calendarData) {
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)) {
Expand Down Expand Up @@ -1333,7 +1333,7 @@ protected function getDenormalizedData($calendarData) {
'etag' => md5($calendarData),
'size' => strlen($calendarData),
'componentType' => $componentType,
'firstOccurence' => $firstOccurence,
'firstOccurence' => is_null($firstOccurence) ? null : max(0, $firstOccurence),
'lastOccurence' => $lastOccurence,
'uid' => $uid,
];
Expand Down
19 changes: 17 additions & 2 deletions apps/dav/tests/unit/caldav/caldavbackendtest.php
Expand Up @@ -57,11 +57,11 @@ public function setUp() {
->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]);

Expand Down Expand Up @@ -446,6 +446,21 @@ public function testScheduling() {
$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) {
Expand Down

0 comments on commit 7f16aae

Please sign in to comment.