ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CDataTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\Xml\Element;
4
7
9
13 function testDeserialize() {
14
15 $input = <<<BLA
16<?xml version="1.0"?>
17<root xmlns="http://sabredav.org/ns">
18 <blabla />
19</root>
20BLA;
21
22 $reader = new Reader();
23 $reader->elementMap = [
24 '{http://sabredav.org/ns}blabla' => 'Sabre\\Xml\\Element\\Cdata',
25 ];
26 $reader->xml($input);
27
28 $output = $reader->parse();
29
30 }
31
32 function testSerialize() {
33
34 $writer = new Writer();
35 $writer->namespaceMap = [
36 'http://sabredav.org/ns' => null
37 ];
38 $writer->openMemory();
39 $writer->startDocument('1.0');
40 $writer->setIndent(true);
41 $writer->write([
42 '{http://sabredav.org/ns}root' => new Cdata('<foo&bar>'),
43 ]);
44
45 $output = $writer->outputMemory();
46
47 $expected = <<<XML
48<?xml version="1.0"?>
49<root xmlns="http://sabredav.org/ns"><![CDATA[<foo&bar>]]></root>
50
51XML;
52
53 $this->assertEquals($expected, $output);
54
55
56 }
57
58}
An exception for terminatinating execution or to throw for unit testing.
testDeserialize()
@expectedException \LogicException
Definition: CDataTest.php:13
CDATA element.
Definition: Cdata.php:21
The Reader class expands upon PHP's built-in XMLReader.
Definition: Reader.php:20
The XML Writer class.
Definition: Writer.php:31