2011-06-28 20:17:15 +00:00
|
|
|
--TEST--
|
|
|
|
DOMNode::C14NFile()
|
2021-03-22 20:57:47 +00:00
|
|
|
--EXTENSIONS--
|
|
|
|
dom
|
2011-06-28 20:17:15 +00:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
$xml = <<< XML
|
|
|
|
<?xml version="1.0" ?>
|
|
|
|
<books>
|
|
|
|
<book>
|
|
|
|
<title>The Grapes of Wrath</title>
|
|
|
|
<author>John Steinbeck</author>
|
|
|
|
</book>
|
|
|
|
<book>
|
|
|
|
<title>The Pearl</title>
|
|
|
|
<author>John Steinbeck</author>
|
|
|
|
</book>
|
|
|
|
</books>
|
|
|
|
XML;
|
|
|
|
|
2019-03-15 21:55:30 +00:00
|
|
|
$output = __DIR__.'/DOMNode_C14NFile_basic.tmp';
|
2011-06-28 20:17:15 +00:00
|
|
|
$doc = new DOMDocument();
|
|
|
|
$doc->loadXML($xml);
|
|
|
|
$node = $doc->getElementsByTagName('title')->item(0);
|
|
|
|
var_dump($node->C14NFile($output));
|
|
|
|
$content = file_get_contents($output);
|
|
|
|
var_dump($content);
|
2020-04-19 12:35:25 +00:00
|
|
|
try {
|
|
|
|
var_dump($node->C14NFile($output, false, false, []));
|
|
|
|
} catch (\ValueError $e) {
|
|
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
var_dump($node->C14NFile($output, false, false, ['query' => []]));
|
|
|
|
} catch (\TypeError $e) {
|
|
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
|
|
}
|
2011-06-28 20:17:15 +00:00
|
|
|
?>
|
|
|
|
--CLEAN--
|
|
|
|
<?php
|
2019-03-15 21:55:30 +00:00
|
|
|
$output = __DIR__.'/DOMNode_C14NFile_basic.tmp';
|
2011-06-28 20:17:15 +00:00
|
|
|
unlink($output);
|
|
|
|
?>
|
2018-02-19 08:59:41 +00:00
|
|
|
--EXPECT--
|
2011-06-28 20:17:15 +00:00
|
|
|
int(34)
|
|
|
|
string(34) "<title>The Grapes of Wrath</title>"
|
2020-04-19 12:35:25 +00:00
|
|
|
DOMNode::C14NFile(): Argument #4 ($xpath) must have a "query" key
|
|
|
|
DOMNode::C14NFile(): Argument #4 ($xpath) "query" option must be a string, array given
|