/**
     * This function takes a list of objects (icalendar objects), and turns
     * them into a freebusy report.
     *
     * Then it takes the expected output and compares it to what we actually
     * got.
     *
     * It only generates the freebusy report for the following time-range:
     * 2011-01-01 11:00:00 until 2011-01-03 11:11:11
     *
     * @param string $expected
     * @param array $input
     * @param string|null $timeZone
     * @param string $vavailability
     * @return void
     */
    function assertFreeBusyReport($expected, $input, $timeZone = null, $vavailability = null)
    {
        $gen = new FreeBusyGenerator(new \DateTime('20110101T110000Z', new \DateTimeZone('UTC')), new \DateTime('20110103T110000Z', new \DateTimeZone('UTC')), $input, $timeZone);
        if ($vavailability) {
            if (is_string($vavailability)) {
                $vavailability = Reader::read($vavailability);
            }
            $gen->setVAvailability($vavailability);
        }
        $output = $gen->getResult();
        // Removing DTSTAMP because it changes every time.
        unset($output->VFREEBUSY->DTSTAMP);
        $expected = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VFREEBUSY
DTSTART:20110101T110000Z
DTEND:20110103T110000Z
{$expected}
END:VFREEBUSY
END:VCALENDAR
ICS;
        $this->assertVObjectEqualsVObject($expected, $output);
    }
예제 #2
0
 function testGeneratorBaseObject()
 {
     $obj = new Component\VCalendar();
     $obj->METHOD = 'PUBLISH';
     $gen = new FreeBusyGenerator();
     $gen->setObjects(array());
     $gen->setBaseObject($obj);
     $result = $gen->getResult();
     $this->assertEquals('PUBLISH', $result->METHOD->getValue());
 }