1
0
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:
Thomas Tanghus 2013-05-15 22:56:52 +02:00
parent 1e6a9dcc64
commit 04ddf9eeb8
3 changed files with 20 additions and 1 deletions

View File

@ -68,7 +68,7 @@ class Test_Contacts_Backend_Datebase extends PHPUnit_Framework_TestCase {
// Test contacts // Test contacts
$this->assertEquals(array(), self::$backend->getContacts($aid)); $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); $id = self::$backend->createContact($aid, $carddata);
$this->assertNotEquals(false, $id); // Isn't there an assertNotFalse() ? $this->assertNotEquals(false, $id); // Isn't there an assertNotFalse() ?
$this->assertEquals(1, count(self::$backend->getContacts($aid))); $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->assertTrue($addressBook->deleteChild($id));
$this->assertEquals(0, count($addressBook)); $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
View 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