Exemple #1
0
 function testMimeDir()
 {
     $input = "BEGIN:VCARD\r\nVERSION:4.0\r\nX-FLOAT;VALUE=FLOAT:0.234;1.245\r\nEND:VCARD\r\n";
     $mimeDir = new VObject\Parser\MimeDir($input);
     $result = $mimeDir->parse($input);
     $this->assertInstanceOf('Sabre\\VObject\\Property\\Float', $result->{'X-FLOAT'});
     $this->assertEquals(array(0.234, 1.245), $result->{'X-FLOAT'}->getParts());
     $this->assertEquals($input, $result->serialize());
 }
 function testMimeDir()
 {
     $input = "BEGIN:VCARD\r\nVERSION:4.0\r\nLANG:nl\r\nEND:VCARD\r\n";
     $mimeDir = new VObject\Parser\MimeDir($input);
     $result = $mimeDir->parse($input);
     $this->assertInstanceOf('Sabre\\VObject\\Property\\VCard\\LanguageTag', $result->LANG);
     $this->assertEquals('nl', $result->LANG->getValue());
     $this->assertEquals($input, $result->serialize());
 }
Exemple #3
0
 /**
  * Every time getNext() is called, a new object will be parsed, until we
  * hit the end of the stream.
  *
  * When the end is reached, null will be returned.
  *
  * @return Sabre\VObject\Component|null
  */
 public function getNext()
 {
     try {
         $object = $this->parser->parse();
     } catch (VObject\EofException $e) {
         return null;
     }
     return $object;
 }
Exemple #4
0
 /**
  * Every time getNext() is called, a new object will be parsed, until we
  * hit the end of the stream.
  *
  * When the end is reached, null will be returned.
  *
  * @return Sabre\VObject\Component|null
  */
 public function getNext()
 {
     try {
         $object = $this->parser->parse();
         if (!$object instanceof VObject\Component\VCard) {
             throw new VObject\ParseException('The supplied input contained non-VCARD data.');
         }
     } catch (VObject\EofException $e) {
         return null;
     }
     return $object;
 }
 function testChangeAndSerialize()
 {
     $input = "BEGIN:VCARD\r\nVERSION:4.0\r\nLANG:nl\r\nEND:VCARD\r\n";
     $mimeDir = new VObject\Parser\MimeDir($input);
     $result = $mimeDir->parse($input);
     $this->assertInstanceOf('Sabre\\VObject\\Property\\VCard\\LanguageTag', $result->LANG);
     // This replicates what the vcard converter does and triggered a bug in
     // the past.
     $result->LANG->setValue(['de']);
     $this->assertEquals('de', $result->LANG->getValue());
     $expected = "BEGIN:VCARD\r\nVERSION:4.0\r\nLANG:de\r\nEND:VCARD\r\n";
     $this->assertEquals($expected, $result->serialize());
 }
Exemple #6
0
 /**
  * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
  *
  * This has been 'unfolded', so only 1 line will be passed. Unescaping is
  * not yet done, but parameters are not included.
  *
  * @param string $val
  * @return void
  */
 public function setRawMimeDirValue($val)
 {
     $this->setValue(MimeDir::unescapeValue($val, $this->delimiter));
 }