ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CDataTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace 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>
20 BLA;
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 
51 XML;
52 
53  $this->assertEquals($expected, $output);
54 
55 
56  }
57 
58 }
The Reader class expands upon PHP&#39;s built-in XMLReader.
Definition: Reader.php:20
The XML Writer class.
Definition: Writer.php:31