ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
QuotedPrintableTest.php
Go to the documentation of this file.
1<?php
2
4
5use PHPUnit\Framework\TestCase;
7
8class QuotedPrintableTest extends TestCase {
9
11
12 $data = "BEGIN:VCARD\r\nLABEL;ENCODING=QUOTED-PRINTABLE:Aach=65n\r\nEND:VCARD";
13
15
16 $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
17 $this->assertEquals('VCARD', $result->name);
18 $this->assertEquals(1, count($result->children()));
19 $this->assertEquals("Aachen", $this->getPropertyValue($result->LABEL));
20
21 }
22
24
25 $data = "BEGIN:VCARD\r\nLABEL;ENCODING=QUOTED-PRINTABLE:Aa=\r\n ch=\r\n en\r\nEND:VCARD";
27
28 $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
29 $this->assertEquals('VCARD', $result->name);
30 $this->assertEquals(1, count($result->children()));
31 $this->assertEquals("Aachen", $this->getPropertyValue($result->LABEL));
32
33 }
34
36
37 $data = "BEGIN:VCARD\r\nLABEL;ENCODING=QUOTED-PRINTABLE:Aachen=0D=0A=\r\n Germany\r\nEND:VCARD";
39
40 $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
41 $this->assertEquals('VCARD', $result->name);
42 $this->assertEquals(1, count($result->children()));
43 $this->assertEquals("Aachen\r\nGermany", $this->getPropertyValue($result->LABEL));
44
45
46 }
47
49
50 $data = "BEGIN:VCARD\r\nLABEL;ENCODING=QUOTED-PRINTABLE:Aachen=0D=0A=\r\nDeutschland:okay\r\nEND:VCARD";
52
53 $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
54 $this->assertEquals('VCARD', $result->name);
55 $this->assertEquals(1, count($result->children()));
56 $this->assertEquals("Aachen\r\nDeutschland:okay", $this->getPropertyValue($result->LABEL));
57
58 }
59
61
62 $data = <<<VCF
63BEGIN:VCARD
64VERSION:2.1
65N:Doe;John;;;
66FN:John Doe
67ADR;WORK;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;;M=C3=BCnster =
68Str. 1;M=C3=BCnster;;48143;Deutschland
69END:VCARD
70VCF;
71
73 $this->assertEquals([
74 '', '', 'Münster Str. 1', 'Münster', '', '48143', 'Deutschland'
75 ], $result->ADR->getParts());
76
77
78 }
79
80 private function getPropertyValue(\Sabre\VObject\Property $property) {
81
82 return (string)$property;
83
84 /*
85 $param = $property['encoding'];
86 if ($param !== null) {
87 $encoding = strtoupper((string)$param);
88 if ($encoding === 'QUOTED-PRINTABLE') {
89 $value = quoted_printable_decode($value);
90 } else {
91 throw new Exception();
92 }
93 }
94
95 $param = $property['charset'];
96 if ($param !== null) {
97 $charset = strtoupper((string)$param);
98 if ($charset !== 'UTF-8') {
99 $value = mb_convert_encoding($value, 'UTF-8', $charset);
100 }
101 } else {
102 $value = StringUtil::convertToUTF8($value);
103 }
104
105 return $value;
106 */
107 }
108}
$result
An exception for terminatinating execution or to throw for unit testing.
getPropertyValue(\Sabre\VObject\Property $property)
iCalendar/vCard/jCal/jCard/xCal/xCard reader object.
Definition: Reader.php:15
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
const OPTION_FORGIVING
If this option is passed to the reader, it will be less strict about the validity of the lines.
Definition: Reader.php:21
$data
Definition: bench.php:6