annotate vendor/sabre/vobject/tests/VObject/JCardTest.php @ 41:d2414df68d78 default tip

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