ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
EmptyParameterTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\VObject;
4
5use PHPUnit\Framework\TestCase;
6
7class EmptyParameterTest extends TestCase {
8
9 function testRead() {
10
11 $input = <<<VCF
12BEGIN:VCARD
13VERSION:2.1
14N:Doe;Jon;;;
15FN:Jon Doe
16EMAIL;X-INTERN:foo@example.org
17UID:foo
18END:VCARD
19VCF;
20
21 $vcard = Reader::read($input);
22
23 $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard);
24 $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30);
25 $vcard = $vcard->serialize();
26
27 $converted = Reader::read($vcard);
28 $converted->validate();
29
30 $this->assertTrue(isset($converted->EMAIL['X-INTERN']));
31
33
34 $expected = <<<VCF
35BEGIN:VCARD
36VERSION:3.0
37PRODID:-//Sabre//Sabre VObject $version//EN
38N:Doe;Jon;;;
39FN:Jon Doe
40EMAIL;X-INTERN=:foo@example.org
41UID:foo
42END:VCARD
43
44VCF;
45
46 $this->assertEquals($expected, str_replace("\r", "", $vcard));
47
48 }
49
51
52 $vcard = new Component\VCard([], false);
53 $vcard->VERSION = '2.1';
54 $vcard->PHOTO = 'random_stuff';
55 $vcard->PHOTO->add(null, 'BASE64');
56 $vcard->UID = 'foo-bar';
57
58 $result = $vcard->serialize();
59 $expected = [
60 "BEGIN:VCARD",
61 "VERSION:2.1",
62 "PHOTO;BASE64:" . base64_encode('random_stuff'),
63 "UID:foo-bar",
64 "END:VCARD",
65 "",
66 ];
67
68 $this->assertEquals(implode("\r\n", $expected), $result);
69
70 }
71}
$result
$version
Definition: build.php:27
An exception for terminatinating execution or to throw for unit testing.
const VCARD30
vCard 3.0.
Definition: Document.php:44
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
const VERSION
Full version number.
Definition: Version.php:17
foreach($paths as $path) if($argc< 3) $input