mirror of
https://github.com/php/phd.git
synced 2026-03-23 22:52:05 +01:00
- Move error handling code into a class and remove PhD message output handling from it. - Introduce a new class to handle PhD message output. - Make the implicit dependency on the output functionality of classes explicit. - Update PEAR package.xml. - Fix tests. - Use proper variadic parameters - Use class constants - Use first-class callable syntax --------- Co-authored-by: haszi <haszika80@gmail.com>
58 lines
1.0 KiB
PHP
58 lines
1.0 KiB
PHP
--TEST--
|
|
Reader 001 - Read contents of current empty and non-empty elements
|
|
--FILE--
|
|
<?php
|
|
namespace phpdotnet\phd;
|
|
|
|
use XMLReader;
|
|
|
|
require_once __DIR__ . "/../setup.php";
|
|
|
|
$xml = <<<XML
|
|
<section>
|
|
<emptyNode></emptyNode>
|
|
<nonEmptyNode>
|
|
<title>Title here</title>
|
|
<content>Some content with <node>nodes</node></content>
|
|
</nonEmptyNode>
|
|
</section>
|
|
|
|
XML;
|
|
|
|
$reader = new Reader($outputHandler);
|
|
$reader->XML($xml);
|
|
|
|
echo "Read current node contents\n";
|
|
while ($reader->read()) {
|
|
if ($reader->nodeType === XMLReader::ELEMENT
|
|
&& ($reader->name === "emptyNode" || $reader->name === "nonEmptyNode")
|
|
) {
|
|
var_dump($reader->readContent());
|
|
}
|
|
}
|
|
|
|
$reader->XML($xml);
|
|
$reader->read();
|
|
|
|
echo "\nRead named node contents\n";
|
|
var_dump($reader->readContent("nonEmptyNode"));
|
|
var_dump($reader->readContent("emptyNode"));
|
|
?>
|
|
--EXPECT--
|
|
Read current node contents
|
|
string(0) ""
|
|
string(41) "
|
|
Title here
|
|
Some content with nodes
|
|
"
|
|
|
|
Read named node contents
|
|
string(45) "
|
|
|
|
|
|
Title here
|
|
Some content with nodes
|
|
"
|
|
string(1) "
|
|
"
|