xref: /PHP-8.3/ext/xmlreader/tests/007.phpt (revision 74859783)
1--TEST--
2XMLReader: libxml2 XML Reader, setRelaxNGSchema
3--EXTENSIONS--
4xmlreader
5--FILE--
6<?php
7
8$xmlstring = '<TEI.2>hello</TEI.2>';
9$relaxngfile = __DIR__ . '/relaxNG.rng';
10$file = __DIR__ . '/_007.xml';
11file_put_contents($file, $xmlstring);
12
13$reader = new XMLReader();
14$reader->open($file);
15
16if ($reader->setRelaxNGSchema($relaxngfile)) {
17  while ($reader->read());
18}
19if ($reader->isValid()) {
20  print "file relaxNG: ok\n";
21} else {
22  print "file relaxNG: failed\n";
23}
24$reader->close();
25unlink($file);
26
27
28$reader = new XMLReader();
29$reader->XML($xmlstring);
30
31if ($reader->setRelaxNGSchema($relaxngfile)) {
32  while ($reader->read());
33}
34if ($reader->isValid()) {
35  print "string relaxNG: ok\n";
36} else {
37  print "string relaxNG: failed\n";
38}
39
40$reader->close();
41
42$reader = new XMLReader();
43$reader->XML($xmlstring);
44
45try {
46    $reader->setRelaxNGSchema('');
47} catch (ValueError $exception) {
48    echo $exception->getMessage() . "\n";
49}
50
51$reader->close();
52?>
53--EXPECT--
54file relaxNG: ok
55string relaxNG: ok
56XMLReader::setRelaxNGSchema(): Argument #1 ($filename) cannot be empty
57