/**
  * Test the Form::load method.
  *
  * This method can load an XML data object, or parse an XML string.
  *
  * @return void
  */
 public function testLoad()
 {
     $form = new JFormInspector('form1');
     $this->assertThat($form->load(JFormDataHelper::$loadDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $this->assertThat($form->getXML() instanceof \SimpleXMLElement, $this->isTrue(), 'Line:' . __LINE__ . ' The internal XML should be a SimpleXMLElement object.');
     // Test replace false.
     $this->assertThat($form->load(JFormDataHelper::$loadMergeDocument, false), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $this->assertThat(count($form->getXML()->xpath('/form/fields/field')), $this->equalTo(4), 'Line:' . __LINE__ . ' There are 2 new ungrouped field and one existing field should merge, resulting in 4 total.');
     // Test replace true (default).
     $form = new JFormInspector('form1');
     $this->assertThat($form->load(JFormDataHelper::$loadDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $this->assertThat($form->load(JFormDataHelper::$loadMergeDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     // @todo remove: $this->_showXml($form);die;
     $this->assertThat(count($form->findFieldsByGroup(false)), $this->equalTo(6), 'Line:' . __LINE__ . ' There are 2 original ungrouped fields, 1 replaced and 4 new, resulting in 6 total.');
     $this->assertThat(count($form->getXML()->xpath('//fields[@name]')), $this->equalTo(2), 'Line:' . __LINE__ . ' The XML has 2 fields tags with a name attribute.');
     $this->assertThat(count($form->getXML()->xpath('//fields[@name="params"]/field')), $this->equalTo(2), 'Line:' . __LINE__ . ' The params fields have been merged ending with 2 elements.');
     $this->assertThat(count($form->getXML()->xpath('/form/fields/fields[@name="params"]/field[@name="show_abstract"]')), $this->equalTo(1), 'Line:' . __LINE__ . ' The show_title in the params group has been replaced by show_abstract.');
     $originalform = new JFormInspector('form1');
     $originalform->load(JFormDataHelper::$loadDocument);
     $originalset = $originalform->getXML()->xpath('/form/fields/field');
     $set = $form->getXML()->xpath('/form/fields/field');
     for ($i = 0; $i < count($originalset); $i++) {
         $this->assertThat((string) $originalset[$i]->attributes()->name == (string) $set[$i]->attributes()->name, $this->isTrue(), 'Line:' . __LINE__ . ' Replace should leave fields in the original order.');
     }
 }