DOMNode_C14NFile_basic.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. DOMNode::C14NFile()
  3. --EXTENSIONS--
  4. dom
  5. --FILE--
  6. <?php
  7. $xml = <<< XML
  8. <?xml version="1.0" ?>
  9. <books>
  10. <book>
  11. <title>The Grapes of Wrath</title>
  12. <author>John Steinbeck</author>
  13. </book>
  14. <book>
  15. <title>The Pearl</title>
  16. <author>John Steinbeck</author>
  17. </book>
  18. </books>
  19. XML;
  20. $output = __DIR__.'/DOMNode_C14NFile_basic.tmp';
  21. $doc = new DOMDocument();
  22. $doc->loadXML($xml);
  23. $node = $doc->getElementsByTagName('title')->item(0);
  24. var_dump($node->C14NFile($output));
  25. $content = file_get_contents($output);
  26. var_dump($content);
  27. try {
  28. var_dump($node->C14NFile($output, false, false, []));
  29. } catch (\ValueError $e) {
  30. echo $e->getMessage() . \PHP_EOL;
  31. }
  32. try {
  33. var_dump($node->C14NFile($output, false, false, ['query' => []]));
  34. } catch (\TypeError $e) {
  35. echo $e->getMessage() . \PHP_EOL;
  36. }
  37. ?>
  38. --CLEAN--
  39. <?php
  40. $output = __DIR__.'/DOMNode_C14NFile_basic.tmp';
  41. unlink($output);
  42. ?>
  43. --EXPECT--
  44. int(34)
  45. string(34) "<title>The Grapes of Wrath</title>"
  46. DOMNode::C14NFile(): Argument #4 ($xpath) must have a "query" key
  47. DOMNode::C14NFile(): Argument #4 ($xpath) "query" option must be a string, array given