ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
InviteTest.php
Go to the documentation of this file.
1<?php
2
4
6use Sabre\DAV;
8
10
16 function testSerializers($notification, $expected) {
17
18 $notification = new Invite($notification);
19
20 $this->assertEquals('foo', $notification->getId());
21 $this->assertEquals('"1"', $notification->getETag());
22
23 $simpleExpected = '<cs:invite-notification xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" />' . "\n";
24 $this->namespaceMap['http://calendarserver.org/ns/'] = 'cs';
25
26 $xml = $this->write($notification);
27
28 $this->assertXmlStringEqualsXmlString($simpleExpected, $xml);
29
30 $this->namespaceMap['urn:ietf:params:xml:ns:caldav'] = 'cal';
31 $xml = $this->writeFull($notification);
32
33 $this->assertXmlStringEqualsXmlString($expected, $xml);
34
35
36 }
37
38 function dataProvider() {
39
40 $dtStamp = new \DateTime('2012-01-01 00:00:00', new \DateTimeZone('GMT'));
41 return [
42 [
43 [
44 'id' => 'foo',
45 'dtStamp' => $dtStamp,
46 'etag' => '"1"',
47 'href' => 'mailto:foo@example.org',
49 'readOnly' => true,
50 'hostUrl' => 'calendar',
51 'organizer' => 'principal/user1',
52 'commonName' => 'John Doe',
53 'summary' => 'Awesome stuff!'
54 ],
55<<<FOO
56<?xml version="1.0" encoding="UTF-8"?>
57<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav">
58 <cs:dtstamp>20120101T000000Z</cs:dtstamp>
59 <cs:invite-notification>
60 <cs:uid>foo</cs:uid>
61 <d:href>mailto:foo@example.org</d:href>
62 <cs:invite-accepted/>
63 <cs:hosturl>
64 <d:href>/calendar</d:href>
65 </cs:hosturl>
66 <cs:summary>Awesome stuff!</cs:summary>
67 <cs:access>
68 <cs:read/>
69 </cs:access>
70 <cs:organizer>
71 <d:href>/principal/user1</d:href>
72 <cs:common-name>John Doe</cs:common-name>
73 </cs:organizer>
74 <cs:organizer-cn>John Doe</cs:organizer-cn>
75 </cs:invite-notification>
76</cs:root>
77
78FOO
79 ],
80 [
81 [
82 'id' => 'foo',
83 'dtStamp' => $dtStamp,
84 'etag' => '"1"',
85 'href' => 'mailto:foo@example.org',
87 'readOnly' => true,
88 'hostUrl' => 'calendar',
89 'organizer' => 'principal/user1',
90 'firstName' => 'Foo',
91 'lastName' => 'Bar',
92 ],
93<<<FOO
94<?xml version="1.0" encoding="UTF-8"?>
95<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav">
96 <cs:dtstamp>20120101T000000Z</cs:dtstamp>
97 <cs:invite-notification>
98 <cs:uid>foo</cs:uid>
99 <d:href>mailto:foo@example.org</d:href>
100 <cs:invite-noresponse/>
101 <cs:hosturl>
102 <d:href>/calendar</d:href>
103 </cs:hosturl>
104 <cs:access>
105 <cs:read/>
106 </cs:access>
107 <cs:organizer>
108 <d:href>/principal/user1</d:href>
109 <cs:first-name>Foo</cs:first-name>
110 <cs:last-name>Bar</cs:last-name>
111 </cs:organizer>
112 <cs:organizer-first>Foo</cs:organizer-first>
113 <cs:organizer-last>Bar</cs:organizer-last>
114 </cs:invite-notification>
115</cs:root>
116
117FOO
118 ],
119
120 ];
121
122 }
123
127 function testMissingArg() {
128
129 new Invite([]);
130
131 }
132
136 function testUnknownArg() {
137
138 new Invite([
139 'foo-i-will-break' => true,
140
141 'id' => 1,
142 'etag' => '"bla"',
143 'href' => 'abc',
144 'dtStamp' => 'def',
145 'type' => 'ghi',
146 'readOnly' => true,
147 'hostUrl' => 'jkl',
148 'organizer' => 'mno',
149 ]);
150
151 }
152
153 function writeFull($input) {
154
155 $writer = new Writer();
156 $writer->contextUri = '/';
157 $writer->namespaceMap = $this->namespaceMap;
158 $writer->openMemory();
159 $writer->startElement('{http://calendarserver.org/ns/}root');
160 $input->xmlSerializeFull($writer);
161 $writer->endElement();
162 return $writer->outputMemory();
163
164 }
165}
An exception for terminatinating execution or to throw for unit testing.
testUnknownArg()
@expectedException InvalidArgumentException
Definition: InviteTest.php:136
testMissingArg()
@expectedException InvalidArgumentException
Definition: InviteTest.php:127
testSerializers($notification, $expected)
Definition: InviteTest.php:16
This class represents the cs:invite-notification notification element.
Definition: Invite.php:20
iCalendar/vCard/jCal/jCard/xCal/xCard writer object.
Definition: Writer.php:17
The XML Writer class.
Definition: Writer.php:31
notification()
Definition: notification.php:2