ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
DocumentTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\VObject;
4
5use PHPUnit\Framework\TestCase;
6
7class DocumentTest extends TestCase {
8
9 function testGetDocumentType() {
10
11 $doc = new MockDocument();
12 $this->assertEquals(Document::UNKNOWN, $doc->getDocumentType());
13
14 }
15
16 function testConstruct() {
17
18 $doc = new MockDocument('VLIST');
19 $this->assertEquals('VLIST', $doc->name);
20
21 }
22
24
25 $vcal = new Component\VCalendar([], false);
26
27 $event = $vcal->createComponent('VEVENT');
28
29 $this->assertInstanceOf('Sabre\VObject\Component\VEvent', $event);
30 $vcal->add($event);
31
32 $prop = $vcal->createProperty('X-PROP', '1234256', ['X-PARAM' => '3']);
33 $this->assertInstanceOf('Sabre\VObject\Property', $prop);
34
35 $event->add($prop);
36
37 unset(
38 $event->DTSTAMP,
39 $event->UID
40 );
41
42 $out = $vcal->serialize();
43 $this->assertEquals("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nX-PROP;X-PARAM=3:1234256\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", $out);
44
45 }
46
47 function testCreate() {
48
49 $vcal = new Component\VCalendar([], false);
50
51 $event = $vcal->create('VEVENT');
52 $this->assertInstanceOf('Sabre\VObject\Component\VEvent', $event);
53
54 $prop = $vcal->create('CALSCALE');
55 $this->assertInstanceOf('Sabre\VObject\Property\Text', $prop);
56
57 }
58
60
61 $vcal = new Component\VCalendar([], false);
62 $this->assertEquals('Sabre\\VObject\\Property\\Text', $vcal->getClassNameForPropertyValue('TEXT'));
63 $this->assertNull($vcal->getClassNameForPropertyValue('FOO'));
64
65 }
66
67 function testDestroy() {
68
69 $vcal = new Component\VCalendar([], false);
70 $event = $vcal->createComponent('VEVENT');
71
72 $this->assertInstanceOf('Sabre\VObject\Component\VEvent', $event);
73 $vcal->add($event);
74
75 $prop = $vcal->createProperty('X-PROP', '1234256', ['X-PARAM' => '3']);
76
77 $event->add($prop);
78
79 $this->assertEquals($event, $prop->parent);
80
81 $vcal->destroy();
82
83 $this->assertNull($prop->parent);
84
85
86 }
87
88}
89
90
91class MockDocument extends Document {
92
93}
An exception for terminatinating execution or to throw for unit testing.
const UNKNOWN
Unknown document type.
Definition: Document.php:24