本文整理汇总了PHP中JFormInspector::findFieldsByGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormInspector::findFieldsByGroup方法的具体用法?PHP JFormInspector::findFieldsByGroup怎么用?PHP JFormInspector::findFieldsByGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFormInspector
的用法示例。
在下文中一共展示了JFormInspector::findFieldsByGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLoad
/**
* Test the JForm::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.');
}
return $form;
}