DOMDocument_relaxNGValidateSource_error1.phpt 889 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. DOMDocument::relaxNGValidateSource() should fail if document doesn't validate
  3. --CREDITS--
  4. Knut Urdalen <knut@php.net>
  5. --SKIPIF--
  6. <?php
  7. require_once('skipif.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. $rng = <<< RNG
  12. <?xml version="1.0" encoding="UTF-8"?>
  13. <grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0"
  14. datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  15. <start>
  16. <element name="apple">
  17. <element name="pear">
  18. <data type="NCName"/>
  19. </element>
  20. </element>
  21. </start>
  22. </grammar>
  23. RNG;
  24. $bad_xml = <<< BAD_XML
  25. <?xml version="1.0"?>
  26. <apple>
  27. <pear>Pear</pear>
  28. <pear>Pear</pear>
  29. </apple>
  30. BAD_XML;
  31. $doc = new DOMDocument();
  32. $doc->loadXML($bad_xml);
  33. $result = $doc->relaxNGValidateSource($rng);
  34. var_dump($result);
  35. ?>
  36. --EXPECTF--
  37. Warning: DOMDocument::relaxNGValidateSource(): Did not expect element pear there in %s on line %d
  38. bool(false)