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