3 class Sabre_VObject_FreeBusyGeneratorTest extends PHPUnit_Framework_TestCase {
11 DTSTART:20110101T120000Z
12 DTEND:20110101T130000Z
22 DTSTART:20110101T130000Z
23 DTEND:20110101T140000Z
28 // transparent, hidden
33 DTSTART:20110101T140000Z
34 DTEND:20110101T150000Z
44 DTSTART:20110101T160000Z
45 DTEND:20110101T170000Z
50 // tentative, shows up
55 DTSTART:20110101T180000Z
56 DTEND:20110101T190000Z
61 // outside of time-range, hidden
65 DTSTART:20110101T090000Z
66 DTEND:20110101T100000Z
71 // outside of time-range, hidden
75 DTSTART:20110104T090000Z
76 DTEND:20110104T100000Z
81 // using duration, shows up
85 DTSTART:20110101T190000Z
91 // Day-long event, shows up
95 DTSTART;TYPE=DATE:20110102
100 // No duration, does not show up
104 DTSTART:20110101T200000Z
109 // encoded as object, shows up
113 DTSTART:20110101T210000Z
119 // Freebusy. Some parts show up
123 FREEBUSY:20110103T010000Z/20110103T020000Z
124 FREEBUSY;FBTYPE=FREE:20110103T020000Z/20110103T030000Z
125 FREEBUSY:20110103T030000Z/20110103T040000Z,20110103T040000Z/20110103T050000Z
126 FREEBUSY:20120101T000000Z/20120101T010000Z
127 FREEBUSY:20110103T050000Z/PT1H
132 // Yearly recurrence rule, shows up
136 DTSTART:20100101T220000Z
137 DTEND:20100101T230000Z
143 // Yearly recurrence rule + duration, shows up
147 DTSTART:20100101T230000Z
166 Sabre_VObject_Reader::read($blob11),
174 function testGenerator() {
176 $gen = new Sabre_VObject_FreeBusyGenerator();
177 $gen->setObjects($this->getInput());
179 new DateTime('20110101T110000Z'),
180 new DateTime('20110103T110000Z')
183 $result = $gen->getResult();
186 '20110101T120000Z/20110101T130000Z',
187 '20110101T130000Z/20110101T140000Z',
188 '20110101T180000Z/20110101T190000Z',
189 '20110101T190000Z/20110101T200000Z',
190 '20110102T000000Z/20110103T000000Z',
191 '20110101T210000Z/20110101T220000Z',
193 '20110103T010000Z/20110103T020000Z',
194 '20110103T030000Z/20110103T040000Z',
195 '20110103T040000Z/20110103T050000Z',
196 '20110103T050000Z/20110103T060000Z',
198 '20110101T220000Z/20110101T230000Z',
199 '20110101T230000Z/20110102T000000Z',
202 foreach($result->VFREEBUSY->FREEBUSY as $fb) {
204 $this->assertContains((string)$fb, $expected);
206 $k = array_search((string)$fb, $expected);
207 unset($expected[$k]);
210 if (count($expected)>0) {
211 $this->fail('There were elements in the expected array that were not found in the output: ' . "\n" . print_r($expected,true) . "\n" . $result->serialize());
217 function testGeneratorBaseObject() {
219 $obj = new Sabre_VObject_Component('VCALENDAR');
220 $obj->METHOD = 'PUBLISH';
222 $gen = new Sabre_VObject_FreeBusyGenerator();
223 $gen->setObjects(array());
224 $gen->setBaseObject($obj);
226 $result = $gen->getResult();
228 $this->assertEquals('PUBLISH', $result->METHOD->value);
231 function testGeneratorNoVersion() {
233 $v = Sabre_DAV_Server::$exposeVersion;
234 Sabre_DAV_Server::$exposeVersion = false;
236 $gen = new Sabre_VObject_FreeBusyGenerator();
237 $gen->setObjects(array());
239 $result = $gen->getResult();
240 Sabre_DAV_Server::$exposeVersion = $v;
242 $this->assertFalse(strpos($result->PRODID->value, Sabre_VObject_Version::VERSION));
247 * @expectedException InvalidArgumentException
249 function testInvalidArg() {
251 $gen = new Sabre_VObject_FreeBusyGenerator();
252 $gen->setObjects(array(new StdClass()));