@@ -321,6 +321,9 @@ public function testVCard2Array() {
321321 $ property = $ vCard ->createProperty ('X-SOCIALPROFILE ' , 'tw-example ' );
322322 $ property ->add ('TYPE ' , 'twitter ' );
323323 $ vCard ->add ($ property );
324+ $ property = $ vCard ->createProperty ('X-SOCIALPROFILE ' , 'tw-example-2 ' );
325+ $ property ->add ('TYPE ' , 'twitter ' );
326+ $ vCard ->add ($ property );
324327 $ property = $ vCard ->createProperty ('X-SOCIALPROFILE ' , 'fb-example ' );
325328 $ property ->add ('TYPE ' , 'facebook ' );
326329 $ vCard ->add ($ property );
@@ -355,8 +358,88 @@ public function testVCard2Array() {
355358 ],
356359
357360 'X-SOCIALPROFILE ' => [
358- 'twitter ' => 'tw-example ' ,
359- 'facebook ' => 'fb-example ' ,
361+ 'tw-example ' ,
362+ 'tw-example-2 ' ,
363+ 'fb-example ' ,
364+ ],
365+
366+ 'isLocalSystemBook ' => true ,
367+ ], $ array );
368+ }
369+
370+ public function testVCard2ArrayWithTypes () {
371+ $ vCard = new VCard ();
372+
373+ $ vCard ->add ($ vCard ->createProperty ('FN ' , 'Full Name ' ));
374+
375+ // Multi-value properties
376+ $ vCard ->add ($ vCard ->createProperty ('CLOUD ' , 'cloud-user1@localhost ' ));
377+ $ vCard ->add ($ vCard ->createProperty ('CLOUD ' , 'cloud-user2@example.tld ' ));
378+
379+ $ property = $ vCard ->createProperty ('EMAIL ' , 'email-user1@localhost ' );
380+ $ property ->add ('TYPE ' , 'HOME ' );
381+ $ vCard ->add ($ property );
382+ $ property = $ vCard ->createProperty ('EMAIL ' , 'email-user2@example.tld ' );
383+ $ property ->add ('TYPE ' , 'WORK ' );
384+ $ vCard ->add ($ property );
385+
386+ $ vCard ->add ($ vCard ->createProperty ('IMPP ' , 'impp-user1@localhost ' ));
387+ $ vCard ->add ($ vCard ->createProperty ('IMPP ' , 'impp-user2@example.tld ' ));
388+
389+ $ property = $ vCard ->createProperty ('TEL ' , '+49 123456789 ' );
390+ $ property ->add ('TYPE ' , 'HOME,VOICE ' );
391+ $ vCard ->add ($ property );
392+ $ property = $ vCard ->createProperty ('TEL ' , '+1 555 123456789 ' );
393+ $ property ->add ('TYPE ' , 'WORK ' );
394+ $ vCard ->add ($ property );
395+
396+ $ vCard ->add ($ vCard ->createProperty ('URL ' , 'https://localhost ' ));
397+ $ vCard ->add ($ vCard ->createProperty ('URL ' , 'https://example.tld ' ));
398+
399+ // Type depending properties
400+ $ property = $ vCard ->createProperty ('X-SOCIALPROFILE ' , 'tw-example ' );
401+ $ property ->add ('TYPE ' , 'twitter ' );
402+ $ vCard ->add ($ property );
403+ $ property = $ vCard ->createProperty ('X-SOCIALPROFILE ' , 'tw-example-2 ' );
404+ $ property ->add ('TYPE ' , 'twitter ' );
405+ $ vCard ->add ($ property );
406+ $ property = $ vCard ->createProperty ('X-SOCIALPROFILE ' , 'fb-example ' );
407+ $ property ->add ('TYPE ' , 'facebook ' );
408+ $ vCard ->add ($ property );
409+
410+ $ array = $ this ->invokePrivate ($ this ->addressBookImpl , 'vCard2Array ' , ['uri ' , $ vCard , true ]);
411+ unset($ array ['PRODID ' ]);
412+ unset($ array ['UID ' ]);
413+
414+ $ this ->assertEquals ([
415+ 'URI ' => 'uri ' ,
416+ 'VERSION ' => '4.0 ' ,
417+ 'FN ' => 'Full Name ' ,
418+ 'CLOUD ' => [
419+ ['type ' => '' , 'value ' => 'cloud-user1@localhost ' ],
420+ ['type ' => '' , 'value ' => 'cloud-user2@example.tld ' ],
421+ ],
422+ 'EMAIL ' => [
423+ ['type ' => 'HOME ' , 'value ' => 'email-user1@localhost ' ],
424+ ['type ' => 'WORK ' , 'value ' => 'email-user2@example.tld ' ],
425+ ],
426+ 'IMPP ' => [
427+ ['type ' => '' , 'value ' => 'impp-user1@localhost ' ],
428+ ['type ' => '' , 'value ' => 'impp-user2@example.tld ' ],
429+ ],
430+ 'TEL ' => [
431+ ['type ' => 'HOME,VOICE ' , 'value ' => '+49 123456789 ' ],
432+ ['type ' => 'WORK ' , 'value ' => '+1 555 123456789 ' ],
433+ ],
434+ 'URL ' => [
435+ ['type ' => '' , 'value ' => 'https://localhost ' ],
436+ ['type ' => '' , 'value ' => 'https://example.tld ' ],
437+ ],
438+
439+ 'X-SOCIALPROFILE ' => [
440+ ['type ' => 'twitter ' , 'value ' => 'tw-example ' ],
441+ ['type ' => 'twitter ' , 'value ' => 'tw-example-2 ' ],
442+ ['type ' => 'facebook ' , 'value ' => 'fb-example ' ],
360443 ],
361444
362445 'isLocalSystemBook ' => true ,
0 commit comments