コード例 #1
0
$geo->push(new Geo(46.952585, 7.43766));
$c->setGPSpos($geo);
$bd = new cDateTime(1980, 8, 1);
$c->setBDay($bd);
$vcs = new vectorcs();
$vcs->push(new CustomProperty("initials", "KF"));
$c->setCustomProperties($vcs);
$xml = kolabformat::writeContact($c);
#print $xml;
assertcontains($xml, "<uid><uri>urn:uuid:", "Generate Contact UID as urn::uuid");
assertcontains($xml, "<n><surname>Surname</surname><given>Given</given><additional>Middle1</additional><additional>Middle2</additional><prefix>Prefix</prefix></n>", "Contact::setNameComponents()");
assertcontains($xml, "<title><text>MyProfession</text></title>", "Contact::setTitles()");
assertcontains($xml, "<photo><uri>data:image/gif;base64,{$pic}</uri></photo>", "Contact::setPhoto()");
assertcontains($xml, "<bday><date>19800801</date></bday>", "Contact::setBDay()");
assertcontains($xml, "<geo><uri>geo:46.952585,7.43766</uri></geo>", "Contact::setGPSpos()");
$c1 = kolabformat::readContact($xml, false);
assertequal($xml, kolabformat::writeContact($c1), "kolabformat::readContact() => kolabformat::writeContact()");
assertequal($c1->photoMimetype(), "image/gif", "Contact::photoMimetype()");
assertequal($c1->uid(), kolabformat::getSerializedUID(), "kolabformat::getSerializedUID()");
$lm = $c1->lastModified();
assertequal(sprintf('%d-%02d-%02d', $lm->year(), $lm->month(), $lm->day()), gmdate('Y-m-d'), "Contact::lastModified()");
$c1->setBDay(new cDateTime());
$xml = kolabformat::writeContact($c);
assertfalse(strpos($xml, '<bday><date>'), "Unset BDay with empty cDateTime");
/////// Test DistList
$dl = new DistList();
$dl->setName("DalistÄÖŸ");
$m = new vectorcontactref();
$a = new ContactReference(ContactReference::EmailReference, "a@localhost", "Member-A");
$m->push($a);
$b = new ContactReference(ContactReference::UidReference, "x-member-b-fff");