本文整理汇总了PHP中JFormInspector类的典型用法代码示例。如果您正苦于以下问题:PHP JFormInspector类的具体用法?PHP JFormInspector怎么用?PHP JFormInspector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JFormInspector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testGetInput
/**
* Test the getInput method.
*
* @return void
*
* @since 11.4
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat(
$form->load('<form><field name="editors" type="plugins" folder="editors" /></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldPlugins($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
$this->isTrue(),
'Line:' . __LINE__ . ' The setup method should return true.'
);
if (!is_null(self::$driver))
{
$this->assertThat(
strlen($field->input),
$this->greaterThan(0),
'Line:' . __LINE__ . ' The getInput method should return something without error.'
);
}
else
{
$this->markTestSkipped();
}
// TODO: Should check all the attributes have come in properly.
}
开发者ID:robschley,项目名称:joomla-platform,代码行数:40,代码来源:JFormFieldPluginsTest.php
示例2: testGetInput
/**
* Test the getInput method.
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat(
$form->load('<form><field name="checkbox" type="checkbox" /></form>'),
$this->isTrue(),
'Line:'.__LINE__.' XML string should load successfully.'
);
$field = new JFormFieldCheckbox($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
$this->isTrue(),
'Line:'.__LINE__.' The setup method should return true.'
);
$this->assertThat(
strlen($field->input),
$this->greaterThan(0),
'Line:'.__LINE__.' The getInput method should return something without error.'
);
// TODO: Should check all the attributes have come in properly.
}
开发者ID:realityking,项目名称:JAJAX,代码行数:29,代码来源:JFormFieldCheckboxTest.php
示例3: testGetInput
/**
* Test the getInput method.
*
* @since 11.1
* @todo Should check all the attributes have come in properly.
*
* @return void
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat(
$form->load('<form><field name="componentlayout" type="componentlayout" /></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldComponentlayout($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
$this->isTrue(),
'Line:' . __LINE__ . ' The setup method should return true.'
);
$this->markTestIncomplete('Problems encountered in next assertion');
$this->assertThat(
strlen($field->input),
$this->greaterThan(0),
'Line:' . __LINE__ . ' The getInput method should return something without error.'
);
}
开发者ID:realityking,项目名称:joomla-platform,代码行数:34,代码来源:JFormFieldComponentLayoutTest.php
示例4: testGetInput
/**
* Test the getInput method.
*
* @return void
*
* @since 11.1
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat(
$form->load('<form><field name="usergroup" type="usergroup" class="inputbox" disabled="true" onclick="window.reload()"><option value="*">None</option><item value="fake">Fake</item></field></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldUsergroup($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
$this->isTrue(),
'Line:' . __LINE__ . ' The setup method should return true.'
);
if (!is_null(self::$driver))
{
$this->assertThat(
strlen($field->input),
$this->greaterThan(0),
'Line:' . __LINE__ . ' The getInput method should return something without error.'
);
}
else
{
$this->markTestSkipped();
}
// TODO: Should check all the attributes have come in properly.
}
开发者ID:robschley,项目名称:joomla-platform,代码行数:40,代码来源:JFormFieldUsergroupTest.php
示例5: testGetInput
/**
* Test the getInput method.
*
* @return void
*
* @since 11.1
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat(
$form->load('<form><field name="accesslevel" type="accesslevel" /></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldAccessLevel($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
$this->isTrue(),
'Line:' . __LINE__ . ' The setup method should return true.'
);
if (!is_null(self::$driver))
{
$this->assertThat(
strlen($field->input),
$this->greaterThan(0),
'Line:' . __LINE__ . ' The getInput method should return something without error.'
);
}
else
{
$this->markTestSkipped();
}
}
开发者ID:realityking,项目名称:joomla-platform,代码行数:38,代码来源:JFormFieldAccessLevelTest.php
示例6: testGetOptions
/**
* Test the getOptions method.
*
* @return void
*
* @since 11.3
*/
public function testGetOptions()
{
$form = new JFormInspector('form1');
$this->assertThat(
$form->load('<form><field name="radio" type="radio"><option value="0">No</option><item value="1">Yes</item></field></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldRadio($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
$this->isTrue(),
'Line:' . __LINE__ . ' The setup method should return true.'
);
$this->assertThat(
strlen($field->input),
$this->logicalNot(
$this->StringContains('Yes')
),
'Line:' . __LINE__ . ' The field should not contain a Yes option.'
);
}
开发者ID:robschley,项目名称:joomla-platform,代码行数:33,代码来源:JFormFieldRadioTest.php
示例7: testGetInput
/**
* Test the getInput method.
*
* @return void
*
* @since 12.1
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat(
$form->load('<form><field name="sql" type="sql" key_field="id" query="SELECT * FROM `jos_categories`"><option value="*">None</option></field></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldSQL($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
$this->isTrue(),
'Line:' . __LINE__ . ' The setup method should return true.'
);
if (!is_null(self::$driver))
{
$this->assertThat(
strlen($field->input),
$this->greaterThan(0),
'Line:' . __LINE__ . ' The getInput method should return something without error.'
);
}
else
{
$this->markTestSkipped();
}
}
开发者ID:robschley,项目名称:joomla-platform,代码行数:38,代码来源:JFormFieldSQLTest.php
示例8: testGetInput
/**
* Test the getInput method.
*
* @return void
*
* @since 11.1
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load('<form><field name="cachehandler" type="cachehandler" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldCacheHandler($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
}
开发者ID:karimzg,项目名称:joomla,代码行数:15,代码来源:JFormFieldCacheHandlerTest.php
示例9: testGetInput
/**
* Tests the getInput method.
*
* @return void
*
* @since 3.1
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load('<form><field name="moduletag" type="moduletag" label="Module Tag" description="Module Tag listing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldModuletag($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertContains('<option value="nav">nav</option>', $field->input, 'Line:' . __LINE__ . ' The getInput method should return an option with various opening tags, verify nav tag is in list.');
}
开发者ID:karimzg,项目名称:joomla,代码行数:15,代码来源:JFormFieldModuletagTest.php
示例10: testGetInput
/**
* Tests the getInput method.
*
* @return void
*
* @since 3.1
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load('<form><field name="helpsite" type="helpsite" label="Help Site" description="Help Site listing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldHelpsite($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertContains('<option value="http://help.joomla.org/proxy/index.php?option=com_help&keyref=Help{major}{minor}:{keyref}">', $field->input, 'Line:' . __LINE__ . ' The getInput method should return an option with a link to the help site.');
}
开发者ID:karimzg,项目名称:joomla,代码行数:15,代码来源:JFormFieldHelpsiteTest.php
示例11: testGetInput
/**
* Test the getInput method.
*
* @since 11.3
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load('<form><field name="checkboxes" type="checkboxes" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldCheckboxes($form);
$this->markTestIncomplete();
// TODO: Should check all the attributes have come in properly.
}
开发者ID:Radek-Suski,项目名称:joomla-platform,代码行数:13,代码来源:JFormFieldCheckboxesTest.php
示例12: testGetInput
/**
* Test the getInput method.
*
* @return void
*
* @since 12.1
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load('<form><field name="color" type="color" disabled="true" onchange="window.reload()" class="inputbox" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldColor($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.');
}
开发者ID:rvsjoen,项目名称:joomla-platform,代码行数:15,代码来源:JFormFieldColorTest.php
示例13: testGetInput
/**
* Test the getInput method.
*
* @return void
*
* @since 11.3
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="mysqli" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldDatabaseConnection($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error; in this case, a "Mysqli" option.');
$this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="non-existing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldDatabaseConnection($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error; in this case, a "None" option.');
// TODO: Should check all the attributes have come in properly.
}
开发者ID:karimzg,项目名称:joomla,代码行数:20,代码来源:JFormFieldDatabaseConnectionTest.php
示例14: testGetInput
/**
* Test the getInput method.
*
* @return void
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
// Test a traditional hidden field type.
$this->assertThat(
$form->load('<form><field name="hidden" type="hidden" label="foo" /></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldHidden($form);
$this->assertThat(
$form->getLabel('hidden'),
$this->equalTo(''),
'Line:' . __LINE__ . ' The label of a hidden element should be nothing.'
);
// Test a field with attribute hidden = true.
$this->assertThat(
$form->load('<form><field name="hidden" type="text" label="foo" hidden="true" /></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldHidden($form);
$this->assertThat(
$form->getLabel('hidden'),
$this->equalTo(''),
'Line:' . __LINE__ . ' The label of a hidden element should be nothing.'
);
// Test a field with attribute hidden = false.
$this->assertThat(
$form->load('<form><field name="hidden" type="text" label="foo" hidden="false" /></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldHidden($form);
$this->assertThat(
$form->getLabel('hidden'),
$this->equalTo('<label id="hidden-lbl" for="hidden" class="">foo</label>'),
'Line:' . __LINE__ . ' The label of a non-hidden element should be some HTML.'
);
}
开发者ID:robschley,项目名称:joomla-platform,代码行数:57,代码来源:JFormFieldHiddenTest.php
示例15: testGetOptions
/**
* Test the getOptions method.
*
* @return void
*
* @since 11.3
*/
public function testGetOptions()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load('<form><field name="integer" type="integer" first="1" last="-5" step="1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldInteger($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertThat($field->input, $this->logicalNot($this->StringContains('<option')), 'Line:' . __LINE__ . ' The field should not contain any options.');
$this->assertThat($form->load('<form><field name="integer" type="integer" first="-7" last="-5" step="1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldInteger($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertThat($field->input, $this->StringContains('<option value="-7">-7</option>'), 'Line:' . __LINE__ . ' The field should contain -7 through -5 as options.');
$this->assertThat($form->load('<form><field name="integer" type="integer" first="-7" last="-5" step="-1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldInteger($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertThat($field->input, $this->logicalNot($this->StringContains('<option')), 'Line:' . __LINE__ . ' The field should not contain any options.');
$this->assertThat($form->load('<form><field name="integer" type="integer" first="-5" last="-7" step="-1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldInteger($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertThat($field->input, $this->StringContains('<option value="-7">-7</option>'), 'Line:' . __LINE__ . ' The field should contain -5 through -7 as options.');
}
开发者ID:rvsjoen,项目名称:joomla-platform,代码行数:27,代码来源:JFormFieldIntegerTest.php
示例16: testGetLabel
/**
* Test the getLabel method.
*/
public function testGetLabel()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load('<form><field name="spacer" type="spacer" description="spacer" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldSpacer($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertEquals($field->label, '<span class="spacer"><span class="before"></span><span class=""><label id="spacer-lbl" class="hasTip" title="spacer::spacer">spacer</label></span><span class="after"></span></span>', 'Line:' . __LINE__ . ' The getLabel method should return something without error.');
$this->assertThat($form->load('<form><field name="spacer" type="spacer" class="text" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldSpacer($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertEquals($field->label, '<span class="spacer"><span class="before"></span><span class="text"><label id="spacer-lbl" class="">spacer</label></span><span class="after"></span></span>', 'Line:' . __LINE__ . ' The getLabel method should return something without error.');
$this->assertThat($form->load('<form><field name="spacer" type="spacer" class="text" label="MyLabel" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldSpacer($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertEquals($field->label, '<span class="spacer"><span class="before"></span><span class="text"><label id="spacer-lbl" class="">MyLabel</label></span><span class="after"></span></span>', 'Line:' . __LINE__ . ' The getLabel method should return something without error.');
$this->assertThat($form->load('<form><field name="spacer" type="spacer" hr="true" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldSpacer($form);
$this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.');
$this->assertEquals($field->label, '<span class="spacer"><span class="before"></span><span class=""><hr class="" /></span><span class="after"></span></span>', 'Line:' . __LINE__ . ' The getLabel method should return something without error.');
}
开发者ID:raquelsa,项目名称:Joomla,代码行数:23,代码来源:JFormFieldSpacerTest.php
示例17: testSetup
/**
* Tests the JFormField::setup method
*
* @covers JFormField::setup
* @covers JFormField::__get
*
* @return void
*/
public function testSetup()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldInspector($form);
// Standard usage.
$xml = $form->getXML();
$title = array_pop($xml->xpath('fields/field[@name="title"]'));
$this->assertThat($field->setup($title, 'The title'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->name, $this->equalTo('title'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->value, $this->equalTo('The title'), 'Line:' . __LINE__ . ' The value should be set from the setup method argument.');
$this->assertThat($field->id, $this->equalTo('title_id'), 'Line:' . __LINE__ . ' The property should be set from the XML (non-alpha transposed to underscore).');
$this->assertThat((string) $title['class'], $this->equalTo('inputbox required'), 'Line:' . __LINE__ . ' The property should be set from the XML.');
$this->assertThat($field->validate, $this->equalTo('none'), 'Line:' . __LINE__ . ' The property should be set from the XML.');
$this->assertThat($field->multiple, $this->isFalse(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->required, $this->isTrue(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->input, $this->equalTo(''), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$equals = '<label id="title_id-lbl" for="title_id" class="hasTip required" title="Title::The title.">' . 'Title<span class="star"> *</span></label>';
$this->assertThat($field->label, $this->equalTo($equals), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->title, $this->equalTo('Title'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->unexisting, $this->equalTo(null), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
// Test multiple attribute and form group name.
$colours = array_pop($xml->xpath('fields/fields[@name="params"]/field[@name="colours"]'));
$this->assertThat($field->setup($colours, 'green', 'params'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->id, $this->equalTo('params_colours'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->name, $this->equalTo('params[colours][]'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->multiple, $this->isTrue(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertEquals($field->group, 'params', 'Line:' . __LINE__ . ' The property should be set to the the group name.');
// Test hidden field type.
$id = array_pop($xml->xpath('fields/field[@name="id"]'));
$this->assertThat($field->setup($id, 42), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->hidden, $this->isTrue(), 'Line:' . __LINE__ . ' The hidden property should be set from the field type.');
// Test hidden attribute.
$createdDate = array_pop($xml->xpath('fields/field[@name="created_date"]'));
$this->assertThat($field->setup($createdDate, '0000-00-00 00:00:00'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->hidden, $this->isTrue(), 'Line:' . __LINE__ . ' The hidden property should be set from the hidden attribute.');
// Test automatic generated name.
$spacer = array_pop($xml->xpath('fields/field[@type="spacer"]'));
$this->assertThat($field->setup($spacer, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->name, $this->equalTo('__field1'), 'Line:' . __LINE__ . ' The spacer name should be set using an automatic generated name.');
// Test nested groups and forced multiple.
$comment = array_pop($xml->xpath('fields/fields[@name="params"]/fields[@name="subparams"]/field[@name="comment"]'));
$field->forceMultiple = true;
$this->assertThat($field->setup($comment, 'My comment', 'params.subparams'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->id, $this->equalTo('params_subparams_comment'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->name, $this->equalTo('params[subparams][comment][]'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertEquals($field->group, 'params.subparams', 'Line:' . __LINE__ . ' The property should be set to the the group name.');
$this->assertEquals($field->element['class'], 'required', 'Line:' . __LINE__ . ' The property should be computed from the XML.');
}
开发者ID:ZerGabriel,项目名称:joomla-platform,代码行数:57,代码来源:JFormFieldTest.php
示例18: testGetTitle
/**
* Tests the JFormField::getTitle method
*
* @return void
*/
public function testGetTitle()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldInspector($form);
// Standard usage.
$xml = $form->getXml();
$data = $xml->xpath('fields/field[@name="title"]');
$title = array_pop($data);
$this->assertThat($field->setup($title, 'The title'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->getTitle(), $this->equalTo('Title'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
// Hidden field
$data = $xml->xpath('fields/field[@name="id"]');
$id = array_pop($data);
$this->assertThat($field->setup($id, 'id'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->getTitle(), $this->equalTo(''), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
}
开发者ID:klas,项目名称:joomla-cms,代码行数:22,代码来源:JFormFieldTest.php
示例19: testSetup
/**
* Tests the JForm::setup method
*/
public function testSetup()
{
$form = new JFormInspector('form1');
$this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldInspector($form);
// Error handling.
$wrong = 'wrong';
$this->assertThat($field->setup($wrong, 0), $this->isFalse(), 'Line:' . __LINE__ . ' If not a form object, setup should return false.');
// Standard usage.
$xml = $form->getXML();
$title = array_pop($xml->xpath('fields/field[@name="title"]'));
$this->assertThat($field->setup($title, 'The title'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->name, $this->equalTo('title'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->value, $this->equalTo('The title'), 'Line:' . __LINE__ . ' The value should be set from the setup method argument.');
$this->assertThat($field->id, $this->equalTo('title_id'), 'Line:' . __LINE__ . ' The property should be set from the XML (non-alpha transposed to underscore).');
$this->assertThat((string) $title['class'], $this->equalTo('inputbox required'), 'Line:' . __LINE__ . ' The property should be set from the XML.');
$this->assertThat($field->validate, $this->equalTo('none'), 'Line:' . __LINE__ . ' The property should be set from the XML.');
$this->assertThat($field->multiple, $this->isFalse(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->required, $this->isTrue(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
// Test multiple attribute and form group name.
$colours = array_pop($xml->xpath('fields/fields[@name="params"]/field[@name="colours"]'));
$this->assertThat($field->setup($colours, 'green', 'params'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->id, $this->equalTo('params_colours'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->name, $this->equalTo('params[colours][]'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertThat($field->multiple, $this->isTrue(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
$this->assertEquals($field->group, 'params', 'Line:' . __LINE__ . ' The property should be set to the the group name.');
// Test hidden field type.
$id = array_pop($xml->xpath('fields/field[@name="id"]'));
$this->assertThat($field->setup($id, 42), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->hidden, $this->isTrue(), 'Line:' . __LINE__ . ' The hidden property should be set from the field type.');
// Test hidden attribute.
$createdDate = array_pop($xml->xpath('fields/field[@name="created_date"]'));
$this->assertThat($field->setup($createdDate, '0000-00-00 00:00:00'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->hidden, $this->isTrue(), 'Line:' . __LINE__ . ' The hidden property should be set from the hidden attribute.');
// Test automatic generated name.
$spacer = array_pop($xml->xpath('fields/field[@type="spacer"]'));
$this->assertThat($field->setup($spacer, ''), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
$this->assertThat($field->name, $this->equalTo('__field1'), 'Line:' . __LINE__ . ' The spacer name should be set using an automatic generated name.');
}
开发者ID:nibra,项目名称:joomla-platform,代码行数:42,代码来源:JFormFieldTest.php
示例20: testValidateField_missingRule
/**
* Test for JForm::validateField method for missing rule exception.
*
* @return void
*
* @since 12.1
*
* @expectedException UnexpectedValueException
*/
public function testValidateField_missingRule()
{
$form = new JFormInspector('form1');
$form->load(JFormDataHelper::$validateFieldDocument);
$xml = $form->getXml();
$data = $xml->xpath('fields/field[@name="missingrule"]');
$field = array_pop($data);
$form->validateField($field, null, 'value');
}
开发者ID:SysBind,项目名称:joomla-cms,代码行数:18,代码来源:JFormTest.php
注:本文中的JFormInspector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论