mirror of
https://github.com/php/php-src.git
synced 2024-11-25 02:44:58 +08:00
- MFH Add tests
This commit is contained in:
parent
0fab5aacce
commit
193ae05edd
34
ext/xmlreader/tests/011.phpt
Normal file
34
ext/xmlreader/tests/011.phpt
Normal file
@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
XMLReader: libxml2 XML Reader, string data
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("xmlreader")) print "skip";
|
||||
$reader = new XMLReader();
|
||||
if (!method_exists($reader, 'readInnerXml')) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* $Id$ */
|
||||
|
||||
$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<books><book>test</book></books>';
|
||||
|
||||
$reader = new XMLReader();
|
||||
$reader->XML($xmlstring);
|
||||
$reader->read();
|
||||
echo $reader->readInnerXml();
|
||||
echo "\n";
|
||||
$reader->close();
|
||||
|
||||
|
||||
$reader = new XMLReader();
|
||||
$reader->XML($xmlstring);
|
||||
$reader->read();
|
||||
echo $reader->readOuterXml();
|
||||
echo "\n";
|
||||
$reader->close();
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
<book>test</book>
|
||||
<books><book>test</book></books>
|
||||
===DONE===
|
2
ext/xmlreader/tests/012.dtd
Executable file
2
ext/xmlreader/tests/012.dtd
Executable file
@ -0,0 +1,2 @@
|
||||
<!ELEMENT foo EMPTY>
|
||||
<!ATTLIST foo bar CDATA '' baz CDATA ''>
|
69
ext/xmlreader/tests/012.phpt
Executable file
69
ext/xmlreader/tests/012.phpt
Executable file
@ -0,0 +1,69 @@
|
||||
--TEST--
|
||||
XMLReader: accessing empty and non existing attributes
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* $Id$ */
|
||||
|
||||
$xmlstring =<<<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<foo bar=""/>
|
||||
EOF;
|
||||
|
||||
$reader = new XMLReader();
|
||||
$reader->XML($xmlstring);
|
||||
$reader->read();
|
||||
var_dump($reader->getAttribute('bar'));
|
||||
var_dump($reader->getAttribute('baz'));
|
||||
$reader->close();
|
||||
|
||||
$xmlstring =<<<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE foo SYSTEM "012.dtd">
|
||||
<foo bar=""/>
|
||||
EOF;
|
||||
|
||||
$xmlstring = str_replace('012.dtd', dirname(__FILE__).'/012.dtd', $xmlstring);
|
||||
|
||||
$reader = new XMLReader();
|
||||
$reader->XML($xmlstring);
|
||||
$reader->setParserProperty(XMLReader::DEFAULTATTRS, true);
|
||||
while($reader->read() && $reader->nodeType != XMLReader::ELEMENT);
|
||||
var_dump($reader->getAttribute('bar'));
|
||||
var_dump($reader->getAttribute('baz'));
|
||||
$reader->close();
|
||||
|
||||
?>
|
||||
===FILE===
|
||||
<?php
|
||||
|
||||
$reader = new XMLReader();
|
||||
$reader->open(dirname(__FILE__) . '/012.xml');
|
||||
//$reader->setParserProperty(XMLReader::DEFAULTATTRS, true);
|
||||
while($reader->read() && $reader->nodeType != XMLReader::ELEMENT);
|
||||
var_dump($reader->getAttribute('bar'));
|
||||
var_dump($reader->getAttribute('baz'));
|
||||
$reader->close();
|
||||
|
||||
$reader = new XMLReader();
|
||||
$reader->open(dirname(__FILE__) . '/012.xml');
|
||||
$reader->setParserProperty(XMLReader::DEFAULTATTRS, true);
|
||||
while($reader->read() && $reader->nodeType != XMLReader::ELEMENT);
|
||||
var_dump($reader->getAttribute('bar'));
|
||||
var_dump($reader->getAttribute('baz'));
|
||||
$reader->close();
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
string(0) ""
|
||||
NULL
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
===FILE===
|
||||
string(0) ""
|
||||
NULL
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
===DONE===
|
3
ext/xmlreader/tests/012.xml
Executable file
3
ext/xmlreader/tests/012.xml
Executable file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE foo SYSTEM "012.dtd">
|
||||
<foo bar=""/>
|
Loading…
Reference in New Issue
Block a user