1
0
mirror of https://github.com/php/php-src.git synced 2026-03-29 19:52:20 +02:00
Files
archived-php-src/ext/simplexml/tests/012.phpt
Máté Kocsis 6c8fb123d2 Promote warnings to exceptions in ext/simplexml
Closes GH-6011

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-08-25 15:15:58 +02:00

47 lines
800 B
PHP

--TEST--
SimpleXML: Attribute creation
--SKIPIF--
<?php
if (!extension_loaded('simplexml')) print 'skip';
?>
--FILE--
<?php
$xml =<<<EOF
<?xml version="1.0" encoding="ISO-8859-1" ?>
<foo/>
EOF;
$sxe = simplexml_load_string($xml);
try {
$sxe[""] = "value";
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
$sxe["attr"] = "value";
echo $sxe->asXML();
$sxe["attr"] = "new value";
echo $sxe->asXML();
try {
$sxe[] = "error";
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
__HALT_COMPILER();
?>
===DONE===
--EXPECT--
Cannot create attribute with an empty name
<?xml version="1.0" encoding="ISO-8859-1"?>
<foo attr="value"/>
<?xml version="1.0" encoding="ISO-8859-1"?>
<foo attr="new value"/>
Cannot append to an attribute list