ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ParameterTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\VObject;
4 
6 
7 class ParameterTest extends TestCase {
8 
9  function testSetup() {
10 
11  $cal = new Component\VCalendar();
12 
13  $param = new Parameter($cal, 'name', 'value');
14  $this->assertEquals('NAME', $param->name);
15  $this->assertEquals('value', $param->getValue());
16 
17  }
18 
19  function testSetupNameLess() {
20 
21  $card = new Component\VCard();
22 
23  $param = new Parameter($card, null, 'URL');
24  $this->assertEquals('VALUE', $param->name);
25  $this->assertEquals('URL', $param->getValue());
26  $this->assertTrue($param->noName);
27 
28  }
29 
30  function testModify() {
31 
32  $cal = new Component\VCalendar();
33 
34  $param = new Parameter($cal, 'name', null);
35  $param->addValue(1);
36  $this->assertEquals([1], $param->getParts());
37 
38  $param->setParts([1, 2]);
39  $this->assertEquals([1, 2], $param->getParts());
40 
41  $param->addValue(3);
42  $this->assertEquals([1, 2, 3], $param->getParts());
43 
44  $param->setValue(4);
45  $param->addValue(5);
46  $this->assertEquals([4, 5], $param->getParts());
47 
48  }
49 
50  function testCastToString() {
51 
52  $cal = new Component\VCalendar();
53  $param = new Parameter($cal, 'name', 'value');
54  $this->assertEquals('value', $param->__toString());
55  $this->assertEquals('value', (string)$param);
56 
57  }
58 
59  function testCastNullToString() {
60 
61  $cal = new Component\VCalendar();
62  $param = new Parameter($cal, 'name', null);
63  $this->assertEquals('', $param->__toString());
64  $this->assertEquals('', (string)$param);
65 
66  }
67 
68  function testSerialize() {
69 
70  $cal = new Component\VCalendar();
71  $param = new Parameter($cal, 'name', 'value');
72  $this->assertEquals('NAME=value', $param->serialize());
73 
74  }
75 
76  function testSerializeEmpty() {
77 
78  $cal = new Component\VCalendar();
79  $param = new Parameter($cal, 'name', null);
80  $this->assertEquals('NAME=', $param->serialize());
81 
82  }
83 
84  function testSerializeComplex() {
85 
86  $cal = new Component\VCalendar();
87  $param = new Parameter($cal, 'name', ["val1", "val2;", "val3^", "val4\n", "val5\""]);
88  $this->assertEquals('NAME=val1,"val2;","val3^^","val4^n","val5^\'"', $param->serialize());
89 
90  }
91 
98  function testSerializePlusSign() {
99 
100  $cal = new Component\VCalendar();
101  $param = new Parameter($cal, 'EMAIL', "user+something@example.org");
102  $this->assertEquals('EMAIL="user+something@example.org"', $param->serialize());
103 
104  }
105 
106  function testIterate() {
107 
108  $cal = new Component\VCalendar();
109 
110  $param = new Parameter($cal, 'name', [1, 2, 3, 4]);
111  $result = [];
112 
113  foreach ($param as $value) {
114  $result[] = $value;
115  }
116 
117  $this->assertEquals([1, 2, 3, 4], $result);
118 
119  }
120 
121  function testSerializeColon() {
122 
123  $cal = new Component\VCalendar();
124  $param = new Parameter($cal, 'name', 'va:lue');
125  $this->assertEquals('NAME="va:lue"', $param->serialize());
126 
127  }
128 
130 
131  $cal = new Component\VCalendar();
132  $param = new Parameter($cal, 'name', 'va;lue');
133  $this->assertEquals('NAME="va;lue"', $param->serialize());
134 
135  }
136 
137 }
$result
VObject Parameter.
Definition: Parameter.php:20
testSerializePlusSign()
iCal 7.0 (OSX 10.9) has major issues with the EMAIL property, when the value contains a plus sign...