Skip to content

Commit db5817b

Browse files
authored
Merge pull request #1608 from alecpl/dev/fix-1000
Add test for #1000
2 parents bb427f2 + ec259c4 commit db5817b

2 files changed

Lines changed: 165 additions & 0 deletions

File tree

tests/Sabre/CalDAV/Backend/AbstractPDOTestCase.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,72 @@ public function testCalendarQueryTimeRangeNotSpecified()
942942
self::assertTrue(in_array('event2', $result));
943943
}
944944

945+
public function testCalendarQueryGH1000()
946+
{
947+
$backend = new PDO($this->pdo);
948+
$backend->createCalendarObject([1, 1], 'event1', <<<EOF
949+
BEGIN:VCALENDAR
950+
VERSION:2.0
951+
BEGIN:VEVENT
952+
UID:event1
953+
DTSTAMP:20120418T152519Z
954+
DTSTART;VALUE=DATE:20120330
955+
DTEND;VALUE=DATE:20120531
956+
SEQUENCE:1
957+
SUMMARY:Birthday1
958+
BEGIN:VALARM
959+
ACTION:EMAIL
960+
ATTENDEE:MAILTO:xxx@domain.de
961+
TRIGGER;VALUE=DATE-TIME:20120329T060000Z
962+
END:VALARM
963+
END:VEVENT
964+
END:VCALENDAR
965+
EOF
966+
);
967+
$backend->createCalendarObject([1, 1], 'event2', <<<EOF
968+
BEGIN:VCALENDAR
969+
VERSION:2.0
970+
BEGIN:VEVENT
971+
UID:event2
972+
DTSTAMP:20120418T152519Z
973+
DTSTART;VALUE=DATE:20120330
974+
DTEND;VALUE=DATE:20120531
975+
SEQUENCE:1
976+
SUMMARY:Birthday2
977+
END:VEVENT
978+
END:VCALENDAR
979+
EOF
980+
);
981+
982+
$filters = [
983+
'name' => 'VCALENDAR',
984+
'is-not-defined' => false,
985+
'comp-filters' => [
986+
[
987+
'name' => 'VEVENT',
988+
'is-not-defined' => false,
989+
'comp-filters' => [
990+
[
991+
'name' => 'VALARM',
992+
'is-not-defined' => true,
993+
'comp-filters' => [],
994+
'prop-filters' => [],
995+
'time-range' => null,
996+
],
997+
],
998+
'prop-filters' => [],
999+
'time-range' => false,
1000+
],
1001+
],
1002+
'prop-filters' => [],
1003+
'time-range' => null,
1004+
];
1005+
1006+
$result = $backend->calendarQuery([1, 1], $filters);
1007+
self::assertFalse(in_array('event1', $result));
1008+
self::assertTrue(in_array('event2', $result));
1009+
}
1010+
9451011
public function testGetChanges()
9461012
{
9471013
$backend = new PDO($this->pdo);
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sabre\CalDAV;
6+
7+
use Sabre\HTTP;
8+
9+
/**
10+
* This unittest for https://github.com/sabre-io/dav/issues/1000.
11+
*
12+
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
13+
* @author Evert Pot (http://evertpot.com/)
14+
* @license http://sabre.io/license/ Modified BSD License
15+
*/
16+
class Issue1000Test extends \Sabre\AbstractDAVServerTestCase
17+
{
18+
protected $setupCalDAV = true;
19+
20+
protected $caldavCalendars = [
21+
[
22+
'id' => 1,
23+
'name' => 'Calendar',
24+
'principaluri' => 'principals/user1',
25+
'uri' => 'calendar1',
26+
],
27+
];
28+
29+
protected $caldavCalendarObjects = [
30+
1 => [
31+
'event1.ics' => [
32+
'calendardata' => 'BEGIN:VCALENDAR
33+
VERSION:2.0
34+
BEGIN:VEVENT
35+
UID:1111
36+
DTSTAMP:20120418T152519Z
37+
DTSTART;VALUE=DATE:20120330
38+
DTEND;VALUE=DATE:20120531
39+
SEQUENCE:1
40+
SUMMARY:Birthday1
41+
TRANSP:TRANSPARENT
42+
BEGIN:VALARM
43+
ACTION:EMAIL
44+
ATTENDEE:MAILTO:xxx@domain.de
45+
TRIGGER;VALUE=DATE-TIME:20120329T060000Z
46+
END:VALARM
47+
END:VEVENT
48+
END:VCALENDAR
49+
',
50+
],
51+
'event2.ics' => [
52+
'calendardata' => 'BEGIN:VCALENDAR
53+
VERSION:2.0
54+
BEGIN:VEVENT
55+
UID:1234
56+
DTSTAMP:20120418T152519Z
57+
DTSTART;VALUE=DATE:20120330
58+
DTEND;VALUE=DATE:20120531
59+
SEQUENCE:1
60+
SUMMARY:Birthday2
61+
TRANSP:TRANSPARENT
62+
END:VEVENT
63+
END:VCALENDAR
64+
',
65+
],
66+
],
67+
];
68+
69+
public function testIssue1000(): void
70+
{
71+
$request = HTTP\Sapi::createFromServerArray([
72+
'REQUEST_METHOD' => 'REPORT',
73+
'HTTP_CONTENT_TYPE' => 'application/xml',
74+
'REQUEST_URI' => '/calendars/user1/calendar1',
75+
'HTTP_DEPTH' => '1',
76+
]);
77+
78+
$request->setBody('<?xml version="1.0" encoding="utf-8" ?>
79+
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
80+
<D:prop>
81+
<D:getetag/>
82+
</D:prop>
83+
<C:filter>
84+
<C:comp-filter name="VCALENDAR">
85+
<C:comp-filter name="VEVENT">
86+
<C:comp-filter name="VALARM">
87+
<C:is-not-defined/>
88+
</C:comp-filter>
89+
</C:comp-filter>
90+
</C:comp-filter>
91+
</C:filter>
92+
</C:calendar-query>');
93+
94+
$response = $this->request($request);
95+
96+
self::assertTrue(strpos($response->getBodyAsString(), 'event2.ics') > 0);
97+
self::assertTrue(false === strpos($response->getBodyAsString(), 'event1.ics'));
98+
}
99+
}

0 commit comments

Comments
 (0)