php-src/ext/libxml/tests/libxml_set_external_entity_loader_basic.phpt
Nikita Popov c3c47c431e Move libxml_destroy_fci to RSHUTDOWN
If this is only done in post shutdown and the function name is
an object (e.g. closure), the object will already be freed during
zend_deactivate.

I left the rest of the shutdown procedure in post shutdown, as it
presumably has a reason to be there...
2014-04-18 00:15:13 +02:00

50 lines
818 B
PHP

--TEST--
libxml_set_external_entity_loader() basic test
--SKIPIF--
<?php if (!extension_loaded('dom')) die('skip'); ?>
--FILE--
<?php
$xml = <<<XML
<!DOCTYPE foo PUBLIC "-//FOO/BAR" "http://example.com/foobar">
<foo>bar</foo>
XML;
$dtd = <<<DTD
<!ELEMENT foo (#PCDATA)>
DTD;
libxml_set_external_entity_loader(
function ($public, $system, $context) use($dtd){
var_dump($public);
var_dump($system);
var_dump($context);
$f = fopen("php://temp", "r+");
fwrite($f, $dtd);
rewind($f);
return $f;
}
);
$dd = new DOMDocument;
$r = $dd->loadXML($xml);
var_dump($dd->validate());
echo "Done.\n";
?>
--EXPECT--
string(10) "-//FOO/BAR"
string(25) "http://example.com/foobar"
array(4) {
["directory"]=>
NULL
["intSubName"]=>
NULL
["extSubURI"]=>
NULL
["extSubSystem"]=>
NULL
}
bool(true)
Done.