diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-04-17 10:12:06 +0300 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-04-17 10:38:47 +0300 |
commit | 29541322c1ce6eed2d43a93172fafcf22c0c54ff (patch) | |
tree | 9bf57330f98d777cb607941feac6c73dcd5cb5f0 /apps/dav/tests | |
parent | a8809f079b47f30e9fff5a8b7ffb4a7229de22a3 (diff) |
Update list of multiple properties
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/CardDAV/AddressBookImplTest.php | 87 |
1 files changed, 85 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php index e4e2d4aef8e..6bf77c1f49e 100644 --- a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php +++ b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php @@ -321,6 +321,9 @@ class AddressBookImplTest extends TestCase { $property = $vCard->createProperty('X-SOCIALPROFILE', 'tw-example'); $property->add('TYPE', 'twitter'); $vCard->add($property); + $property = $vCard->createProperty('X-SOCIALPROFILE', 'tw-example-2'); + $property->add('TYPE', 'twitter'); + $vCard->add($property); $property = $vCard->createProperty('X-SOCIALPROFILE', 'fb-example'); $property->add('TYPE', 'facebook'); $vCard->add($property); @@ -355,8 +358,88 @@ class AddressBookImplTest extends TestCase { ], 'X-SOCIALPROFILE' => [ - 'twitter'=> 'tw-example', - 'facebook'=> 'fb-example', + 'tw-example', + 'tw-example-2', + 'fb-example', + ], + + 'isLocalSystemBook' => true, + ], $array); + } + + public function testVCard2ArrayWithTypes() { + $vCard = new VCard(); + + $vCard->add($vCard->createProperty('FN', 'Full Name')); + + // Multi-value properties + $vCard->add($vCard->createProperty('CLOUD', 'cloud-user1@localhost')); + $vCard->add($vCard->createProperty('CLOUD', 'cloud-user2@example.tld')); + + $property = $vCard->createProperty('EMAIL', 'email-user1@localhost'); + $property->add('TYPE', 'HOME'); + $vCard->add($property); + $property = $vCard->createProperty('EMAIL', 'email-user2@example.tld'); + $property->add('TYPE', 'WORK'); + $vCard->add($property); + + $vCard->add($vCard->createProperty('IMPP', 'impp-user1@localhost')); + $vCard->add($vCard->createProperty('IMPP', 'impp-user2@example.tld')); + + $property = $vCard->createProperty('TEL', '+49 123456789'); + $property->add('TYPE', 'HOME,VOICE'); + $vCard->add($property); + $property = $vCard->createProperty('TEL', '+1 555 123456789'); + $property->add('TYPE', 'WORK'); + $vCard->add($property); + + $vCard->add($vCard->createProperty('URL', 'https://localhost')); + $vCard->add($vCard->createProperty('URL', 'https://example.tld')); + + // Type depending properties + $property = $vCard->createProperty('X-SOCIALPROFILE', 'tw-example'); + $property->add('TYPE', 'twitter'); + $vCard->add($property); + $property = $vCard->createProperty('X-SOCIALPROFILE', 'tw-example-2'); + $property->add('TYPE', 'twitter'); + $vCard->add($property); + $property = $vCard->createProperty('X-SOCIALPROFILE', 'fb-example'); + $property->add('TYPE', 'facebook'); + $vCard->add($property); + + $array = $this->invokePrivate($this->addressBookImpl, 'vCard2Array', ['uri', $vCard, true]); + unset($array['PRODID']); + unset($array['UID']); + + $this->assertEquals([ + 'URI' => 'uri', + 'VERSION' => '4.0', + 'FN' => 'Full Name', + 'CLOUD' => [ + ['type' => '', 'value' => 'cloud-user1@localhost'], + ['type' => '', 'value' => 'cloud-user2@example.tld'], + ], + 'EMAIL' => [ + ['type' => 'HOME', 'value' => 'email-user1@localhost'], + ['type' => 'WORK', 'value' => 'email-user2@example.tld'], + ], + 'IMPP' => [ + ['type' => '', 'value' => 'impp-user1@localhost'], + ['type' => '', 'value' => 'impp-user2@example.tld'], + ], + 'TEL' => [ + ['type' => 'HOME,VOICE', 'value' => '+49 123456789'], + ['type' => 'WORK', 'value' => '+1 555 123456789'], + ], + 'URL' => [ + ['type' => '', 'value' => 'https://localhost'], + ['type' => '', 'value' => 'https://example.tld'], + ], + + 'X-SOCIALPROFILE' => [ + ['type' => 'twitter', 'value' => 'tw-example'], + ['type' => 'twitter', 'value' => 'tw-example-2'], + ['type' => 'facebook', 'value' => 'fb-example'], ], 'isLocalSystemBook' => true, |