Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions tests/Sabre/CalDAV/Backend/AbstractPDOTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,72 @@ public function testCalendarQueryTimeRangeNotSpecified()
self::assertTrue(in_array('event2', $result));
}

public function testCalendarQueryGH1000()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function testCalendarQueryGH1000()
public function testCalendarQueryGH1000(): void

{
$backend = new PDO($this->pdo);
$backend->createCalendarObject([1, 1], 'event1', <<<EOF
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
UID:event1
DTSTAMP:20120418T152519Z
DTSTART;VALUE=DATE:20120330
DTEND;VALUE=DATE:20120531
SEQUENCE:1
SUMMARY:Birthday1
BEGIN:VALARM
ACTION:EMAIL
ATTENDEE:MAILTO:xxx@domain.de
TRIGGER;VALUE=DATE-TIME:20120329T060000Z
END:VALARM
END:VEVENT
END:VCALENDAR
EOF
);
$backend->createCalendarObject([1, 1], 'event2', <<<EOF
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
UID:event2
DTSTAMP:20120418T152519Z
DTSTART;VALUE=DATE:20120330
DTEND;VALUE=DATE:20120531
SEQUENCE:1
SUMMARY:Birthday2
END:VEVENT
END:VCALENDAR
EOF
);

$filters = [
'name' => 'VCALENDAR',
'is-not-defined' => false,
'comp-filters' => [
[
'name' => 'VEVENT',
'is-not-defined' => false,
'comp-filters' => [
[
'name' => 'VALARM',
'is-not-defined' => true,
'comp-filters' => [],
'prop-filters' => [],
'time-range' => null,
],
],
'prop-filters' => [],
'time-range' => false,
],
],
'prop-filters' => [],
'time-range' => null,
];

$result = $backend->calendarQuery([1, 1], $filters);
self::assertFalse(in_array('event1', $result));
self::assertTrue(in_array('event2', $result));
}

public function testGetChanges()
{
$backend = new PDO($this->pdo);
Expand Down
99 changes: 99 additions & 0 deletions tests/Sabre/CalDAV/Issue1000Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

declare(strict_types=1);

namespace Sabre\CalDAV;

use Sabre\HTTP;

/**
* This unittest for https://github.com/sabre-io/dav/issues/1000.
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
class Issue1000Test extends \Sabre\AbstractDAVServerTestCase
{
protected $setupCalDAV = true;

protected $caldavCalendars = [
[
'id' => 1,
'name' => 'Calendar',
'principaluri' => 'principals/user1',
'uri' => 'calendar1',
],
];

protected $caldavCalendarObjects = [
Comment on lines +18 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected $setupCalDAV = true;
protected $caldavCalendars = [
[
'id' => 1,
'name' => 'Calendar',
'principaluri' => 'principals/user1',
'uri' => 'calendar1',
],
];
protected $caldavCalendarObjects = [
protected bool $setupCalDAV = true;
protected array $caldavCalendars = [
[
'id' => 1,
'name' => 'Calendar',
'principaluri' => 'principals/user1',
'uri' => 'calendar1',
],
];
protected array $caldavCalendarObjects = [

1 => [
'event1.ics' => [
'calendardata' => 'BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
UID:1111
DTSTAMP:20120418T152519Z
DTSTART;VALUE=DATE:20120330
DTEND;VALUE=DATE:20120531
SEQUENCE:1
SUMMARY:Birthday1
TRANSP:TRANSPARENT
BEGIN:VALARM
ACTION:EMAIL
ATTENDEE:MAILTO:xxx@domain.de
TRIGGER;VALUE=DATE-TIME:20120329T060000Z
END:VALARM
END:VEVENT
END:VCALENDAR
',
],
'event2.ics' => [
'calendardata' => 'BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
UID:1234
DTSTAMP:20120418T152519Z
DTSTART;VALUE=DATE:20120330
DTEND;VALUE=DATE:20120531
SEQUENCE:1
SUMMARY:Birthday2
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR
',
],
],
];

public function testIssue211()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function testIssue211()
public function testIssue211(): void

{
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
'REQUEST_URI' => '/calendars/user1/calendar1',
'HTTP_DEPTH' => '1',
]);

$request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
<D:prop>
<D:getetag/>
</D:prop>
<C:filter>
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VEVENT">
<C:comp-filter name="VALARM">
<C:is-not-defined/>
</C:comp-filter>
</C:comp-filter>
</C:comp-filter>
</C:filter>
</C:calendar-query>');

$response = $this->request($request);

self::assertTrue(strpos($response->getBodyAsString(), 'event2.ics') > 0);
self::assertTrue(false === strpos($response->getBodyAsString(), 'event1.ics'));
}
}