コード例 #1
0
 public function setFromVCardLine(VCardLine $line)
 {
     $this->setBuilderFromLine($line);
     $this->setTypesFromLine($line);
     $this->setMediaTypeFromLine($line);
     if (($line->getVersion() === '3.0' || $line->getVersion() === '2.1') && $this->getValueType() !== 'uri') {
         $uri = new DataUri($this->getMediaType(), $line->getValue(), DataUri::ENCODING_BASE64);
         $this->setValue($uri->toString());
         $this->setMediaType(null);
     } else {
         $this->setValue(\stripcslashes($line->getValue()));
     }
     return $this;
 }
コード例 #2
0
ファイル: VCardDBTest.php プロジェクト: evought/vcard-tools
 /**
  * @group default
  * @depends testStoreAndRetrieveVCard
  */
 public function testStoreAndRetrieveWLogoDataMediaType(VCardDB $vcardDB)
 {
     $this->checkRowCounts(['CONTACT' => 0, 'CONTACT_ORG' => 0, 'CONTACT_DATA' => 0]);
     $expected = ['org_name' => 'Seinar Fleet Systems', 'org_unit1' => 'Seinar Advanced Projects Laboratory', 'org_unit2' => 'TIE AO1X Division', 'fn' => 'Seinar APL TIE AO1X Division', 'logo' => '|-0-|'];
     $vcard = new VCard();
     $dataUri = new DataUri('image/example', $expected['logo'], DataUri::ENCODING_BASE64);
     VCard::builder('fn')->setValue($expected['fn'])->pushTo($vcard);
     VCard::builder('org')->setField('Name', $expected['org_name'])->setField('Unit1', $expected['org_unit1'])->setField('Unit2', $expected['org_unit2'])->pushTo($vcard);
     VCard::builder('logo')->setValue($dataUri->toString())->setMediaType('image/example')->pushTo($vcard);
     $contactID = $vcardDB->store($vcard);
     $this->checkRowCounts(['CONTACT' => 1, 'CONTACT_ORG' => 1, 'CONTACT_DATA' => 1], $vcard);
     $resultVCard = $vcardDB->fetchOne($contactID);
     $this->compareVCards($vcard, $resultVCard);
 }