2012-06-03 14:19:28 -04:00
|
|
|
<?php
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
use Sabre\VObject;
|
|
|
|
|
2012-06-03 14:19:28 -04:00
|
|
|
class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This test is specifically for a time-range query on a VALARM, contained
|
|
|
|
* in a VEVENT that's recurring
|
|
|
|
*/
|
|
|
|
function testValarm() {
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$vevent = VObject\Component::create('VEVENT');
|
2012-06-03 14:19:28 -04:00
|
|
|
$vevent->RRULE = 'FREQ=MONTHLY';
|
|
|
|
$vevent->DTSTART = '20120101T120000Z';
|
|
|
|
$vevent->UID = 'bla';
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$valarm = VObject\Component::create('VALARM');
|
2012-06-03 14:19:28 -04:00
|
|
|
$valarm->TRIGGER = '-P15D';
|
|
|
|
$vevent->add($valarm);
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$vcalendar = VObject\Component::create('VCALENDAR');
|
2012-06-03 14:19:28 -04:00
|
|
|
$vcalendar->add($vevent);
|
|
|
|
|
|
|
|
$filter = array(
|
|
|
|
'name' => 'VCALENDAR',
|
|
|
|
'is-not-defined' => false,
|
|
|
|
'time-range' => null,
|
|
|
|
'prop-filters' => array(),
|
|
|
|
'comp-filters' => array(
|
|
|
|
array(
|
|
|
|
'name' => 'VEVENT',
|
|
|
|
'is-not-defined' => false,
|
|
|
|
'time-range' => null,
|
|
|
|
'prop-filters' => array(),
|
|
|
|
'comp-filters' => array(
|
|
|
|
array(
|
|
|
|
'name' => 'VALARM',
|
|
|
|
'is-not-defined' => false,
|
|
|
|
'prop-filters' => array(),
|
|
|
|
'comp-filters' => array(),
|
|
|
|
'time-range' => array(
|
|
|
|
'start' => new DateTime('2012-05-10'),
|
|
|
|
'end' => new DateTime('2012-05-20'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
$validator = new Sabre_CalDAV_CalendarQueryValidator();
|
|
|
|
$this->assertTrue($validator->validate($vcalendar, $filter));
|
|
|
|
|
|
|
|
|
|
|
|
// A limited recurrence rule, should return false
|
2012-08-11 04:07:19 -04:00
|
|
|
$vevent = VObject\Component::create('VEVENT');
|
2012-06-03 14:19:28 -04:00
|
|
|
$vevent->RRULE = 'FREQ=MONTHLY;COUNT=1';
|
|
|
|
$vevent->DTSTART = '20120101T120000Z';
|
|
|
|
$vevent->UID = 'bla';
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$valarm = VObject\Component::create('VALARM');
|
2012-06-03 14:19:28 -04:00
|
|
|
$valarm->TRIGGER = '-P15D';
|
|
|
|
$vevent->add($valarm);
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$vcalendar = VObject\Component::create('VCALENDAR');
|
2012-06-03 14:19:28 -04:00
|
|
|
$vcalendar->add($vevent);
|
|
|
|
|
|
|
|
$this->assertFalse($validator->validate($vcalendar, $filter));
|
|
|
|
}
|
|
|
|
|
|
|
|
function testAlarmWayBefore() {
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$vevent = VObject\Component::create('VEVENT');
|
2012-06-03 14:19:28 -04:00
|
|
|
$vevent->DTSTART = '20120101T120000Z';
|
|
|
|
$vevent->UID = 'bla';
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$valarm = VObject\Component::create('VALARM');
|
2012-06-03 14:19:28 -04:00
|
|
|
$valarm->TRIGGER = '-P2W1D';
|
|
|
|
$vevent->add($valarm);
|
|
|
|
|
2012-08-11 04:07:19 -04:00
|
|
|
$vcalendar = VObject\Component::create('VCALENDAR');
|
2012-06-03 14:19:28 -04:00
|
|
|
$vcalendar->add($vevent);
|
|
|
|
|
|
|
|
$filter = array(
|
|
|
|
'name' => 'VCALENDAR',
|
|
|
|
'is-not-defined' => false,
|
|
|
|
'time-range' => null,
|
|
|
|
'prop-filters' => array(),
|
|
|
|
'comp-filters' => array(
|
|
|
|
array(
|
|
|
|
'name' => 'VEVENT',
|
|
|
|
'is-not-defined' => false,
|
|
|
|
'time-range' => null,
|
|
|
|
'prop-filters' => array(),
|
|
|
|
'comp-filters' => array(
|
|
|
|
array(
|
|
|
|
'name' => 'VALARM',
|
|
|
|
'is-not-defined' => false,
|
|
|
|
'prop-filters' => array(),
|
|
|
|
'comp-filters' => array(),
|
|
|
|
'time-range' => array(
|
|
|
|
'start' => new DateTime('2011-12-10'),
|
|
|
|
'end' => new DateTime('2011-12-20'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
$validator = new Sabre_CalDAV_CalendarQueryValidator();
|
|
|
|
$this->assertTrue($validator->validate($vcalendar, $filter));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|