DOMNode_C14N_basic.phpt 868 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. DOMNode::C14N()
  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. $doc = new DOMDocument();
  21. $doc->loadXML($xml);
  22. $node = $doc->getElementsByTagName('title')->item(0);
  23. var_dump($node->C14N());
  24. try {
  25. var_dump($node->C14N(false, false, []));
  26. } catch (\ValueError $e) {
  27. echo $e->getMessage() . \PHP_EOL;
  28. }
  29. try {
  30. var_dump($node->C14N(false, false, ['query' => []]));
  31. } catch (\TypeError $e) {
  32. echo $e->getMessage() . \PHP_EOL;
  33. }
  34. ?>
  35. --EXPECT--
  36. string(34) "<title>The Grapes of Wrath</title>"
  37. DOMNode::C14N(): Argument #3 ($xpath) must have a "query" key
  38. DOMNode::C14N(): Argument #3 ($xpath) "query" option must be a string, array given