ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
InviteReplyTest.php
Go to the documentation of this file.
1<?php
2
4
5use Sabre\DAV;
7
9
15 function testSerializers($notification, $expected) {
16
17 $notification = new InviteReply($notification);
18
19 $this->assertEquals('foo', $notification->getId());
20 $this->assertEquals('"1"', $notification->getETag());
21
22 $simpleExpected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:invite-reply/></cs:root>';
23
24 $writer = new Writer();
25 $writer->namespaceMap = [
26 'http://calendarserver.org/ns/' => 'cs',
27 ];
28 $writer->openMemory();
29 $writer->startDocument('1.0', 'UTF-8');
30 $writer->startElement('{http://calendarserver.org/ns/}root');
31 $writer->write($notification);
32 $writer->endElement();
33
34 $this->assertEquals($simpleExpected, $writer->outputMemory());
35
36 $writer = new Writer();
37 $writer->contextUri = '/';
38 $writer->namespaceMap = [
39 'http://calendarserver.org/ns/' => 'cs',
40 'DAV:' => 'd',
41 ];
42 $writer->openMemory();
43 $writer->startDocument('1.0', 'UTF-8');
44 $writer->startElement('{http://calendarserver.org/ns/}root');
45 $notification->xmlSerializeFull($writer);
46 $writer->endElement();
47
48 $this->assertXmlStringEqualsXmlString($expected, $writer->outputMemory());
49
50
51 }
52
53 function dataProvider() {
54
55 $dtStamp = new \DateTime('2012-01-01 00:00:00 GMT');
56 return [
57 [
58 [
59 'id' => 'foo',
60 'dtStamp' => $dtStamp,
61 'etag' => '"1"',
62 'inReplyTo' => 'bar',
63 'href' => 'mailto:foo@example.org',
65 'hostUrl' => 'calendar'
66 ],
67<<<FOO
68<?xml version="1.0" encoding="UTF-8"?>
69<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:">
70 <cs:dtstamp>20120101T000000Z</cs:dtstamp>
71 <cs:invite-reply>
72 <cs:uid>foo</cs:uid>
73 <cs:in-reply-to>bar</cs:in-reply-to>
74 <d:href>mailto:foo@example.org</d:href>
75 <cs:invite-accepted/>
76 <cs:hosturl>
77 <d:href>/calendar</d:href>
78 </cs:hosturl>
79 </cs:invite-reply>
80</cs:root>
81
82FOO
83 ],
84 [
85 [
86 'id' => 'foo',
87 'dtStamp' => $dtStamp,
88 'etag' => '"1"',
89 'inReplyTo' => 'bar',
90 'href' => 'mailto:foo@example.org',
92 'hostUrl' => 'calendar',
93 'summary' => 'Summary!'
94 ],
95<<<FOO
96<?xml version="1.0" encoding="UTF-8"?>
97<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:">
98 <cs:dtstamp>20120101T000000Z</cs:dtstamp>
99 <cs:invite-reply>
100 <cs:uid>foo</cs:uid>
101 <cs:in-reply-to>bar</cs:in-reply-to>
102 <d:href>mailto:foo@example.org</d:href>
103 <cs:invite-declined/>
104 <cs:hosturl>
105 <d:href>/calendar</d:href>
106 </cs:hosturl>
107 <cs:summary>Summary!</cs:summary>
108 </cs:invite-reply>
109</cs:root>
110
111FOO
112 ],
113
114 ];
115
116 }
117
121 function testMissingArg() {
122
123 new InviteReply([]);
124
125 }
126
130 function testUnknownArg() {
131
132 new InviteReply([
133 'foo-i-will-break' => true,
134
135 'id' => 1,
136 'etag' => '"bla"',
137 'href' => 'abc',
138 'dtStamp' => 'def',
139 'inReplyTo' => 'qrs',
140 'type' => 'ghi',
141 'hostUrl' => 'jkl',
142 ]);
143
144 }
145
146}
An exception for terminatinating execution or to throw for unit testing.
testMissingArg()
@expectedException InvalidArgumentException
testUnknownArg()
@expectedException InvalidArgumentException
This class represents the cs:invite-reply notification element.
Definition: InviteReply.php:17
iCalendar/vCard/jCal/jCard/xCal/xCard writer object.
Definition: Writer.php:17
The XML Writer class.
Definition: Writer.php:31