ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
JCardTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\VObject;
4
5use PHPUnit\Framework\TestCase;
6
7class JCardTest extends TestCase {
8
9 function testToJCard() {
10
11 $card = new Component\VCard([
12 "VERSION" => "4.0",
13 "UID" => "foo",
14 "BDAY" => "19850407",
15 "REV" => "19951031T222710Z",
16 "LANG" => "nl",
17 "N" => ["Last", "First", "Middle", "", ""],
18 "item1.TEL" => "+1 555 123456",
19 "item1.X-AB-LABEL" => "Walkie Talkie",
20 "ADR" => [
21 "",
22 "",
23 ["My Street", "Left Side", "Second Shack"],
24 "Hometown",
25 "PA",
26 "18252",
27 "U.S.A",
28 ],
29 ]);
30
31 $card->add('BDAY', '1979-12-25', ['VALUE' => 'DATE', 'X-PARAM' => [1, 2]]);
32 $card->add('BDAY', '1979-12-25T02:00:00', ['VALUE' => 'DATE-TIME']);
33
34
35 $card->add('X-TRUNCATED', '--1225', ['VALUE' => 'DATE']);
36 $card->add('X-TIME-LOCAL', '123000', ['VALUE' => 'TIME']);
37 $card->add('X-TIME-UTC', '12:30:00Z', ['VALUE' => 'TIME']);
38 $card->add('X-TIME-OFFSET', '12:30:00-08:00', ['VALUE' => 'TIME']);
39 $card->add('X-TIME-REDUCED', '23', ['VALUE' => 'TIME']);
40 $card->add('X-TIME-TRUNCATED', '--30', ['VALUE' => 'TIME']);
41
42 $card->add('X-KARMA-POINTS', '42', ['VALUE' => 'INTEGER']);
43 $card->add('X-GRADE', '1.3', ['VALUE' => 'FLOAT']);
44
45 $card->add('TZ', '-0500', ['VALUE' => 'UTC-OFFSET']);
46
47 $expected = [
48 "vcard",
49 [
50 [
51 "version",
52 new \StdClass(),
53 "text",
54 "4.0"
55 ],
56 [
57 "prodid",
58 new \StdClass(),
59 "text",
60 "-//Sabre//Sabre VObject " . Version::VERSION . "//EN",
61 ],
62 [
63 "uid",
64 new \StdClass(),
65 "text",
66 "foo",
67 ],
68 [
69 "bday",
70 new \StdClass(),
71 "date-and-or-time",
72 "1985-04-07",
73 ],
74 [
75 "bday",
76 (object)[
77 'x-param' => [1,2],
78 ],
79 "date",
80 "1979-12-25",
81 ],
82 [
83 "bday",
84 new \StdClass(),
85 "date-time",
86 "1979-12-25T02:00:00",
87 ],
88 [
89 "rev",
90 new \StdClass(),
91 "timestamp",
92 "1995-10-31T22:27:10Z",
93 ],
94 [
95 "lang",
96 new \StdClass(),
97 "language-tag",
98 "nl",
99 ],
100 [
101 "n",
102 new \StdClass(),
103 "text",
104 ["Last", "First", "Middle", "", ""],
105 ],
106 [
107 "tel",
108 (object)[
109 "group" => "item1",
110 ],
111 "text",
112 "+1 555 123456",
113 ],
114 [
115 "x-ab-label",
116 (object)[
117 "group" => "item1",
118 ],
119 "unknown",
120 "Walkie Talkie",
121 ],
122 [
123 "adr",
124 new \StdClass(),
125 "text",
126 [
127 "",
128 "",
129 ["My Street", "Left Side", "Second Shack"],
130 "Hometown",
131 "PA",
132 "18252",
133 "U.S.A",
134 ],
135 ],
136 [
137 "x-truncated",
138 new \StdClass(),
139 "date",
140 "--12-25",
141 ],
142 [
143 "x-time-local",
144 new \StdClass(),
145 "time",
146 "12:30:00"
147 ],
148 [
149 "x-time-utc",
150 new \StdClass(),
151 "time",
152 "12:30:00Z"
153 ],
154 [
155 "x-time-offset",
156 new \StdClass(),
157 "time",
158 "12:30:00-08:00"
159 ],
160 [
161 "x-time-reduced",
162 new \StdClass(),
163 "time",
164 "23"
165 ],
166 [
167 "x-time-truncated",
168 new \StdClass(),
169 "time",
170 "--30"
171 ],
172 [
173 "x-karma-points",
174 new \StdClass(),
175 "integer",
176 42
177 ],
178 [
179 "x-grade",
180 new \StdClass(),
181 "float",
182 1.3
183 ],
184 [
185 "tz",
186 new \StdClass(),
187 "utc-offset",
188 "-05:00",
189 ],
190 ],
191 ];
192
193 $this->assertEquals($expected, $card->jsonSerialize());
194
195 }
196
197}
An exception for terminatinating execution or to throw for unit testing.
const VERSION
Full version number.
Definition: Version.php:17