xref: /PHP-7.2/ext/simplexml/tests/bug40451.phpt (revision 17ccbeec)
1--TEST--
2Bug #40451 (addAttribute() may crash when used with non-existent child node)
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7
8$string = <<<XML
9<?xml version="1.0"?>
10	<Host enable="true">
11	 <Name>host.server.com</Name>
12	 </Host>
13XML;
14
15$xml = simplexml_load_string($string);
16
17$add = $xml->addChild('Host');
18$add->Host->addAttribute('enable', 'true');
19
20?>
21===DONE===
22--EXPECTF--
23Warning: SimpleXMLElement::addAttribute(): Unable to locate parent Element in %s on line %d
24===DONE===
25