Skip to content

Commit 62938bf

Browse files
jhdxrkrakjoe
authored andcommitted
fix BC break introduced by php#2346 (sebastianbergmann/phpunit#2454)
1 parent 4b1afc8 commit 62938bf

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

ext/dom/document.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,9 @@ PHP_FUNCTION(dom_document_savexml)
16281628

16291629
doc_props = dom_get_doc_props(intern->document);
16301630
format = doc_props->formatoutput;
1631+
if (format) {
1632+
options = options | XML_SAVE_FORMAT;
1633+
}
16311634

16321635
buf = xmlBufferCreate();
16331636
if (!buf) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
DOM Document: saveXML with createElement and formatOutput
3+
--CREDITS--
4+
CHU Zhaowei <jhdxr@php.net>
5+
--SKIPIF--
6+
<?php require_once('skipif.inc'); ?>
7+
--FILE--
8+
<?php
9+
$dom = new domDocument('1.0', 'UTF-8');
10+
$dom->formatOutput = true;
11+
12+
$root = $dom->createElement('root');
13+
$dom->appendChild($root);
14+
15+
$child1 = $dom->createElement('testsuite');
16+
$root->appendChild($child1);
17+
18+
$child11 = $dom->createElement('testcase');
19+
$child11->setAttribute('name', 'leaf1');
20+
$child12 = $dom->createElement('testcase');
21+
$child12->setAttribute('name', 'leaf2');
22+
$child1->appendChild($child11);
23+
$child1->appendChild($child12);
24+
25+
echo $dom->saveXml();
26+
--EXPECT--
27+
<?xml version="1.0" encoding="UTF-8"?>
28+
<root>
29+
<testsuite>
30+
<testcase name="leaf1"/>
31+
<testcase name="leaf2"/>
32+
</testsuite>
33+
</root>

0 commit comments

Comments
 (0)