Revision: 18641 http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18641 Author: johang Date: 2008-07-06 18:08:31 +0000 (Sun, 06 Jul 2008)
Log Message: ----------- * Make addressbook handle text/vcard too. * More and better tests. Modified Paths: -------------- trunk/addressbook/inc/class.ipc_addressbook.inc.php trunk/addressbook/test/class.ipc_addressbook_test.inc.php Modified: trunk/addressbook/inc/class.ipc_addressbook.inc.php =================================================================== --- trunk/addressbook/inc/class.ipc_addressbook.inc.php 2008-07-05 21:09:56 UTC (rev 18640) +++ trunk/addressbook/inc/class.ipc_addressbook.inc.php 2008-07-06 18:08:31 UTC (rev 18641) @@ -54,9 +54,14 @@ */ function addData($data, $type) { - // 1: mapping the mime type to application data - if($type != 'text/x-vcard') - return false; + switch($type) + { + case 'text/x-vcard': + case 'text/vcard': + break; + default: + return false; + } $data_lines = preg_split("/[\r\n]+/", $data); @@ -122,9 +127,13 @@ */ function getData($id, $type) { - if($type != 'text/x-vcard') + switch($type) { - return false; + case 'text/x-vcard': + case 'text/vcard': + break; + default: + return false; } if(!$this->contacts->check_read($id)) Modified: trunk/addressbook/test/class.ipc_addressbook_test.inc.php =================================================================== --- trunk/addressbook/test/class.ipc_addressbook_test.inc.php 2008-07-05 21:09:56 UTC (rev 18640) +++ trunk/addressbook/test/class.ipc_addressbook_test.inc.php 2008-07-06 18:08:31 UTC (rev 18641) @@ -92,6 +92,7 @@ $this->assertTrue($id); $data = $this->ipc->getData($id, 'text/x-vcard'); + $this->assertTrue(is_string($data)); } @@ -114,15 +115,18 @@ $now = time(); $this->assertEqual($this->ipc->getIdlist($now + 10), array()); + $this->assertEqual($this->ipc->getIdlist($now), array()); $this->assertEqual($this->ipc->getIdlist($now - 10), array()); $a = $this->ipc->addData($this->sample_vcard, 'text/x-vcard'); $id_list_plus10 = $this->ipc->getIdlist($now + 10); + $id_list_now = $this->ipc->getIdlist($now); $id_list_minus10 = $this->ipc->getIdlist($now - 10); + $this->assertEqual($id_list_plus10, array()); + $this->assertEqual($id_list_now, array()); $this->assertEqual($id_list_minus10, array($a)); - $this->assertEqual($id_list_plus10, array()); } function test_removeData() @@ -169,5 +173,22 @@ $this->assertFalse($this->ipc->existData($id)); } + + function test_add_STCS_vcard() + { + $x = 'BEGIN:VCARD +VERSION:3.0 +N:SCTS;41215365832 +FN:SCTS41215365832 +TEL;TYPE=WORK,VOICE,MSG:1215365832 +END:VCARD'; + + $id = $this->ipc->addData($x, 'text/vcard'); + $this->assertTrue($id); + + $data = $this->ipc->getData($id, 'text/vcard'); + + $this->assertTrue(is_string($data)); + } } ?> _______________________________________________ phpGroupWare-cvs mailing list phpGroupWare-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/phpgroupware-cvs