xref: /PHP-7.2/ext/spl/tests/bug54971.phpt (revision 372801d9)
1--TEST--
2Bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
3--SKIPIF--
4<?php
5if (!extension_loaded('dom')) die("skip this test needs --enable-dom");
6?>
7--FILE--
8<?php
9
10$source = <<<XML
11<root>
12<node>val1</node>
13<node>val2</node>
14</root>
15XML;
16
17
18$doc = new DOMDocument();
19$doc->loadXML($source);
20
21$xpath = new DOMXPath($doc);
22$items = $xpath->query('//node');
23
24print_r(array_map('get_class', iterator_to_array($items, false)));
25print_r(array_map('get_class', iterator_to_array($items, true)));
26?>
27--EXPECT--
28Array
29(
30    [0] => DOMElement
31    [1] => DOMElement
32)
33Array
34(
35    [0] => DOMElement
36    [1] => DOMElement
37)
38