コード例 #1
0
ファイル: JFormTest.php プロジェクト: SysBind/joomla-cms
 /**
  * Test the JForm::mergeNode method.
  *
  * @return void
  */
 public function testMergeNode()
 {
     // The source data.
     $xml1 = simplexml_load_string('<form><field name="foo" /></form>');
     // The new data for adding the field.
     $xml2 = simplexml_load_string('<form><field name="bar" type="text" /></form>');
     if ($xml1 === false || $xml2 === false) {
         $this->fail('Line:' . __LINE__ . ' Error in text XML data');
     }
     JFormInspector::mergeNode($xml1->field, $xml2->field);
     $fields = $xml1->xpath('field[@name="foo"] | field[@type="text"]');
     $this->assertThat(count($fields), $this->equalTo(1), 'Line:' . __LINE__ . ' Existing attribute "name" should merge, new attribute "type" added.');
 }