本文整理汇总了PHP中JFormInspector::getInput方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormInspector::getInput方法的具体用法?PHP JFormInspector::getInput怎么用?PHP JFormInspector::getInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFormInspector
的用法示例。
在下文中一共展示了JFormInspector::getInput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetInput
/**
* Test for JForm::getInput method.
*
* @return void
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$matcher = array('id' => 'title_id', 'tag' => 'input', 'attributes' => array('type' => 'text', 'name' => 'title', 'value' => 'The Title', 'class' => 'inputbox', 'aria-required' => 'true'));
$this->assertTag($matcher, $form->getInput('title', null, 'The Title'), 'Line:' . __LINE__ . ' The method should return a simple input text field.');
$matcher = array('id' => 'params_show_title', 'tag' => 'fieldset', 'attributes' => array('class' => 'radio'), 'descendant' => array('tag' => 'input', 'attributes' => array('type' => 'radio', 'name' => 'params[show_title]')));
$this->assertTag($matcher, $form->getInput('show_title', 'params', '0'), 'Line:' . __LINE__ . ' The method should return a radio list.');
$form = new JFormInspector('form1', array('control' => 'jform'));
$this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$matcher = array('id' => 'jform_params_colours', 'tag' => 'select', 'attributes' => array('name' => 'jform[params][colours][]', 'multiple' => true), 'child' => array('tag' => 'option', 'content' => 'Red', 'attributes' => array('value' => 'red')), 'children' => array('count' => 4, 'only' => array('tag' => 'option')));
$this->assertTag($matcher, $form->getInput('colours', 'params', 'blue'), 'Line:' . __LINE__ . ' The method should return a select list.');
$matcher = array('id' => 'jform_translate_default', 'tag' => 'input', 'attributes' => array('name' => 'jform[translate_default]', 'value' => 'DEFAULT_KEY'));
// Test translate default
$this->assertTag($matcher, $form->getInput('translate_default'), 'Line:' . __LINE__ . ' The method should return a simple input text field whose value is untranslated since the DEFAULT_KEY does not exist in the language.');
$lang = JFactory::getLanguage();
$debug = $lang->setDebug(true);
$matcher = array('id' => 'jform_translate_default', 'tag' => 'input', 'attributes' => array('name' => 'jform[translate_default]', 'value' => '??DEFAULT_KEY??'));
$this->assertTag($matcher, $form->getInput('translate_default'), 'Line:' . __LINE__ . ' The method should return a simple input text field whose value is marked untranslated.');
$lang->load('form_test', __DIR__);
$matcher = array('id' => 'jform_translate_default', 'tag' => 'input', 'attributes' => array('name' => 'jform[translate_default]', 'value' => 'My Default'));
$this->assertTag($matcher, $form->getInput('translate_default'), 'Line:' . __LINE__ . ' The method should return a simple input text field whose value is translated.');
$lang->setDebug($debug);
}
示例2: testGetInput
/**
* Test for JForm::getInput method.
*
* @return void
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$this->assertThat($form->getInput('title', null, 'The Title'), $this->equalTo('<input type="text" name="title" id="title_id" value="The Title" class="inputbox required" required aria-required="true" />'), 'Line:' . __LINE__ . ' The method should return a simple input text field.');
$this->assertThat($form->getInput('show_title', 'params', '0'), $this->equalTo('<fieldset id="params_show_title" class="radio" >' . '<input type="radio" id="params_show_title0" name="params[show_title]" value="1" />' . '<label for="params_show_title0" >' . JText::_('JYes') . '</label>' . '<input type="radio" id="params_show_title1" name="params[show_title]" value="0" checked="checked" />' . '<label for="params_show_title1" >' . JText::_('JNo') . '</label>' . '</fieldset>'), 'Line:' . __LINE__ . ' The method should return a radio list.');
$form = new JFormInspector('form1', array('control' => 'jform'));
$this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$this->assertThat($form->getInput('colours', 'params', 'blue'), $this->equalTo('<select id="jform_params_colours" name="jform[params][colours][]" multiple>' . "\n\t" . '<option value="red">Red</option>' . "\n\t" . '<option value="blue" selected="selected">Blue</option>' . "\n\t" . '<option value="green">Green</option>' . "\n\t" . '<option value="yellow">Yellow</option>' . "\n" . '</select>' . "\n"), 'Line:' . __LINE__ . ' XML string should load successfully.');
// Test translate default
$this->assertThat($form->getInput('translate_default'), $this->equalTo('<input type="text" name="jform[translate_default]" id="jform_translate_default" value="DEFAULT_KEY" />'), 'Line:' . __LINE__ . ' The method should return a simple input text field whose value is untranslated since the DEFAULT_KEY does not exist in the language.');
$lang = JFactory::getLanguage();
$debug = $lang->setDebug(true);
$this->assertThat($form->getInput('translate_default'), $this->equalTo('<input type="text" name="jform[translate_default]" id="jform_translate_default" value="??DEFAULT_KEY??" />'), 'Line:' . __LINE__ . ' The method should return a simple input text field whose value is marked untranslated.');
$lang->load('form_test', __DIR__);
$this->assertThat($form->getInput('translate_default'), $this->equalTo('<input type="text" name="jform[translate_default]" id="jform_translate_default" value="My Default" />'), 'Line:' . __LINE__ . ' The method should return a simple input text field whose value is translated.');
$lang->setDebug($debug);
}