mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-09 09:58:49 +00:00
Second part of refactoring; should be runnable again, yet not thoroughly tested
This commit is contained in:
parent
b8234a1cb8
commit
6186153f68
88 changed files with 2135 additions and 1186 deletions
100
dav/sabre-vobject/tests/Sabre/VObject/Component/VCardTest.php
Normal file
100
dav/sabre-vobject/tests/Sabre/VObject/Component/VCardTest.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace Sabre\VObject\Component;
|
||||
|
||||
use Sabre\VObject;
|
||||
|
||||
class VCardTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* @dataProvider validateData
|
||||
*/
|
||||
function testValidate($input, $expectedWarnings, $expectedRepairedOutput) {
|
||||
|
||||
$vcard = VObject\Reader::read($input);
|
||||
|
||||
$warnings = $vcard->validate();
|
||||
|
||||
$warnMsg = array();
|
||||
foreach($warnings as $warning) {
|
||||
$warnMsg[] = $warning['message'];
|
||||
}
|
||||
|
||||
$this->assertEquals($expectedWarnings, $warnMsg);
|
||||
|
||||
$vcard->validate(VObject\Component::REPAIR);
|
||||
|
||||
$this->assertEquals(
|
||||
$expectedRepairedOutput,
|
||||
$vcard->serialize()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function validateData() {
|
||||
|
||||
$tests = array();
|
||||
|
||||
// Correct
|
||||
$tests[] = array(
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
|
||||
array(),
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
|
||||
);
|
||||
|
||||
// No VERSION
|
||||
$tests[] = array(
|
||||
"BEGIN:VCARD\r\nFN:John Doe\r\nEND:VCARD\r\n",
|
||||
array(
|
||||
'The VERSION property must appear in the VCARD component exactly 1 time',
|
||||
),
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
|
||||
);
|
||||
|
||||
// Unknown version
|
||||
$tests[] = array(
|
||||
"BEGIN:VCARD\r\nVERSION:2.2\r\nFN:John Doe\r\nEND:VCARD\r\n",
|
||||
array(
|
||||
'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.',
|
||||
),
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
|
||||
);
|
||||
|
||||
// No FN
|
||||
$tests[] = array(
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nEND:VCARD\r\n",
|
||||
array(
|
||||
'The FN property must appear in the VCARD component exactly 1 time',
|
||||
),
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nEND:VCARD\r\n",
|
||||
);
|
||||
// No FN, N fallback
|
||||
$tests[] = array(
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;John;;;;;\r\nEND:VCARD\r\n",
|
||||
array(
|
||||
'The FN property must appear in the VCARD component exactly 1 time',
|
||||
),
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;John;;;;;\r\nFN:John Doe\r\nEND:VCARD\r\n",
|
||||
);
|
||||
// No FN, N fallback, no first name
|
||||
$tests[] = array(
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;;;;;;\r\nEND:VCARD\r\n",
|
||||
array(
|
||||
'The FN property must appear in the VCARD component exactly 1 time',
|
||||
),
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;;;;;;\r\nFN:Doe\r\nEND:VCARD\r\n",
|
||||
);
|
||||
|
||||
// No FN, ORG fallback
|
||||
$tests[] = array(
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nORG:Acme Co.\r\nEND:VCARD\r\n",
|
||||
array(
|
||||
'The FN property must appear in the VCARD component exactly 1 time',
|
||||
),
|
||||
"BEGIN:VCARD\r\nVERSION:4.0\r\nORG:Acme Co.\r\nFN:Acme Co.\r\nEND:VCARD\r\n",
|
||||
);
|
||||
return $tests;
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue