ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
UriTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\Xml\Element;
4
7
9
10 function testDeserialize() {
11
12 $input = <<<BLA
13<?xml version="1.0"?>
14<root xmlns="http://sabredav.org/ns">
15 <uri>/foo/bar</uri>
16</root>
17BLA;
18
19 $reader = new Reader();
20 $reader->contextUri = 'http://example.org/';
21 $reader->elementMap = [
22 '{http://sabredav.org/ns}uri' => 'Sabre\\Xml\\Element\\Uri',
23 ];
24 $reader->xml($input);
25
26 $output = $reader->parse();
27
28 $this->assertEquals(
29 [
30 'name' => '{http://sabredav.org/ns}root',
31 'value' => [
32 [
33 'name' => '{http://sabredav.org/ns}uri',
34 'value' => new Uri('http://example.org/foo/bar'),
35 'attributes' => [],
36 ]
37 ],
38 'attributes' => [],
39 ],
41 );
42
43 }
44
45 function testSerialize() {
46
47 $writer = new Writer();
48 $writer->namespaceMap = [
49 'http://sabredav.org/ns' => null
50 ];
51 $writer->openMemory();
52 $writer->startDocument('1.0');
53 $writer->setIndent(true);
54 $writer->contextUri = 'http://example.org/';
55 $writer->write([
56 '{http://sabredav.org/ns}root' => [
57 '{http://sabredav.org/ns}uri' => new Uri('/foo/bar'),
58 ]
59 ]);
60
61 $output = $writer->outputMemory();
62
63 $expected = <<<XML
64<?xml version="1.0"?>
65<root xmlns="http://sabredav.org/ns">
66 <uri>http://example.org/foo/bar</uri>
67</root>
68
69XML;
70
71 $this->assertEquals($expected, $output);
72
73
74 }
75
76}
An exception for terminatinating execution or to throw for unit testing.
Uri element.
Definition: Uri.php:23
The Reader class expands upon PHP's built-in XMLReader.
Definition: Reader.php:20
The XML Writer class.
Definition: Writer.php:31
static http()
Fetches the global http state from ILIAS.