summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Watkins <krakjoe@php.net>2017-01-30 11:26:37 +0000
committerJoe Watkins <krakjoe@php.net>2017-01-30 11:26:37 +0000
commite6bc4f39a27c8a91df48cf9ab2de76eb1b7c81c0 (patch)
treeeec0a9653135205730f5a8462769b00f7ad41b41
parentf2c99e201ed52da4b395d833bb6f5edbab3b2dba (diff)
parentdd227c2b23325fb7df524a3bc06c050e41b9d252 (diff)
downloadphp-git-e6bc4f39a27c8a91df48cf9ab2de76eb1b7c81c0.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: fix BC break introduced by #2346 (sebastianbergmann/phpunit#2454)
-rw-r--r--ext/dom/document.c3
-rw-r--r--ext/dom/tests/DOMDocument_savexml_basic2.phpt33
2 files changed, 36 insertions, 0 deletions
diff --git a/ext/dom/document.c b/ext/dom/document.c
index 0086d13c41..9250b92700 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -1628,6 +1628,9 @@ PHP_FUNCTION(dom_document_savexml)
doc_props = dom_get_doc_props(intern->document);
format = doc_props->formatoutput;
+ if (format) {
+ options = options | XML_SAVE_FORMAT;
+ }
buf = xmlBufferCreate();
if (!buf) {
diff --git a/ext/dom/tests/DOMDocument_savexml_basic2.phpt b/ext/dom/tests/DOMDocument_savexml_basic2.phpt
new file mode 100644
index 0000000000..7c01014808
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_savexml_basic2.phpt
@@ -0,0 +1,33 @@
+--TEST--
+DOM Document: saveXML with createElement and formatOutput
+--CREDITS--
+CHU Zhaowei <jhdxr@php.net>
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$dom = new domDocument('1.0', 'UTF-8');
+$dom->formatOutput = true;
+
+$root = $dom->createElement('root');
+$dom->appendChild($root);
+
+$child1 = $dom->createElement('testsuite');
+$root->appendChild($child1);
+
+$child11 = $dom->createElement('testcase');
+$child11->setAttribute('name', 'leaf1');
+$child12 = $dom->createElement('testcase');
+$child12->setAttribute('name', 'leaf2');
+$child1->appendChild($child11);
+$child1->appendChild($child12);
+
+echo $dom->saveXml();
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <testsuite>
+ <testcase name="leaf1"/>
+ <testcase name="leaf2"/>
+ </testsuite>
+</root> \ No newline at end of file