11 $this->writer =
new Writer();
12 $this->writer->namespaceMap = [
13 'http://sabredav.org/ns' =>
's',
15 $this->writer->openMemory();
16 $this->writer->setIndent(
true);
17 $this->writer->startDocument();
23 $this->writer->write(
$input);
24 $this->assertEquals(
$output, $this->writer->outputMemory());
32 '{http://sabredav.org/ns}root' =>
'text',
35 <
s:root xmlns:
s=
"http://sabredav.org/ns">text</s:root>
48 '{http://sabredav.org/ns}root' =>
'"text"',
51 <
s:root xmlns:
s=
"http://sabredav.org/ns">"text"</
s:root>
61 '{http://sabredav.org/ns}root' => [
64 'attr1' =>
'attribute value',
69 <
s:root xmlns:
s=
"http://sabredav.org/ns" attr1=
"attribute value">text</s:root>
77 '{http://sabredav.org/ns}root' => [
78 '{http://sabredav.org/ns}single' =>
'value',
79 '{http://sabredav.org/ns}multiple' => [
81 'name' =>
'{http://sabredav.org/ns}foo',
85 'name' =>
'{http://sabredav.org/ns}foo',
90 'name' =>
'{http://sabredav.org/ns}attributes',
97 'name' =>
'{http://sabredav.org/ns}verbose',
105 <?xml version=
"1.0"?>
106 <
s:root xmlns:
s=
"http://sabredav.org/ns">
107 <
s:single>value</s:single>
110 <
s:foo>foobar</s:foo>
112 <
s:attributes foo=
"bar"/>
113 <
s:verbose foo=
"bar">syntax</s:verbose>
123 '{http://sabredav.org/ns}root' => null,
125 <?xml version=
"1.0"?>
126 <
s:root xmlns:
s=
"http://sabredav.org/ns"/>
136 '{http://sabredav.org/ns}root' => [
138 'name' =>
'{http://sabredav.org/ns}elem1',
141 'attr1' =>
'attribute value',
146 <?xml version=
"1.0"?>
147 <
s:root xmlns:
s=
"http://sabredav.org/ns">
148 <
s:elem1 attr1=
"attribute value">text</s:elem1>
159 '{http://sabredav.org/ns}root' => [
161 'name' =>
'{http://sabredav.org/ns}elem1',
170 <?xml version=
"1.0"?>
171 <
s:root xmlns:
s=
"http://sabredav.org/ns">
172 <
s:elem1>foobarbaz</s:elem1>
186 '{http://sabredav.org/ns}root' => [
188 'name' =>
'{http://sabredav.org/ns}elem1',
190 'attr1' =>
'attribute value',
195 <?xml version=
"1.0"?>
196 <
s:root xmlns:
s=
"http://sabredav.org/ns">
197 <
s:elem1 attr1=
"attribute value"/>
208 '{http://sabredav.org/ns}root' => [
209 '{urn:foo}elem1' =>
'bar',
212 <?xml version=
"1.0"?>
213 <
s:root xmlns:
s=
"http://sabredav.org/ns">
214 <x1:elem1 xmlns:x1=
"urn:foo">bar</x1:elem1>
226 '{http://sabredav.org/ns}root' => [
230 <?xml version=
"1.0"?>
231 <
s:root xmlns:
s=
"http://sabredav.org/ns">
232 <elem1 xmlns=
"">bar</elem1>
243 '{http://sabredav.org/ns}root' => [
245 'name' =>
'{http://sabredav.org/ns}elem1',
249 '{http://sabredav.org/ns}attr2' =>
'val2',
250 '{urn:foo}attr3' =>
'val3',
255 <?xml version=
"1.0"?>
256 <
s:root xmlns:
s=
"http://sabredav.org/ns">
257 <
s:elem1 attr1=
"val1" s:attr2=
"val2" x1:attr3=
"val3" xmlns:x1=
"urn:foo">text</s:elem1>
268 '{http://sabredav.org/ns}root' =>
new Element\
Base(
'hello')
270 <?xml version=
"1.0"?>
271 <
s:root xmlns:
s=
"http://sabredav.org/ns">hello</s:root>
281 '{http://sabredav.org/ns}root' =>
new Element\Mock()
283 <?xml version=
"1.0"?>
284 <
s:root xmlns:
s=
"http://sabredav.org/ns">
285 <
s:elem1>hiiii!</
s:elem1>
295 $this->writer->namespaceMap[
'http://sabredav.org/ns'] = null;
297 '{http://sabredav.org/ns}root' =>
new Element\Mock()
299 <?xml version=
"1.0"?>
300 <root xmlns=
"http://sabredav.org/ns">
301 <elem1>hiiii!</elem1>
311 $this->writer->namespaceMap[
'http://sabredav.org/ns'] =
'';
313 '{http://sabredav.org/ns}root' =>
new Element\Mock()
315 <?xml version=
"1.0"?>
316 <root xmlns=
"http://sabredav.org/ns">
317 <elem1>hiiii!</elem1>
327 $this->writer->writeElement(
"{http://sabredav.org/ns}foo",
'content');
330 <?xml version=
"1.0"?>
331 <
s:foo xmlns:
s=
"http://sabredav.org/ns">content</
s:foo>
335 $this->assertEquals(
$output, $this->writer->outputMemory());
342 $this->writer->writeElement(
"{http://sabredav.org/ns}foo",
new Element\KeyValue([
'{http://sabredav.org/ns}bar' =>
'test']));
345 <?xml version=
"1.0"?>
346 <
s:foo xmlns:
s=
"http://sabredav.org/ns">
352 $this->assertEquals(
$output, $this->writer->outputMemory());
361 $this->writer->write(
new \StdClass());
367 $this->writer->startElement(
"foo");
368 $this->writer->endElement();
371 <?xml version=
"1.0"?>
372 <foo xmlns:
s=
"http://sabredav.org/ns"/>
376 $this->assertEquals(
$output, $this->writer->outputMemory());
384 $writer->text(
'deferred writer');
387 <?xml version=
"1.0"?>
388 <
s:root xmlns:
s=
"http://sabredav.org/ns">deferred writer</
s:root>
401 '{http://sabredav.org/ns}root' =>
fopen(
'php://memory',
'r'),
403 <?xml version=
"1.0"?>
404 <
s:root xmlns:
s=
"http://sabredav.org/ns">deferred writer</s:root>
418 $this->writer->classMap[
'stdClass'] =
function(
Writer $writer, $value) {
420 foreach (get_object_vars($value) as
$key => $val) {
421 $writer->
writeElement(
'{http://sabredav.org/ns}' . $key, $val);
427 '{http://sabredav.org/ns}root' => $obj
429 <?xml version=
"1.0"?>
430 <
s:root xmlns:
s=
"http://sabredav.org/ns">
431 <
s:key1>value1</s:key1>
432 <
s:key2>value2</s:key2>
testSimpleQuotes()
testSimple
testWriteElementComplex()
testEmptyNamespacePrefix()
testEmptyNamespacePrefixEmptyString()
This is the XML element interface.
Base Class for all * cipher classes.
testArrayFormat2NoValue()
testArrayFormat2
writeElement($name, $content=null)
Write a full element tag and it's contents.