xref: /PHP-8.2/ext/xmlreader/tests/002.phpt (revision 74859783)
1--TEST--
2XMLReader: libxml2 XML Reader, file data
3--EXTENSIONS--
4xmlreader
5--FILE--
6<?php
7$filename = __DIR__ . '/_002.xml';
8$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
9<books></books>';
10file_put_contents($filename, $xmlstring);
11
12$reader = new XMLReader();
13try {
14    $reader->open('');
15} catch (ValueError $exception) {
16    echo $exception->getMessage() . "\n";
17}
18
19$reader = new XMLReader();
20if (!$reader->open($filename)) {
21    $reader->close();
22    exit();
23}
24
25// Only go through
26while ($reader->read()) {
27    echo $reader->name."\n";
28}
29$reader->close();
30unlink($filename);
31touch($filename);
32$reader = new XMLReader();
33$reader->open($filename);
34$reader->close();
35unlink($filename);
36
37?>
38--EXPECT--
39XMLReader::open(): Argument #1 ($uri) cannot be empty
40books
41books
42