3 namespace Sabre\VObject\Component;
7 class VCardTest extends \PHPUnit_Framework_TestCase {
10 * @dataProvider validateData
12 function testValidate($input, $expectedWarnings, $expectedRepairedOutput) {
14 $vcard = VObject\Reader::read($input);
16 $warnings = $vcard->validate();
19 foreach($warnings as $warning) {
20 $warnMsg[] = $warning['message'];
23 $this->assertEquals($expectedWarnings, $warnMsg);
25 $vcard->validate(VObject\Component::REPAIR);
28 $expectedRepairedOutput,
34 public function validateData() {
40 "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
42 "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
47 "BEGIN:VCARD\r\nFN:John Doe\r\nEND:VCARD\r\n",
49 'The VERSION property must appear in the VCARD component exactly 1 time',
51 "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
56 "BEGIN:VCARD\r\nVERSION:2.2\r\nFN:John Doe\r\nEND:VCARD\r\n",
58 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.',
60 "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
65 "BEGIN:VCARD\r\nVERSION:4.0\r\nEND:VCARD\r\n",
67 'The FN property must appear in the VCARD component exactly 1 time',
69 "BEGIN:VCARD\r\nVERSION:4.0\r\nEND:VCARD\r\n",
73 "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;John;;;;;\r\nEND:VCARD\r\n",
75 'The FN property must appear in the VCARD component exactly 1 time',
77 "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;John;;;;;\r\nFN:John Doe\r\nEND:VCARD\r\n",
79 // No FN, N fallback, no first name
81 "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;;;;;;\r\nEND:VCARD\r\n",
83 'The FN property must appear in the VCARD component exactly 1 time',
85 "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;;;;;;\r\nFN:Doe\r\nEND:VCARD\r\n",
88 // No FN, ORG fallback
90 "BEGIN:VCARD\r\nVERSION:4.0\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\nORG:Acme Co.\r\nFN:Acme Co.\r\nEND:VCARD\r\n",