ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SystemStatusTest.php
Go to the documentation of this file.
1<?php
2
4
5use Sabre\DAV;
7
9
16 function testSerializers($notification, $expected1, $expected2) {
17
18 $this->assertEquals('foo', $notification->getId());
19 $this->assertEquals('"1"', $notification->getETag());
20
21 $writer = new Writer();
22 $writer->namespaceMap = [
23 'http://calendarserver.org/ns/' => 'cs',
24 ];
25 $writer->openMemory();
26 $writer->startDocument('1.0', 'UTF-8');
27 $writer->startElement('{http://calendarserver.org/ns/}root');
28 $writer->write($notification);
29 $writer->endElement();
30 $this->assertXmlStringEqualsXmlString($expected1, $writer->outputMemory());
31
32 $writer = new Writer();
33 $writer->namespaceMap = [
34 'http://calendarserver.org/ns/' => 'cs',
35 'DAV:' => 'd',
36 ];
37 $writer->openMemory();
38 $writer->startDocument('1.0', 'UTF-8');
39 $writer->startElement('{http://calendarserver.org/ns/}root');
40 $notification->xmlSerializeFull($writer);
41 $writer->endElement();
42 $this->assertXmlStringEqualsXmlString($expected2, $writer->outputMemory());
43
44 }
45
46 function dataProvider() {
47
48 return [
49
50 [
51 new SystemStatus('foo', '"1"'),
52 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="high"/></cs:root>' . "\n",
53 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:"><cs:systemstatus type="high"/></cs:root>' . "\n",
54 ],
55 [
56 new SystemStatus('foo', '"1"', SystemStatus::TYPE_MEDIUM, 'bar'),
57 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="medium"/></cs:root>' . "\n",
58 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:"><cs:systemstatus type="medium"><cs:description>bar</cs:description></cs:systemstatus></cs:root>' . "\n",
59 ],
60 [
61 new SystemStatus('foo', '"1"', SystemStatus::TYPE_LOW, null, 'http://example.org/'),
62 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="low"/></cs:root>' . "\n",
63 '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:"><cs:systemstatus type="low"><d:href>http://example.org/</d:href></cs:systemstatus></cs:root>' . "\n",
64 ]
65 ];
66
67 }
68
69}
An exception for terminatinating execution or to throw for unit testing.
testSerializers($notification, $expected1, $expected2)
iCalendar/vCard/jCal/jCard/xCal/xCard writer object.
Definition: Writer.php:17
The XML Writer class.
Definition: Writer.php:31