예제 #1
0
 function testCreateComponent()
 {
     $vcal = new Component\VCalendar();
     $event = $vcal->createComponent('VEVENT');
     $this->assertInstanceOf('Sabre\\VObject\\Component\\VEvent', $event);
     $vcal->add($event);
     $prop = $vcal->createProperty('X-PROP', '1234256', array('X-PARAM' => '3'));
     $this->assertInstanceOf('Sabre\\VObject\\Property', $prop);
     $event->add($prop);
     $out = $vcal->serialize();
     $this->assertEquals("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nX-PROP;X-PARAM=3:1234256\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", $out);
 }
예제 #2
0
 function testDestroy()
 {
     $vcal = new Component\VCalendar([], false);
     $event = $vcal->createComponent('VEVENT');
     $this->assertInstanceOf('Sabre\\VObject\\Component\\VEvent', $event);
     $vcal->add($event);
     $prop = $vcal->createProperty('X-PROP', '1234256', ['X-PARAM' => '3']);
     $event->add($prop);
     $this->assertEquals($event, $prop->parent);
     $vcal->destroy();
     $this->assertNull($prop->parent);
 }
예제 #3
0
 function testIterate()
 {
     $cal = new Component\VCalendar();
     $sub = $cal->createComponent('VEVENT');
     $elems = [$sub, clone $sub, clone $sub];
     $elemList = new ElementList($elems);
     $count = 0;
     foreach ($elemList as $key => $subcomponent) {
         $count++;
         $this->assertInstanceOf('Sabre\\VObject\\Component', $subcomponent);
     }
     $this->assertEquals(3, $count);
     $this->assertEquals(2, $key);
 }
예제 #4
0
 function testToJCal()
 {
     $cal = new Component\VCalendar();
     $event = $cal->add('VEVENT', array("UID" => "foo", "DTSTART" => new \DateTime("2013-05-26 18:10:00Z"), "DURATION" => "P1D", "CATEGORIES" => array('home', 'testing'), "CREATED" => new \DateTime("2013-05-26 18:10:00Z"), "ATTACH" => "attachment", "ATTENDEE" => "mailto:armin@example.org", "GEO" => array(51.96668, 7.61876), "SEQUENCE" => 5, "FREEBUSY" => array("20130526T210213Z/PT1H", "20130626T120000Z/20130626T130000Z"), "URL" => "http://example.org/", "TZOFFSETFROM" => "+05:00", "RRULE" => array('FREQ' => 'WEEKLY', 'BYDAY' => array('MO', 'TU'))));
     // Modifying DTSTART to be a date-only.
     $event->dtstart['VALUE'] = 'DATE';
     $event->add("X-BOOL", true, array('VALUE' => 'BOOLEAN'));
     $event->add("X-TIME", "08:00:00", array('VALUE' => 'TIME'));
     $event->add("ATTENDEE", "mailto:dominik@example.org", array("CN" => "Dominik", "PARTSTAT" => "DECLINED"));
     $event->add('REQUEST-STATUS', array("2.0", "Success"));
     $event->add('REQUEST-STATUS', array("3.7", "Invalid Calendar User", "ATTENDEE:mailto:jsmith@example.org"));
     $expected = array("vcalendar", array(array("version", new \StdClass(), "text", "2.0"), array("prodid", new \StdClass(), "text", "-//Sabre//Sabre VObject " . Version::VERSION . "//EN"), array("calscale", new \StdClass(), "text", "GREGORIAN")), array(array("vevent", array(array("uid", new \StdClass(), "text", "foo"), array("dtstart", new \StdClass(), "date", "2013-05-26"), array("duration", new \StdClass(), "duration", "P1D"), array("categories", new \StdClass(), "text", "home", "testing"), array("created", new \StdClass(), "date-time", "2013-05-26T18:10:00Z"), array("attach", new \StdClass(), "binary", base64_encode('attachment')), array("attendee", new \StdClass(), "cal-address", "mailto:armin@example.org"), array("geo", new \StdClass(), "float", array(51.96668, 7.61876)), array("sequence", new \StdClass(), "integer", 5), array("freebusy", new \StdClass(), "period", array("2013-05-26T21:02:13", "PT1H"), array("2013-06-26T12:00:00", "2013-06-26T13:00:00")), array("url", new \StdClass(), "uri", "http://example.org/"), array("tzoffsetfrom", new \StdClass(), "utc-offset", "+05:00"), array("rrule", new \StdClass(), "recur", array('freq' => 'WEEKLY', 'byday' => array('MO', 'TU'))), array("x-bool", new \StdClass(), "boolean", true), array("x-time", new \StdClass(), "time", "08:00:00"), array("attendee", (object) array("cn" => "Dominik", "partstat" => "DECLINED"), "cal-address", "mailto:dominik@example.org"), array("request-status", new \StdClass(), "text", array("2.0", "Success")), array("request-status", new \StdClass(), "text", array("3.7", "Invalid Calendar User", "ATTENDEE:mailto:jsmith@example.org"))), array())));
     $this->assertEquals($expected, $cal->jsonSerialize());
 }
예제 #5
0
파일: SlashRTest.php 프로젝트: bodun/jorani
 function testEncode()
 {
     $vcal = new Component\VCalendar();
     $prop = $vcal->add('test', "abc\r\ndef");
     $this->assertEquals("TEST:abc\\ndef\r\n", $prop->serialize());
 }
    /**
     * @expectedException \InvalidArgumentException
     */
    function testInvalidArgumentExceptionForPartiallyInvalidArray()
    {
        $generator = new BirthdayCalendarGenerator();
        $input = [];
        $input[] = <<<VCF
BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest;;Mr.
FN:Forrest Gump
BDAY:19850407
UID:foo
END:VCARD
VCF;
        $calendar = new Component\VCalendar();
        $input = $calendar->add('VEVENT', ['SUMMARY' => 'Foo', 'DTSTART' => new \DateTime('NOW')]);
        $generator->setObjects($input);
    }
예제 #7
0
 function testGetClassNameForPropertyValue()
 {
     $vcal = new Component\VCalendar(array(), false);
     $this->assertEquals('Sabre\\VObject\\Property\\Text', $vcal->getClassNameForPropertyValue('TEXT'));
     $this->assertNull($vcal->getClassNameForPropertyValue('FOO'));
 }