ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
XmlTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV\Xml;
4 
7 
8 abstract class XmlTest extends \PHPUnit_Framework_TestCase {
9 
10  protected $elementMap = [];
11  protected $namespaceMap = ['DAV:' => 'd'];
12  protected $contextUri = '/';
13 
14  function write($input) {
15 
16  $writer = new Writer();
17  $writer->contextUri = $this->contextUri;
18  $writer->namespaceMap = $this->namespaceMap;
19  $writer->openMemory();
20  $writer->setIndent(true);
21  $writer->write($input);
22  return $writer->outputMemory();
23 
24  }
25 
26  function parse($xml, array $elementMap = []) {
27 
28  $reader = new Reader();
29  $reader->elementMap = array_merge($this->elementMap, $elementMap);
30  $reader->xml($xml);
31  return $reader->parse();
32 
33  }
34 
35  function assertParsedValue($expected, $xml, array $elementMap = []) {
36 
37  $result = $this->parse($xml, $elementMap);
38  $this->assertEquals($expected, $result['value']);
39 
40  }
41 
42  function cleanUp() {
43 
44  libxml_clear_errors();
45 
46  }
47 
48 }
$result
assertParsedValue($expected, $xml, array $elementMap=[])
Definition: XmlTest.php:35
parse($xml, array $elementMap=[])
Definition: XmlTest.php:26
The Reader class expands upon PHP&#39;s built-in XMLReader.
Definition: Reader.php:20
The XML Writer class.
Definition: Writer.php:31