1 | <?php |
||
10 | class ChatTest extends \PHPUnit_Framework_TestCase { |
||
11 | |||
12 | public function setUp(){ |
||
52 | |||
53 | public function contactsProvider() { |
||
54 | return array( |
||
55 | array( |
||
56 | array( |
||
57 | 'foo' |
||
58 | ), |
||
59 | array( |
||
60 | 0 => array( |
||
61 | 'id' => 'foo', |
||
62 | 'FN' => 'foo', |
||
63 | 'EMAIL' => array(), |
||
64 | 'IMPP' => array( |
||
65 | 0 => 'x-owncloud-handle:foo', |
||
66 | ), |
||
67 | 'addressbook-key' => 'local', |
||
68 | ), |
||
69 | 1 => array( |
||
70 | 'id' => 'bar', |
||
71 | 'FN' => 'bar', |
||
72 | 'EMAIL' => array(), |
||
73 | 'IMPP' => array( |
||
74 | 0 => 'x-owncloud-handle:bar', |
||
75 | ), |
||
76 | 'addressbook-key' => 'local', |
||
77 | ), |
||
78 | 2 => array( |
||
79 | 'id' => '1', |
||
80 | 'N' => array( |
||
81 | 0 => '', |
||
82 | 1 => 'TestContact', |
||
83 | 2 => '', |
||
84 | 3 => '', |
||
85 | 4 => '', |
||
86 | ), |
||
87 | 'UID' => '1a2a30d7-4907-4d5c-8e4a-3e51cf89e55a@localhost', |
||
88 | 'FN' => 'TestContact', |
||
89 | 'addressbook-key' => 'local:1', |
||
90 | ) |
||
91 | ), |
||
92 | array( |
||
93 | 'contacts' => |
||
94 | array( |
||
95 | 0 => |
||
96 | array( |
||
97 | 'id' => 'foo', |
||
98 | 'online' => true, |
||
99 | 'displayname' => 'foo', |
||
100 | 'order' => 1, |
||
101 | 'saved' => true, |
||
102 | 'backends' => |
||
103 | array( |
||
104 | 0 => |
||
105 | array( |
||
106 | 'id' => 'email', |
||
107 | 'displayname' => 'E-mail', |
||
108 | 'protocol' => 'email', |
||
109 | 'namespace' => ' email', |
||
110 | 'value' => |
||
111 | array( |
||
112 | 0 => |
||
113 | array(), |
||
114 | ), |
||
115 | ), |
||
116 | 1 => |
||
117 | array( |
||
118 | 'id' => 'och', |
||
119 | 'displayname' => 'ownCloud Chat', |
||
120 | 'protocol' => 'x-owncloud-handle', |
||
121 | 'namespace' => 'och', |
||
122 | 'value' => 'foo', |
||
123 | ), |
||
124 | ), |
||
125 | 'address_book_id' => '', |
||
126 | 'address_book_backend' => 'local', |
||
127 | ), |
||
128 | 1 => |
||
129 | array( |
||
130 | 'id' => 'bar', |
||
131 | 'online' => false, |
||
132 | 'displayname' => 'bar', |
||
133 | 'order' => 2, |
||
134 | 'saved' => true, |
||
135 | 'backends' => |
||
136 | array( |
||
137 | 0 => |
||
138 | array( |
||
139 | 'id' => 'email', |
||
140 | 'displayname' => 'E-mail', |
||
141 | 'protocol' => 'email', |
||
142 | 'namespace' => ' email', |
||
143 | 'value' => |
||
144 | array( |
||
145 | 0 => |
||
146 | array(), |
||
147 | ), |
||
148 | ), |
||
149 | 1 => |
||
150 | array( |
||
151 | 'id' => 'och', |
||
152 | 'displayname' => 'ownCloud Chat', |
||
153 | 'protocol' => 'x-owncloud-handle', |
||
154 | 'namespace' => 'och', |
||
155 | 'value' => 'bar', |
||
156 | ), |
||
157 | ), |
||
158 | 'address_book_id' => '', |
||
159 | 'address_book_backend' => 'local', |
||
160 | ), |
||
161 | 2 => |
||
162 | array( |
||
163 | 'id' => '1', |
||
164 | 'online' => false, |
||
165 | 'displayname' => 'TestContact', |
||
166 | 'order' => 3, |
||
167 | 'saved' => true, |
||
168 | 'backends' => |
||
169 | array( |
||
170 | 0 => |
||
171 | array( |
||
172 | 'id' => 'email', |
||
173 | 'displayname' => 'E-mail', |
||
174 | 'protocol' => 'email', |
||
175 | 'namespace' => ' email', |
||
176 | 'value' => |
||
177 | array( |
||
178 | 0 => |
||
179 | array(), |
||
180 | ), |
||
181 | ), |
||
182 | ), |
||
183 | 'address_book_id' => '1', |
||
184 | 'address_book_backend' => 'local', |
||
185 | ), |
||
186 | ), |
||
187 | 'contactsList' => |
||
188 | array( |
||
189 | 0 => 'foo', |
||
190 | 1 => 'bar', |
||
191 | 2 => '1', |
||
192 | ), |
||
193 | 'contactsObj' => |
||
194 | array( |
||
195 | 'foo' => |
||
196 | array( |
||
197 | 'id' => 'foo', |
||
198 | 'online' => true, |
||
199 | 'displayname' => 'foo', |
||
200 | 'order' => 1, |
||
201 | 'saved' => true, |
||
202 | 'backends' => |
||
203 | array( |
||
204 | 0 => |
||
205 | array( |
||
206 | 'id' => 'email', |
||
207 | 'displayname' => 'E-mail', |
||
208 | 'protocol' => 'email', |
||
209 | 'namespace' => ' email', |
||
210 | 'value' => |
||
211 | array( |
||
212 | 0 => |
||
213 | array(), |
||
214 | ), |
||
215 | ), |
||
216 | 1 => |
||
217 | array( |
||
218 | 'id' => 'och', |
||
219 | 'displayname' => 'ownCloud Chat', |
||
220 | 'protocol' => 'x-owncloud-handle', |
||
221 | 'namespace' => 'och', |
||
222 | 'value' => 'foo', |
||
223 | ), |
||
224 | ), |
||
225 | 'address_book_id' => '', |
||
226 | 'address_book_backend' => 'local', |
||
227 | ), |
||
228 | 'bar' => |
||
229 | array( |
||
230 | 'id' => 'bar', |
||
231 | 'online' => false, |
||
232 | 'displayname' => 'bar', |
||
233 | 'order' => 2, |
||
234 | 'saved' => true, |
||
235 | 'backends' => |
||
236 | array( |
||
237 | 0 => |
||
238 | array( |
||
239 | 'id' => 'email', |
||
240 | 'displayname' => 'E-mail', |
||
241 | 'protocol' => 'email', |
||
242 | 'namespace' => ' email', |
||
243 | 'value' => |
||
244 | array( |
||
245 | 0 => |
||
246 | array(), |
||
247 | ), |
||
248 | ), |
||
249 | 1 => |
||
250 | array( |
||
251 | 'id' => 'och', |
||
252 | 'displayname' => 'ownCloud Chat', |
||
253 | 'protocol' => 'x-owncloud-handle', |
||
254 | 'namespace' => 'och', |
||
255 | 'value' => 'bar', |
||
256 | ), |
||
257 | ), |
||
258 | 'address_book_id' => '', |
||
259 | 'address_book_backend' => 'local', |
||
260 | ), |
||
261 | 1 => |
||
262 | array( |
||
263 | 'id' => '1', |
||
264 | 'online' => false, |
||
265 | 'displayname' => 'TestContact', |
||
266 | 'order' => 3, |
||
267 | 'saved' => true, |
||
268 | 'backends' => |
||
269 | array( |
||
270 | 0 => |
||
271 | array( |
||
272 | 'id' => 'email', |
||
273 | 'displayname' => 'E-mail', |
||
274 | 'protocol' => 'email', |
||
275 | 'namespace' => ' email', |
||
276 | 'value' => |
||
277 | array( |
||
278 | 0 => |
||
279 | array(), |
||
280 | ), |
||
281 | ), |
||
282 | ), |
||
283 | 'address_book_id' => '1', |
||
284 | 'address_book_backend' => 'local', |
||
285 | ), |
||
286 | ), |
||
287 | ) |
||
288 | ) |
||
289 | ); |
||
290 | } |
||
291 | |||
292 | /** |
||
293 | * @dataProvider contactsProvider |
||
294 | */ |
||
295 | public function testGetContacts($onlineUsers, $rawContacts, $parsedContacts) { |
||
319 | |||
320 | |||
321 | /** |
||
322 | * This test will run after the testGetContacts method |
||
323 | * This test will test if the cache is used instead of re-fetching the contacts information |
||
324 | * |
||
325 | * @depends testGetContacts |
||
326 | * @dataProvider contactsProvider |
||
327 | // */ |
||
328 | public function testGetContactsCache($onlineUsers, $rawContacts, $parsedContacts) { |
||
335 | |||
336 | |||
337 | public function testGetBackends() { |
||
348 | |||
349 | |||
350 | public function userContactProvider() { |
||
351 | return array( |
||
352 | array( |
||
353 | array( |
||
354 | 0 => array( |
||
355 | 'id' => 'foo', |
||
356 | 'FN' => 'foo', |
||
357 | 'EMAIL' => array(), |
||
358 | 'IMPP' => array( |
||
359 | 0 => 'x-owncloud-handle:foo', |
||
360 | ), |
||
361 | 'addressbook-key' => 'local', |
||
362 | ), |
||
363 | 1 => array( |
||
364 | 'id' => 'bar', |
||
365 | 'FN' => 'bar', |
||
366 | 'EMAIL' => array(), |
||
367 | 'IMPP' => array( |
||
368 | 0 => 'x-owncloud-handle:bar', |
||
369 | ), |
||
370 | 'addressbook-key' => 'local', |
||
371 | ), |
||
372 | 2 => array( |
||
373 | 'id' => '1', |
||
374 | 'N' => array( |
||
375 | 0 => '', |
||
376 | 1 => 'TestContact', |
||
377 | 2 => '', |
||
378 | 3 => '', |
||
379 | 4 => '', |
||
380 | ), |
||
381 | 'UID' => '1a2a30d7-4907-4d5c-8e4a-3e51cf89e55a@localhost', |
||
382 | 'FN' => 'TestContact', |
||
383 | 'addressbook-key' => 'local:1', |
||
384 | ) |
||
385 | ), |
||
386 | array( |
||
387 | 'online' => 1, |
||
388 | 'order' => 1, |
||
389 | 'saved' => 1, |
||
390 | 'id' => 'foo', |
||
391 | 'displayname' => 'foo', |
||
392 | 'backends' => |
||
393 | array( |
||
394 | 0 => |
||
395 | array( |
||
396 | 'id' => 'email', |
||
397 | 'displayname' => 'E-mail', |
||
398 | 'protocol' => 'email', |
||
399 | 'namespace' => ' email', |
||
400 | 'value' => |
||
401 | array( |
||
402 | 0 => |
||
403 | array(), |
||
404 | ), |
||
405 | ), |
||
406 | 1 => |
||
407 | array( |
||
408 | 'id' => 'och', |
||
409 | 'displayname' => 'ownCloud Chat', |
||
410 | 'protocol' => 'x-owncloud-handle', |
||
411 | 'namespace' => 'och', |
||
412 | 'value' => 'foo', |
||
413 | ), |
||
414 | ), |
||
415 | 'address_book_id' => '', |
||
416 | 'address_book_backend' => 'local', |
||
417 | ), |
||
418 | 'foo' |
||
419 | ) |
||
420 | ); |
||
421 | } |
||
422 | |||
423 | /** |
||
424 | * @dataProvider userContactProvider |
||
425 | */ |
||
426 | public function testGetUserasContact($rawContacts, $expectedResult, $UID) { |
||
438 | |||
439 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: