本文整理汇总了PHP中JFormInspector::loadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormInspector::loadFile方法的具体用法?PHP JFormInspector::loadFile怎么用?PHP JFormInspector::loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFormInspector
的用法示例。
在下文中一共展示了JFormInspector::loadFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLoadFile
/**
* Test the JForm::loadFile method.
*
* This method loads a file and passes the string to the JForm::load method.
*
* @return void
*/
public function testLoadFile()
{
$form = new JFormInspector('form1');
// Test for files that don't exist.
$this->assertThat($form->loadFile('/tmp/example.xml'), $this->isFalse(), 'Line:' . __LINE__ . ' A file path that does not exist should return false.');
$this->assertThat($form->loadFile('notfound'), $this->isFalse(), 'Line:' . __LINE__ . ' A file name that does not exist should return false.');
// Testing loading a file by full path.
$this->assertThat($form->loadFile(__DIR__ . '/example.xml'), $this->isTrue(), 'Line:' . __LINE__ . ' XML file by full path should load successfully.');
$this->assertThat($form->getXml() instanceof SimpleXMLElement, $this->isTrue(), 'Line:' . __LINE__ . ' XML string should parse successfully.');
// Testing loading a file by file name.
$form = new JFormInspector('form1');
JForm::addFormPath(__DIR__);
$this->assertThat($form->loadFile('example'), $this->isTrue(), 'Line:' . __LINE__ . ' XML file by name should load successfully.');
$this->assertThat($form->getXml() instanceof SimpleXMLElement, $this->isTrue(), 'Line:' . __LINE__ . ' XML string should parse successfully.');
}