ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SupportedCalendarComponentSetTest.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Sabre\CalDAV;
6 use Sabre\DAV;
7 
9 
10  function setUp() {
11 
12  $this->namespaceMap[CalDAV\Plugin::NS_CALDAV] = 'cal';
13  $this->namespaceMap[CalDAV\Plugin::NS_CALENDARSERVER] = 'cs';
14 
15  }
16 
17  function testSimple() {
18 
19  $prop = new SupportedCalendarComponentSet(['VEVENT']);
20  $this->assertEquals(
21  ['VEVENT'],
22  $prop->getValue()
23  );
24 
25  }
26 
27  function testMultiple() {
28 
29  $prop = new SupportedCalendarComponentSet(['VEVENT', 'VTODO']);
30  $this->assertEquals(
31  ['VEVENT', 'VTODO'],
32  $prop->getValue()
33  );
34 
35  }
36 
41  function testSerialize() {
42 
43  $property = new SupportedCalendarComponentSet(['VEVENT', 'VTODO']);
44  $xml = $this->write(['{DAV:}root' => $property]);
45 
46  $this->assertXmlStringEqualsXmlString(
47 '<?xml version="1.0"?>
48 <d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '" xmlns:cs="' . CalDAV\Plugin::NS_CALENDARSERVER . '">
49  <cal:comp name="VEVENT"/>
50  <cal:comp name="VTODO"/>
51 </d:root>
52 ', $xml);
53 
54  }
55 
56  function testUnserialize() {
57 
60 
61 $xml = <<<XML
62 <?xml version="1.0"?>
63  <d:root xmlns:cal="$cal" xmlns:cs="$cs" xmlns:d="DAV:">
64  <cal:comp name="VEVENT"/>
65  <cal:comp name="VTODO"/>
66  </d:root>
67 XML;
68 
69  $result = $this->parse(
70  $xml,
71  ['{DAV:}root' => 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet']
72  );
73 
74  $this->assertEquals(
75  new SupportedCalendarComponentSet(['VEVENT', 'VTODO']),
76  $result['value']
77  );
78 
79  }
80 
84  function testUnserializeEmpty() {
85 
88 
89 $xml = <<<XML
90 <?xml version="1.0"?>
91  <d:root xmlns:cal="$cal" xmlns:cs="$cs" xmlns:d="DAV:">
92  </d:root>
93 XML;
94 
95  $result = $this->parse(
96  $xml,
97  ['{DAV:}root' => 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet']
98  );
99 
100  }
101 
102 }
$result
parse($xml, array $elementMap=[])
Definition: XmlTest.php:26
const NS_CALENDARSERVER
This is the namespace for the proprietary calendarserver extensions.
Definition: Plugin.php:38
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33