comparison vendor/sabre/vobject/tests/VObject/EmptyParameterTest.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
children
comparison
equal deleted inserted replaced
6:cec75ba50afc 7:430dbd5346f7
1 <?php
2
3 namespace Sabre\VObject;
4
5 class IssueEmptyParameterTest extends \PHPUnit_Framework_TestCase {
6
7 function testRead() {
8
9 $input = <<<VCF
10 BEGIN:VCARD
11 VERSION:2.1
12 N:Doe;Jon;;;
13 FN:Jon Doe
14 EMAIL;X-INTERN:foo@example.org
15 UID:foo
16 END:VCARD
17 VCF;
18
19 $vcard = Reader::read($input);
20
21 $this->assertInstanceOf('Sabre\\VObject\\Component\\VCard', $vcard);
22 $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30);
23 $vcard = $vcard->serialize();
24
25 $converted = Reader::read($vcard);
26 $converted->validate();
27
28 $this->assertTrue(isset($converted->EMAIL['X-INTERN']));
29
30 $version = Version::VERSION;
31
32 $expected = <<<VCF
33 BEGIN:VCARD
34 VERSION:3.0
35 PRODID:-//Sabre//Sabre VObject $version//EN
36 N:Doe;Jon;;;
37 FN:Jon Doe
38 EMAIL;X-INTERN=:foo@example.org
39 UID:foo
40 END:VCARD
41
42 VCF;
43
44 $this->assertEquals($expected, str_replace("\r","", $vcard));
45
46 }
47
48 function testVCard21Parameter() {
49
50 $vcard = new Component\VCard(array(), false);
51 $vcard->VERSION = '2.1';
52 $vcard->PHOTO = 'random_stuff';
53 $vcard->PHOTO->add(null,'BASE64');
54 $vcard->UID = 'foo-bar';
55
56 $result = $vcard->serialize();
57 $expected = array(
58 "BEGIN:VCARD",
59 "VERSION:2.1",
60 "PHOTO;BASE64:" . base64_encode('random_stuff'),
61 "UID:foo-bar",
62 "END:VCARD",
63 "",
64 );
65
66 $this->assertEquals(implode("\r\n", $expected), $result);
67
68 }
69 }