forked from u01jmg3/ics-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyValueTest.php
88 lines (76 loc) · 2.32 KB
/
KeyValueTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
use ICal\ICal;
use PHPUnit\Framework\TestCase;
class KeyValueTest extends TestCase
{
// phpcs:disable Generic.Arrays.DisallowLongArraySyntax
// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
// phpcs:disable Squiz.Commenting.FunctionComment
// phpcs:disable Squiz.Commenting.VariableComment
public function testBoundaryCharactersInsideQuotes()
{
$checks = array(
0 => 'ATTENDEE',
1 => array(
0 => 'mailto:[email protected]',
1 => array(
'PARTSTAT' => 'TENTATIVE',
'CN' => 'ju: @ag.com = Ju ; ',
),
),
);
$this->assertLines(
'ATTENDEE;PARTSTAT=TENTATIVE;CN="ju: @ag.com = Ju ; ":mailto:[email protected]',
$checks
);
}
public function testUtf8Characters()
{
$checks = array(
0 => 'ATTENDEE',
1 => array(
0 => 'mailto:juëǯ@ag.com',
1 => array(
'PARTSTAT' => 'TENTATIVE',
'CN' => 'juëǯĻ',
),
),
);
$this->assertLines(
'ATTENDEE;PARTSTAT=TENTATIVE;CN=juëǯĻ:mailto:juëǯ@ag.com',
$checks
);
$checks = array(
0 => 'SUMMARY',
1 => ' I love emojis 😀😁😁 ë, ǯ, Ļ',
);
$this->assertLines(
'SUMMARY: I love emojis 😀😁😁 ë, ǯ, Ļ',
$checks
);
}
public function testParametersOfKeysWithMultipleValues()
{
$checks = array(
0 => 'ATTENDEE',
1 => array(
0 => 'mailto:[email protected]',
1 => array(
'DELEGATED-TO' => array(
0 => 'mailto:[email protected]',
1 => 'mailto:[email protected]',
),
),
),
);
$this->assertLines(
'ATTENDEE;DELEGATED-TO="mailto:[email protected]","mailto:[email protected]":mailto:[email protected]',
$checks
);
}
private function assertLines($lines, array $checks)
{
$ical = new ICal();
self::assertEquals($ical->keyValueFromString($lines), $checks);
}
}