mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Added tests for upgrading vCards
This commit is contained in:
parent
1e6a9dcc64
commit
04ddf9eeb8
@ -68,7 +68,7 @@ class Test_Contacts_Backend_Datebase extends PHPUnit_Framework_TestCase {
|
||||
// Test contacts
|
||||
$this->assertEquals(array(), self::$backend->getContacts($aid));
|
||||
|
||||
$carddata = file_get_contents(__DIR__ . '/data/test.vcf');
|
||||
$carddata = file_get_contents(__DIR__ . '/data/test1.vcf');
|
||||
$id = self::$backend->createContact($aid, $carddata);
|
||||
$this->assertNotEquals(false, $id); // Isn't there an assertNotFalse() ?
|
||||
$this->assertEquals(1, count(self::$backend->getContacts($aid)));
|
||||
@ -119,4 +119,18 @@ class Test_Contacts_Backend_Datebase extends PHPUnit_Framework_TestCase {
|
||||
$this->assertTrue($addressBook->deleteChild($id));
|
||||
$this->assertEquals(0, count($addressBook));
|
||||
}
|
||||
|
||||
public function testCrappyVCard() {
|
||||
$carddata = file_get_contents(__DIR__ . '/data/test3.vcf');
|
||||
$obj = \Sabre\VObject\Reader::read(
|
||||
$carddata,
|
||||
\Sabre\VObject\Reader::OPTION_IGNORE_INVALID_LINES
|
||||
);
|
||||
$obj->validate($obj::REPAIR|$obj::UPGRADE);
|
||||
echo "\n" . $obj->serialize();
|
||||
|
||||
$this->assertEquals('3.0', (string)$obj->VERSION);
|
||||
$this->assertEquals('Adèle Fermée', (string)$obj->FN);
|
||||
$this->assertEquals('Fermée;Adèle;;;', (string)$obj->N);
|
||||
}
|
||||
}
|
||||
|
5
tests/data/test3.vcf
Normal file
5
tests/data/test3.vcf
Normal file
@ -0,0 +1,5 @@
|
||||
BEGIN:VCARD
|
||||
VERSION:2.1
|
||||
FN;QUOTED-PRINTABLE:Ad=C3=A8le=20Ferm=C3=A9e
|
||||
TEL;CELL;VOICE:+123456789
|
||||
END:VCARD
|
Loading…
x
Reference in New Issue
Block a user