21 $warnMsg[] = $warning[
'message'];
24 $this->assertEquals($expectedWarnings, $warnMsg);
29 $expectedRepairedOutput,
41 "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nUID:foo\r\nEND:VCARD\r\n",
43 "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nUID:foo\r\nEND:VCARD\r\n",
48 "BEGIN:VCARD\r\nFN:John Doe\r\nUID:foo\r\nEND:VCARD\r\n",
50 'VERSION MUST appear exactly once in a VCARD component',
52 "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nUID:foo\r\nEND:VCARD\r\n",
57 "BEGIN:VCARD\r\nVERSION:2.2\r\nFN:John Doe\r\nUID:foo\r\nEND:VCARD\r\n",
59 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.',
61 "BEGIN:VCARD\r\nVERSION:2.1\r\nFN:John Doe\r\nUID:foo\r\nEND:VCARD\r\n",
66 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nEND:VCARD\r\n",
68 'The FN property must appear in the VCARD component exactly 1 time',
70 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nEND:VCARD\r\n",
74 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nN:Doe;John;;;;;\r\nEND:VCARD\r\n",
76 'The FN property must appear in the VCARD component exactly 1 time',
78 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nN:Doe;John;;;;;\r\nFN:John Doe\r\nEND:VCARD\r\n",
82 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nN:Doe;;;;;;\r\nEND:VCARD\r\n",
84 'The FN property must appear in the VCARD component exactly 1 time',
86 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nN:Doe;;;;;;\r\nFN:Doe\r\nEND:VCARD\r\n",
90 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nORG:Acme Co.\r\nEND:VCARD\r\n",
92 'The FN property must appear in the VCARD component exactly 1 time',
94 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nORG:Acme Co.\r\nFN:Acme Co.\r\nEND:VCARD\r\n",
98 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nEMAIL:1@example.org\r\nEND:VCARD\r\n",
100 'The FN property must appear in the VCARD component exactly 1 time',
102 "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nEMAIL:1@example.org\r\nFN:1@example.org\r\nEND:VCARD\r\n",
110 $vcard =
new VCard([],
false);
111 $vcard->VERSION =
'2.1';
114 $vcard =
new VCard([],
false);
115 $vcard->VERSION =
'3.0';
118 $vcard =
new VCard([],
false);
119 $vcard->VERSION =
'4.0';
122 $vcard =
new VCard([],
false);
130 EMAIL;TYPE=home:1@example.org
131 EMAIL;TYPE=work:2@example.org
136 $this->assertEquals(
'1@example.org', $vcard->getByType(
'EMAIL',
'home')->getValue());
137 $this->assertEquals(
'2@example.org', $vcard->getByType(
'EMAIL',
'work')->getValue());
138 $this->assertNull($vcard->getByType(
'EMAIL',
'non-existant'));
139 $this->assertNull($vcard->getByType(
'ADR',
'non-existant'));
153 $this->assertEquals(
'1@example.org', $vcard->preferred(
'EMAIL')->getValue());
163 EMAIL;TYPE=PREF:2@example.org
168 $this->assertEquals(
'2@example.org', $vcard->preferred(
'EMAIL')->getValue());
178 EMAIL;PREF=3:2@example.org
179 EMAIL;PREF=2:3@example.org
184 $this->assertEquals(
'3@example.org', $vcard->preferred(
'EMAIL')->getValue());
197 $this->assertNull($vcard->preferred(
'EMAIL'));
211 VCARD::PROFILE_CARDDAV,
213 'vCards on CardDAV servers MUST have a UID property.' 230 'Adding a UID to a vCard property is recommended.' 246 'Adding a UID to a vCard property is recommended.' 262 VCARD::PROFILE_CARDDAV,
264 'CardDAV servers are not allowed to accept vCard 2.1.' 302 if ($expectedLevel === 0) {
303 $this->assertEquals(0,
count(
$input),
'No validation messages were expected. We got: ' . implode(
', ',
$messages));
305 $this->assertEquals(1,
count(
$input),
'We expected exactly 1 validation message, We got: ' . implode(
', ',
$messages));
307 $this->assertEquals($expectedMessage,
$input[0][
'message']);
308 $this->assertEquals($expectedLevel,
$input[0][
'level']);
testPreferredWith40Pref()
assertValidateResult($input, $expectedLevel, $expectedMessage=null)
const UNKNOWN
Unknown document type.
testNoUIDNoCardDAVRepair()
const REPAIR
The following constants are used by the validate() method.
count()
Returns the number of elements.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
testValidate($input, $expectedWarnings, $expectedRepairedOutput)
validateData
assertValidate($vcf, $options, $expectedLevel, $expectedMessage=null)