]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php
Second part of refactoring; should be runnable again, yet not thoroughly tested
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / CalDAV / CalendarQueryVAlarmTest.php
1 <?php
2
3 use Sabre\VObject;
4
5 class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase {
6
7     /**
8      * This test is specifically for a time-range query on a VALARM, contained
9      * in a VEVENT that's recurring
10      */
11     function testValarm() {
12
13         $vevent = VObject\Component::create('VEVENT');
14         $vevent->RRULE = 'FREQ=MONTHLY';
15         $vevent->DTSTART = '20120101T120000Z';
16         $vevent->UID = 'bla';
17
18         $valarm = VObject\Component::create('VALARM');
19         $valarm->TRIGGER = '-P15D';
20         $vevent->add($valarm);
21
22         $vcalendar = VObject\Component::create('VCALENDAR');
23         $vcalendar->add($vevent);
24
25         $filter = array(
26             'name' => 'VCALENDAR',
27             'is-not-defined' => false,
28             'time-range' => null,
29             'prop-filters' => array(),
30             'comp-filters' => array(
31                 array(
32                     'name' => 'VEVENT',
33                     'is-not-defined' => false,
34                     'time-range' => null,
35                     'prop-filters' => array(),
36                     'comp-filters' => array(
37                         array(
38                             'name' => 'VALARM',
39                             'is-not-defined' => false,
40                             'prop-filters' => array(),
41                             'comp-filters' => array(),
42                             'time-range' => array(
43                                 'start' => new DateTime('2012-05-10'),
44                                 'end' => new DateTime('2012-05-20'),
45                             ),
46                         ),
47                     ),
48                 ),
49             ),
50         );
51
52         $validator = new Sabre_CalDAV_CalendarQueryValidator();
53         $this->assertTrue($validator->validate($vcalendar, $filter));
54
55
56         // A limited recurrence rule, should return false
57         $vevent = VObject\Component::create('VEVENT');
58         $vevent->RRULE = 'FREQ=MONTHLY;COUNT=1';
59         $vevent->DTSTART = '20120101T120000Z';
60         $vevent->UID = 'bla';
61
62         $valarm = VObject\Component::create('VALARM');
63         $valarm->TRIGGER = '-P15D';
64         $vevent->add($valarm);
65
66         $vcalendar = VObject\Component::create('VCALENDAR');
67         $vcalendar->add($vevent);
68
69         $this->assertFalse($validator->validate($vcalendar, $filter));
70     }
71
72     function testAlarmWayBefore() {
73
74         $vevent = VObject\Component::create('VEVENT');
75         $vevent->DTSTART = '20120101T120000Z';
76         $vevent->UID = 'bla';
77
78         $valarm = VObject\Component::create('VALARM');
79         $valarm->TRIGGER = '-P2W1D';
80         $vevent->add($valarm);
81
82         $vcalendar = VObject\Component::create('VCALENDAR');
83         $vcalendar->add($vevent);
84
85         $filter = array(
86             'name' => 'VCALENDAR',
87             'is-not-defined' => false,
88             'time-range' => null,
89             'prop-filters' => array(),
90             'comp-filters' => array(
91                 array(
92                     'name' => 'VEVENT',
93                     'is-not-defined' => false,
94                     'time-range' => null,
95                     'prop-filters' => array(),
96                     'comp-filters' => array(
97                         array(
98                             'name' => 'VALARM',
99                             'is-not-defined' => false,
100                             'prop-filters' => array(),
101                             'comp-filters' => array(),
102                             'time-range' => array(
103                                 'start' => new DateTime('2011-12-10'),
104                                 'end' => new DateTime('2011-12-20'),
105                             ),
106                         ),
107                     ),
108                 ),
109             ),
110         );
111
112         $validator = new Sabre_CalDAV_CalendarQueryValidator();
113         $this->assertTrue($validator->validate($vcalendar, $filter));
114
115     }
116
117 }