1<?php 2 3namespace Sabre\VObject; 4 5class IssueEmptyParameterTest extends \PHPUnit_Framework_TestCase { 6 7 function testRead() { 8 9 $input = <<<VCF 10BEGIN:VCARD 11VERSION:2.1 12N:Doe;Jon;;; 13FN:Jon Doe 14EMAIL;X-INTERN:foo@example.org 15UID:foo 16END:VCARD 17VCF; 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 33BEGIN:VCARD 34VERSION:3.0 35PRODID:-//Sabre//Sabre VObject $version//EN 36N:Doe;Jon;;; 37FN:Jon Doe 38EMAIL;X-INTERN=:foo@example.org 39UID:foo 40END:VCARD 41 42VCF; 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} 70