ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
TextTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\VObject\Property;
4 
7 
8 class TextTest extends TestCase {
9 
10  function assertVCard21Serialization($propValue, $expected) {
11 
12  $doc = new VCard([
13  'VERSION' => '2.1',
14  'PROP' => $propValue
15  ], false);
16 
17  // Adding quoted-printable, because we're testing if it gets removed
18  // automatically.
19  $doc->PROP['ENCODING'] = 'QUOTED-PRINTABLE';
20  $doc->PROP['P1'] = 'V1';
21 
22 
23  $output = $doc->serialize();
24 
25 
26  $this->assertEquals("BEGIN:VCARD\r\nVERSION:2.1\r\n$expected\r\nEND:VCARD\r\n", $output);
27 
28  }
29 
30  function testSerializeVCard21() {
31 
33  'f;oo',
34  'PROP;P1=V1:f;oo'
35  );
36 
37  }
38 
40 
42  ['f;oo', 'bar'],
43  'PROP;P1=V1:f\;oo;bar'
44  );
45 
46  }
48 
50  str_repeat('x', 80),
51  'PROP;P1=V1:' . str_repeat('x', 64) . "\r\n " . str_repeat('x', 16)
52  );
53 
54  }
55 
56 
57 
59 
61  "foo\r\nbar",
62  'PROP;P1=V1;ENCODING=QUOTED-PRINTABLE:foo=0D=0Abar'
63  );
64  }
65 
67 
69  "foo\r\nbarxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
70  "PROP;P1=V1;ENCODING=QUOTED-PRINTABLE:foo=0D=0Abarxxxxxxxxxxxxxxxxxxxxxxxxxx=\r\n xxx"
71  );
72 
73  }
74 
76 
77  $vcard = <<<IN
78 BEGIN:VCARD
79 VERSION:4.0
80 UID:foo
81 FN:Hi!
82 N:A
83 END:VCARD
84 IN;
85 
86  $vcard = \Sabre\VObject\Reader::read($vcard);
87  $this->assertEquals(1, count($vcard->validate()));
88 
89  $this->assertEquals(1, count($vcard->N->getParts()));
90 
91  $vcard->validate(\Sabre\VObject\Node::REPAIR);
92 
93  $this->assertEquals(5, count($vcard->N->getParts()));
94 
95  }
96 
97 }
const REPAIR
The following constants are used by the validate() method.
Definition: Node.php:27
count()
Returns the number of elements.
Definition: Node.php:177
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
assertVCard21Serialization($propValue, $expected)
Definition: TextTest.php:10
The VCard component.
Definition: VCard.php:18