当前位置: 首页>>代码示例>>PHP>>正文


PHP JFormInspector::getFieldAttribute方法代码示例

本文整理汇总了PHP中JFormInspector::getFieldAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormInspector::getFieldAttribute方法的具体用法?PHP JFormInspector::getFieldAttribute怎么用?PHP JFormInspector::getFieldAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JFormInspector的用法示例。


在下文中一共展示了JFormInspector::getFieldAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSetFields

 /**
  * Test for JForm::setFields method.
  *
  * @return void
  */
 public function testSetFields()
 {
     $form = new JFormInspector('form1');
     $this->assertTrue($form->load(JFormDataHelper::$loadDocument), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $xml1 = simplexml_load_string('<form><field name="title" required="true" /><field name="ordering" /></form>');
     if ($xml1 === false) {
         $this->fail('Error in text XML data');
     }
     $addFields = array();
     foreach ($xml1->field as $element) {
         $addFields[] = $element;
     }
     // Test without replace.
     $this->assertTrue($form->setFields($addFields, null, false), 'Line:' . __LINE__ . ' The setFields method should return true for an existing field.');
     $this->assertEquals($form->getFieldAttribute('title', 'required', 'default'), 'default', 'Line:' . __LINE__ . ' The getFieldAttribute method should return the default value if the attribute is not set.');
     $this->assertNotFalse($form->getField('ordering'), 'Line:' . __LINE__ . ' The getField method does not return false when the field exists.');
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:22,代码来源:JFormTest.php

示例2: testSetFields

	/**
	 * Test for JForm::setFields method.
	 *
	 * @return void
	 */
	public function testSetFields()
	{
		$form = new JFormInspector('form1');

		$this->assertThat(
			$form->load(JFormDataHelper::$loadDocument),
			$this->isTrue(),
			'Line:' . __LINE__ . ' XML string should load successfully.'
		);

		$xml1 = simplexml_load_string('<form><field name="title" required="true" /><field name="ordering" /></form>');

		if ($xml1 === false)
		{
			$this->fail('Error in text XML data');
		}

		// Test without replace.

		$this->assertThat(
			$form->setFields($xml1->field, null, false),
			$this->isTrue(),
			'Line:' . __LINE__ . ' The setFields method should return true.'
		);

		$this->assertThat(
			$form->getFieldAttribute('title', 'required', 'default'),
			$this->equalTo('default'),
			'Line:' . __LINE__ . ' The label should contain just the field name.'
		);

		$this->assertThat(
			$form->getField('ordering'),
			$this->logicalNot($this->isFalse()),
			'Line:' . __LINE__ . ' The label should contain just the field name.'
		);
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:42,代码来源:JFormTest.php


注:本文中的JFormInspector::getFieldAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。