ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\VObject\PropertyTest Class Reference
+ Inheritance diagram for Sabre\VObject\PropertyTest:
+ Collaboration diagram for Sabre\VObject\PropertyTest:

Public Member Functions

 testToString ()
 
 testCreate ()
 
 testSetValue ()
 
 testParameterExists ()
 
 testParameterGet ()
 
 testParameterNotExists ()
 
 testParameterMultiple ()
 
 testSetParameterAsString ()
 
 testUnsetParameter ()
 
 testSerialize ()
 
 testSerializeParam ()
 
 testSerializeNewLine ()
 
 testSerializeLongLine ()
 
 testSerializeUTF8LineFold ()
 
 testGetIterator ()
 
 testGetIteratorDefault ()
 
 testAddScalar ()
 
 testAddParameter ()
 
 testAddParameterTwice ()
 
 testClone ()
 
 testCreateParams ()
 
 testValidateNonUTF8 ()
 
 testValidateControlChars ()
 
 testValidateBadPropertyName ()
 
 testGetValue ()
 
 testArrayAccessSetInt ()
 ElementList should reject this. More...
 
 testArrayAccessUnsetInt ()
 ElementList should reject this. More...
 
 testValidateBadEncoding ()
 
 testValidateBadEncodingVCard4 ()
 
 testValidateBadEncodingVCard3 ()
 
 testValidateBadEncodingVCard21 ()
 

Detailed Description

Definition at line 9 of file PropertyTest.php.

Member Function Documentation

◆ testAddParameter()

Sabre\VObject\PropertyTest::testAddParameter ( )

Definition at line 212 of file PropertyTest.php.

212  {
213 
214  $cal = new VCalendar();
215  $prop = $cal->createProperty('EMAIL');
216 
217  $prop->add('MYPARAM', 'value');
218 
219  $this->assertEquals(1, count($prop->parameters()));
220  $this->assertEquals('MYPARAM', $prop['myparam']->name);
221 
222  }

◆ testAddParameterTwice()

Sabre\VObject\PropertyTest::testAddParameterTwice ( )

Definition at line 224 of file PropertyTest.php.

224  {
225 
226  $cal = new VCalendar();
227  $prop = $cal->createProperty('EMAIL');
228 
229  $prop->add('MYPARAM', 'value1');
230  $prop->add('MYPARAM', 'value2');
231 
232  $this->assertEquals(1, count($prop->parameters));
233  $this->assertEquals(2, count($prop->parameters['MYPARAM']->getParts()));
234 
235  $this->assertEquals('MYPARAM', $prop['MYPARAM']->name);
236 
237  }

◆ testAddScalar()

Sabre\VObject\PropertyTest::testAddScalar ( )

Definition at line 197 of file PropertyTest.php.

197  {
198 
199  $cal = new VCalendar();
200  $property = $cal->createProperty('EMAIL');
201 
202  $property->add('myparam', 'value');
203 
204  $this->assertEquals(1, count($property->parameters()));
205 
206  $this->assertTrue($property->parameters['MYPARAM'] instanceof Parameter);
207  $this->assertEquals('MYPARAM', $property->parameters['MYPARAM']->name);
208  $this->assertEquals('value', $property->parameters['MYPARAM']->getValue());
209 
210  }

◆ testArrayAccessSetInt()

Sabre\VObject\PropertyTest::testArrayAccessSetInt ( )

ElementList should reject this.

Definition at line 340 of file PropertyTest.php.

References $calendar.

340  {
341 
342  $calendar = new VCalendar();
343  $property = $calendar->createProperty("X-PROP", null);
344 
345  $calendar->add($property);
346  $calendar->{'X-PROP'}[0] = 'Something!';
347 
348  }

◆ testArrayAccessUnsetInt()

Sabre\VObject\PropertyTest::testArrayAccessUnsetInt ( )

ElementList should reject this.

Definition at line 355 of file PropertyTest.php.

References $calendar.

355  {
356 
357  $calendar = new VCalendar();
358  $property = $calendar->createProperty("X-PROP", null);
359 
360  $calendar->add($property);
361  unset($calendar->{'X-PROP'}[0]);
362 
363  }

◆ testClone()

Sabre\VObject\PropertyTest::testClone ( )

Definition at line 240 of file PropertyTest.php.

240  {
241 
242  $cal = new VCalendar();
243  $property = $cal->createProperty('EMAIL', 'value');
244  $property['FOO'] = 'BAR';
245 
246  $property2 = clone $property;
247 
248  $property['FOO'] = 'BAZ';
249  $this->assertEquals('BAR', (string)$property2['FOO']);
250 
251  }

◆ testCreate()

Sabre\VObject\PropertyTest::testCreate ( )

Definition at line 23 of file PropertyTest.php.

References PHPMailer\PHPMailer\$params.

23  {
24 
25  $cal = new VCalendar();
26 
27  $params = [
28  'param1' => 'value1',
29  'param2' => 'value2',
30  ];
31 
32  $property = $cal->createProperty('propname', 'propvalue', $params);
33 
34  $this->assertEquals('value1', $property['param1']->getValue());
35  $this->assertEquals('value2', $property['param2']->getValue());
36 
37  }

◆ testCreateParams()

Sabre\VObject\PropertyTest::testCreateParams ( )

Definition at line 253 of file PropertyTest.php.

253  {
254 
255  $cal = new VCalendar();
256  $property = $cal->createProperty('X-PROP', 'value', [
257  'param1' => 'value1',
258  'param2' => ['value2', 'value3']
259  ]);
260 
261  $this->assertEquals(1, count($property['PARAM1']->getParts()));
262  $this->assertEquals(2, count($property['PARAM2']->getParts()));
263 
264  }

◆ testGetIterator()

Sabre\VObject\PropertyTest::testGetIterator ( )

Definition at line 176 of file PropertyTest.php.

176  {
177 
178  $cal = new VCalendar();
179  $it = new ElementList([]);
180  $property = $cal->createProperty('propname', 'propvalue');
181  $property->setIterator($it);
182  $this->assertEquals($it, $property->getIterator());
183 
184  }

◆ testGetIteratorDefault()

Sabre\VObject\PropertyTest::testGetIteratorDefault ( )

Definition at line 187 of file PropertyTest.php.

187  {
188 
189  $cal = new VCalendar();
190  $property = $cal->createProperty('propname', 'propvalue');
191  $it = $property->getIterator();
192  $this->assertTrue($it instanceof ElementList);
193  $this->assertEquals(1, count($it));
194 
195  }

◆ testGetValue()

Sabre\VObject\PropertyTest::testGetValue ( )

Definition at line 311 of file PropertyTest.php.

References $calendar.

311  {
312 
313  $calendar = new VCalendar();
314  $property = $calendar->createProperty("SUMMARY", null);
315  $this->assertEquals([], $property->getParts());
316  $this->assertNull($property->getValue());
317 
318  $property->setValue([]);
319  $this->assertEquals([], $property->getParts());
320  $this->assertNull($property->getValue());
321 
322  $property->setValue([1]);
323  $this->assertEquals([1], $property->getParts());
324  $this->assertEquals(1, $property->getValue());
325 
326  $property->setValue([1, 2]);
327  $this->assertEquals([1, 2], $property->getParts());
328  $this->assertEquals('1,2', $property->getValue());
329 
330  $property->setValue('str');
331  $this->assertEquals(['str'], $property->getParts());
332  $this->assertEquals('str', $property->getValue());
333  }

◆ testParameterExists()

Sabre\VObject\PropertyTest::testParameterExists ( )

Definition at line 51 of file PropertyTest.php.

51  {
52 
53  $cal = new VCalendar();
54  $property = $cal->createProperty('propname', 'propvalue');
55  $property['paramname'] = 'paramvalue';
56 
57  $this->assertTrue(isset($property['PARAMNAME']));
58  $this->assertTrue(isset($property['paramname']));
59  $this->assertFalse(isset($property['foo']));
60 
61  }

◆ testParameterGet()

Sabre\VObject\PropertyTest::testParameterGet ( )

Definition at line 63 of file PropertyTest.php.

63  {
64 
65  $cal = new VCalendar();
66  $property = $cal->createProperty('propname', 'propvalue');
67  $property['paramname'] = 'paramvalue';
68 
69  $this->assertInstanceOf('Sabre\\VObject\\Parameter', $property['paramname']);
70 
71  }

◆ testParameterMultiple()

Sabre\VObject\PropertyTest::testParameterMultiple ( )

Definition at line 83 of file PropertyTest.php.

83  {
84 
85  $cal = new VCalendar();
86  $property = $cal->createProperty('propname', 'propvalue');
87  $property['paramname'] = 'paramvalue';
88  $property->add('paramname', 'paramvalue');
89 
90  $this->assertInstanceOf('Sabre\\VObject\\Parameter', $property['paramname']);
91  $this->assertEquals(2, count($property['paramname']->getParts()));
92 
93  }

◆ testParameterNotExists()

Sabre\VObject\PropertyTest::testParameterNotExists ( )

Definition at line 73 of file PropertyTest.php.

73  {
74 
75  $cal = new VCalendar();
76  $property = $cal->createProperty('propname', 'propvalue');
77  $property['paramname'] = 'paramvalue';
78 
79  $this->assertInternalType('null', $property['foo']);
80 
81  }

◆ testSerialize()

Sabre\VObject\PropertyTest::testSerialize ( )

Definition at line 119 of file PropertyTest.php.

119  {
120 
121  $cal = new VCalendar();
122  $property = $cal->createProperty('propname', 'propvalue');
123 
124  $this->assertEquals("PROPNAME:propvalue\r\n", $property->serialize());
125 
126  }

◆ testSerializeLongLine()

Sabre\VObject\PropertyTest::testSerializeLongLine ( )

Definition at line 149 of file PropertyTest.php.

149  {
150 
151  $cal = new VCalendar();
152  $value = str_repeat('!', 200);
153  $property = $cal->createProperty('propname', $value);
154 
155  $expected = "PROPNAME:" . str_repeat('!', 66) . "\r\n " . str_repeat('!', 74) . "\r\n " . str_repeat('!', 60) . "\r\n";
156 
157  $this->assertEquals($expected, $property->serialize());
158 
159  }

◆ testSerializeNewLine()

Sabre\VObject\PropertyTest::testSerializeNewLine ( )

Definition at line 140 of file PropertyTest.php.

140  {
141 
142  $cal = new VCalendar();
143  $property = $cal->createProperty('SUMMARY', "line1\nline2");
144 
145  $this->assertEquals("SUMMARY:line1\\nline2\r\n", $property->serialize());
146 
147  }

◆ testSerializeParam()

Sabre\VObject\PropertyTest::testSerializeParam ( )

Definition at line 128 of file PropertyTest.php.

128  {
129 
130  $cal = new VCalendar();
131  $property = $cal->createProperty('propname', 'propvalue', [
132  'paramname' => 'paramvalue',
133  'paramname2' => 'paramvalue2',
134  ]);
135 
136  $this->assertEquals("PROPNAME;PARAMNAME=paramvalue;PARAMNAME2=paramvalue2:propvalue\r\n", $property->serialize());
137 
138  }

◆ testSerializeUTF8LineFold()

Sabre\VObject\PropertyTest::testSerializeUTF8LineFold ( )

Definition at line 161 of file PropertyTest.php.

161  {
162 
163  $cal = new VCalendar();
164  $value = str_repeat('!', 65) . "\xc3\xa4bla" . str_repeat('!', 142) . "\xc3\xa4foo"; // inserted umlaut-a
165  $property = $cal->createProperty('propname', $value);
166 
167  // PROPNAME:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ("PROPNAME:" + 65x"!" = 74 bytes)
168  // äbla!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (" äbla" + 69x"!" = 75 bytes)
169  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (" " + 73x"!" = 74 bytes)
170  // äfoo
171  $expected = "PROPNAME:" . str_repeat('!', 65) . "\r\n \xc3\xa4bla" . str_repeat('!', 69) . "\r\n " . str_repeat('!', 73) . "\r\n \xc3\xa4foo\r\n";
172  $this->assertEquals($expected, $property->serialize());
173 
174  }

◆ testSetParameterAsString()

Sabre\VObject\PropertyTest::testSetParameterAsString ( )

Definition at line 95 of file PropertyTest.php.

95  {
96 
97  $cal = new VCalendar();
98  $property = $cal->createProperty('propname', 'propvalue');
99  $property['paramname'] = 'paramvalue';
100 
101  $this->assertEquals(1, count($property->parameters()));
102  $this->assertInstanceOf('Sabre\\VObject\\Parameter', $property->parameters['PARAMNAME']);
103  $this->assertEquals('PARAMNAME', $property->parameters['PARAMNAME']->name);
104  $this->assertEquals('paramvalue', $property->parameters['PARAMNAME']->getValue());
105 
106  }

◆ testSetValue()

Sabre\VObject\PropertyTest::testSetValue ( )

Definition at line 39 of file PropertyTest.php.

39  {
40 
41  $cal = new VCalendar();
42 
43  $property = $cal->createProperty('propname', 'propvalue');
44  $property->setValue('value2');
45 
46  $this->assertEquals('PROPNAME', $property->name);
47  $this->assertEquals('value2', $property->__toString());
48 
49  }

◆ testToString()

Sabre\VObject\PropertyTest::testToString ( )

Definition at line 11 of file PropertyTest.php.

11  {
12 
13  $cal = new VCalendar();
14 
15  $property = $cal->createProperty('propname', 'propvalue');
16  $this->assertEquals('PROPNAME', $property->name);
17  $this->assertEquals('propvalue', $property->__toString());
18  $this->assertEquals('propvalue', (string)$property);
19  $this->assertEquals('propvalue', $property->getValue());
20 
21  }

◆ testUnsetParameter()

Sabre\VObject\PropertyTest::testUnsetParameter ( )

Definition at line 108 of file PropertyTest.php.

108  {
109 
110  $cal = new VCalendar();
111  $property = $cal->createProperty('propname', 'propvalue');
112  $property['paramname'] = 'paramvalue';
113 
114  unset($property['PARAMNAME']);
115  $this->assertEquals(0, count($property->parameters()));
116 
117  }

◆ testValidateBadEncoding()

Sabre\VObject\PropertyTest::testValidateBadEncoding ( )

Definition at line 365 of file PropertyTest.php.

References $result.

365  {
366 
367  $document = new VCalendar();
368  $property = $document->add('X-FOO', 'value');
369  $property['ENCODING'] = 'invalid';
370 
371  $result = $property->validate();
372 
373  $this->assertEquals('ENCODING=INVALID is not valid for this document type.', $result[0]['message']);
374  $this->assertEquals(3, $result[0]['level']);
375 
376  }
$result

◆ testValidateBadEncodingVCard21()

Sabre\VObject\PropertyTest::testValidateBadEncodingVCard21 ( )

Definition at line 404 of file PropertyTest.php.

References $result.

404  {
405 
406  $document = new VCard(['VERSION' => '2.1']);
407  $property = $document->add('X-FOO', 'value');
408  $property['ENCODING'] = 'B';
409 
410  $result = $property->validate();
411 
412  $this->assertEquals('ENCODING=B is not valid for this document type.', $result[0]['message']);
413  $this->assertEquals(3, $result[0]['level']);
414 
415  }
$result

◆ testValidateBadEncodingVCard3()

Sabre\VObject\PropertyTest::testValidateBadEncodingVCard3 ( )

Definition at line 391 of file PropertyTest.php.

References $result.

391  {
392 
393  $document = new VCard(['VERSION' => '3.0']);
394  $property = $document->add('X-FOO', 'value');
395  $property['ENCODING'] = 'BASE64';
396 
397  $result = $property->validate();
398 
399  $this->assertEquals('ENCODING=BASE64 is not valid for this document type.', $result[0]['message']);
400  $this->assertEquals(3, $result[0]['level']);
401 
402  }
$result

◆ testValidateBadEncodingVCard4()

Sabre\VObject\PropertyTest::testValidateBadEncodingVCard4 ( )

Definition at line 378 of file PropertyTest.php.

References $result.

378  {
379 
380  $document = new VCard(['VERSION' => '4.0']);
381  $property = $document->add('X-FOO', 'value');
382  $property['ENCODING'] = 'BASE64';
383 
384  $result = $property->validate();
385 
386  $this->assertEquals('ENCODING parameter is not valid in vCard 4.', $result[0]['message']);
387  $this->assertEquals(3, $result[0]['level']);
388 
389  }
$result

◆ testValidateBadPropertyName()

Sabre\VObject\PropertyTest::testValidateBadPropertyName ( )

Definition at line 300 of file PropertyTest.php.

References $calendar, $result, and Sabre\VObject\Node\REPAIR.

300  {
301 
302  $calendar = new VCalendar();
303  $property = $calendar->createProperty("X_*&PROP*", "Bla");
304  $result = $property->validate(Property::REPAIR);
305 
306  $this->assertEquals($result[0]['message'], 'The propertyname: X_*&PROP* contains invalid characters. Only A-Z, 0-9 and - are allowed');
307  $this->assertEquals('X-PROP', $property->name);
308 
309  }
$result
const REPAIR
The following constants are used by the validate() method.
Definition: Node.php:27

◆ testValidateControlChars()

Sabre\VObject\PropertyTest::testValidateControlChars ( )

Definition at line 277 of file PropertyTest.php.

References $c, $calendar, $result, $s, and Sabre\VObject\Node\REPAIR.

277  {
278 
279  $s = "chars[";
280  foreach ([
281  0x7F, 0x5E, 0x5C, 0x3B, 0x3A, 0x2C, 0x22, 0x20,
282  0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18,
283  0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
284  0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08,
285  0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
286  ] as $c) {
287  $s .= sprintf('%02X(%c)', $c, $c);
288  }
289  $s .= "]end";
290 
291  $calendar = new VCalendar();
292  $property = $calendar->createProperty('X-PROP', $s);
293  $result = $property->validate(Property::REPAIR);
294 
295  $this->assertEquals('Property contained a control character (0x7f)', $result[0]['message']);
296  $this->assertEquals("chars[7F()5E(^)5C(\\\\)3B(\\;)3A(:)2C(\\,)22(\")20( )1F()1E()1D()1C()1B()1A()19()18()17()16()15()14()13()12()11()10()0F()0E()0D()0C()0B()0A(\\n)09(\t)08()07()06()05()04()03()02()01()00()]end", $property->getRawMimeDirValue());
297 
298  }
$result
$s
Definition: pwgen.php:45
const REPAIR
The following constants are used by the validate() method.
Definition: Node.php:27

◆ testValidateNonUTF8()

Sabre\VObject\PropertyTest::testValidateNonUTF8 ( )

Definition at line 266 of file PropertyTest.php.

References $calendar, $result, and Sabre\VObject\Node\REPAIR.

266  {
267 
268  $calendar = new VCalendar();
269  $property = $calendar->createProperty('X-PROP', "Bla\x00");
270  $result = $property->validate(Property::REPAIR);
271 
272  $this->assertEquals('Property contained a control character (0x00)', $result[0]['message']);
273  $this->assertEquals('Bla', $property->getValue());
274 
275  }
$result
const REPAIR
The following constants are used by the validate() method.
Definition: Node.php:27

The documentation for this class was generated from the following file: