本文整理汇总了PHP中JFormInspector::mergeNodes方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormInspector::mergeNodes方法的具体用法?PHP JFormInspector::mergeNodes怎么用?PHP JFormInspector::mergeNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFormInspector
的用法示例。
在下文中一共展示了JFormInspector::mergeNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMergeNodes
/**
* Test the JForm::mergeNode method.
*
* @return void
*/
public function testMergeNodes()
{
// The source data.
$xml1 = simplexml_load_string('<form><fields><field name="foo" /></fields></form>');
// The new data for adding the field.
$xml2 = simplexml_load_string('<form><fields><field name="foo" type="text" /><field name="soap" /></fields></form>');
if ($xml1 === false || $xml2 === false) {
$this->fail('Line:' . __LINE__ . ' Error in text XML data');
}
JFormInspector::mergeNodes($xml1->fields, $xml2->fields);
$this->assertThat(count($xml1->xpath('fields/field')), $this->equalTo(2), 'Line:' . __LINE__ . ' The merge should have two field tags, one existing, one new.');
$this->assertThat(count($xml1->xpath('fields/field[@name="foo"] | fields/field[@type="text"]')), $this->equalTo(1), 'Line:' . __LINE__ . ' A field of the same name should merge.');
$this->assertThat(count($xml1->xpath('fields/field[@name="soap"]')), $this->equalTo(1), 'Line:' . __LINE__ . ' A new field should be added.');
}