xref: /PHP-8.1/ext/simplexml/tests/bug40451.phpt (revision 7f2f0c00)
1--TEST--
2Bug #40451 (addAttribute() may crash when used with non-existent child node)
3--EXTENSIONS--
4simplexml
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--EXPECTF--
22Warning: SimpleXMLElement::addAttribute(): Unable to locate parent Element in %s on line %d
23