1<?php
2
3namespace Sabre\DAV\Xml;
4
5use Sabre\Xml\Writer;
6use Sabre\Xml\Reader;
7
8abstract 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 cleanUp() {
36
37        libxml_clear_errors();
38
39    }
40
41}
42