Skip to content

Commit

Permalink
Add a test case for iterator and empty & var_dump interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsdos committed Sep 17, 2023
1 parent 550ec29 commit fe98a16
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions ext/simplexml/tests/iterator_interaction_empty_and_var_dump.phpt
@@ -0,0 +1,48 @@
--TEST--
Test iterator interaction with empty and var_dump
--EXTENSIONS--
simplexml
--FILE--
<?php

$xml = <<<XML
<container>
<first><foo/></first>
</container>
XML;

$sxe = simplexml_load_string($xml);

echo "--- var_dump ---\n";

$first = $sxe->first;
$first->rewind();
var_dump($first->current()->getName());
var_dump($first);
var_dump($first->current()->getName());

echo "--- empty ---\n";

$first = $sxe->first;
$first->rewind();
var_dump($first->current()->getName());
var_dump(empty($first));
var_dump($first->current()->getName());

?>
--EXPECT--
--- var_dump ---
string(5) "first"
object(SimpleXMLElement)#2 (1) {
[0]=>
object(SimpleXMLElement)#4 (1) {
["foo"]=>
object(SimpleXMLElement)#5 (0) {
}
}
}
string(5) "first"
--- empty ---
string(5) "first"
bool(false)
string(5) "first"

0 comments on commit fe98a16

Please sign in to comment.