annotate vendor/sabre/vobject/tests/VObject/DocumentTest.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1 <?php
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
3 namespace Sabre\VObject;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
4
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
5 class DocumentTest extends \PHPUnit_Framework_TestCase {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
7 function testGetDocumentType() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
8
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
9 $doc = new MockDocument();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
10 $this->assertEquals(Document::UNKNOWN, $doc->getDocumentType());
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
11
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
12 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
13
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
14 function testConstruct() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
15
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
16 $doc = new MockDocument('VLIST');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
17 $this->assertEquals('VLIST', $doc->name);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
18
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
19 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
20
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
21 function testCreateComponent() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
22
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
23 $vcal = new Component\VCalendar(array(), false);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
24
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
25 $event = $vcal->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
26
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
27 $this->assertInstanceOf('Sabre\VObject\Component\VEvent', $event);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
28 $vcal->add($event);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
29
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
30 $prop = $vcal->createProperty('X-PROP','1234256',array('X-PARAM' => '3'));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
31 $this->assertInstanceOf('Sabre\VObject\Property', $prop);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
32
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
33 $event->add($prop);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
34
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
35 unset(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
36 $event->DTSTAMP,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
37 $event->UID
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
38 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
39
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
40 $out = $vcal->serialize();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
41 $this->assertEquals("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nX-PROP;X-PARAM=3:1234256\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", $out);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
42
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
43 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
44
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
45 function testCreate() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
46
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
47 $vcal = new Component\VCalendar(array(), false);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
48
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
49 $event = $vcal->create('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
50 $this->assertInstanceOf('Sabre\VObject\Component\VEvent', $event);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
51
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
52 $event = $vcal->create('CALSCALE');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
53 $this->assertInstanceOf('Sabre\VObject\Property\Text', $event);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
54
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
55 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
56
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
57 function testGetClassNameForPropertyValue() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
58
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
59 $vcal = new Component\VCalendar(array(), false);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
60 $this->assertEquals('Sabre\\VObject\\Property\\Text', $vcal->getClassNameForPropertyValue('TEXT'));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
61 $this->assertNull($vcal->getClassNameForPropertyValue('FOO'));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
62
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
63 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
64
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
65 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
66
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
67
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
68 class MockDocument extends Document {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
69
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
70 }