Mercurial > hg > rc1
comparison vendor/sabre/vobject/tests/VObject/Property/TextTest.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\Property; | |
4 | |
5 use Sabre\VObject\Component\VCard; | |
6 | |
7 class TextTest extends \PHPUnit_Framework_TestCase { | |
8 | |
9 function assertVCard21serialization($propValue, $expected) { | |
10 | |
11 $doc = new VCard(array( | |
12 'VERSION'=>'2.1', | |
13 'PROP' => $propValue | |
14 ), false); | |
15 | |
16 // Adding quoted-printable, because we're testing if it gets removed | |
17 // automatically. | |
18 $doc->PROP['ENCODING'] = 'QUOTED-PRINTABLE'; | |
19 $doc->PROP['P1'] = 'V1'; | |
20 | |
21 | |
22 $output = $doc->serialize(); | |
23 | |
24 | |
25 $this->assertEquals("BEGIN:VCARD\r\nVERSION:2.1\r\n$expected\r\nEND:VCARD\r\n", $output); | |
26 | |
27 } | |
28 | |
29 function testSerializeVCard21() { | |
30 | |
31 $this->assertVCard21Serialization( | |
32 'f;oo', | |
33 'PROP;P1=V1:f;oo' | |
34 ); | |
35 | |
36 } | |
37 | |
38 function testSerializeVCard21Array() { | |
39 | |
40 $this->assertVCard21Serialization( | |
41 array('f;oo','bar'), | |
42 'PROP;P1=V1:f\;oo;bar' | |
43 ); | |
44 | |
45 } | |
46 function testSerializeVCard21Fold() { | |
47 | |
48 $this->assertVCard21Serialization( | |
49 str_repeat('x',80), | |
50 'PROP;P1=V1:' . str_repeat('x',64) . "\r\n " . str_repeat('x',16) | |
51 ); | |
52 | |
53 } | |
54 | |
55 | |
56 | |
57 function testSerializeQuotedPrintable() { | |
58 | |
59 $this->assertVCard21Serialization( | |
60 "foo\r\nbar", | |
61 'PROP;P1=V1;ENCODING=QUOTED-PRINTABLE:foo=0D=0Abar' | |
62 ); | |
63 } | |
64 | |
65 function testSerializeQuotedPrintableFold() { | |
66 | |
67 $this->assertVCard21Serialization( | |
68 "foo\r\nbarxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", | |
69 "PROP;P1=V1;ENCODING=QUOTED-PRINTABLE:foo=0D=0Abarxxxxxxxxxxxxxxxxxxxxxxxxxx=\r\n xxx" | |
70 ); | |
71 | |
72 } | |
73 | |
74 function testValidateMinimumPropValue() { | |
75 | |
76 $vcard = <<<IN | |
77 BEGIN:VCARD | |
78 VERSION:4.0 | |
79 UID:foo | |
80 FN:Hi! | |
81 N:A | |
82 END:VCARD | |
83 IN; | |
84 | |
85 $vcard = \Sabre\VObject\Reader::read($vcard); | |
86 $this->assertEquals(1, count($vcard->validate())); | |
87 | |
88 $this->assertEquals(1, count($vcard->N->getParts())); | |
89 | |
90 $vcard->validate(\Sabre\VObject\Node::REPAIR); | |
91 | |
92 $this->assertEquals(5, count($vcard->N->getParts())); | |
93 | |
94 } | |
95 | |
96 } |