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


PHP JFormInspector::validateField方法代码示例

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


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

示例1: 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

示例2: testValidateField

 /**
  * Test for JForm::validateField method.
  */
 public function testValidateField()
 {
     $form = new JFormInspector('form1');
     $this->assertThat($form->load(JFormDataHelper::$validateFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $xml = $form->getXML();
     // Test error handling.
     $result = $form->validateField('wrong');
     $this->assertThat($result instanceof Exception, $this->isTrue(), 'Line:' . __LINE__ . ' Passing a non-JXmlElement should return an exception.');
     $this->assertThat($result->getCode(), $this->equalTo(-1), 'Line:' . __LINE__ . ' The correct exception should be returned.');
     $field = array_pop($xml->xpath('fields/field[@name="missingrule"]'));
     $result = $form->validateField($field, null, 'value');
     $this->assertThat($result instanceof Exception, $this->isTrue(), 'Line:' . __LINE__ . ' Having a missing validation rule should return an exception.');
     $this->assertThat($result->getCode(), $this->equalTo(-2), 'Line:' . __LINE__ . ' The correct exception should be returned.');
     $field = array_pop($xml->xpath('fields/field[@name="boolean"]'));
     $result = $form->validateField($field);
     $this->assertThat($result instanceof Exception, $this->isTrue(), 'Line:' . __LINE__ . ' A failed validation should return an exception.');
     $this->assertThat($result->getCode(), $this->equalTo(1), 'Line:' . __LINE__ . ' The correct exception should be returned.');
     $field = array_pop($xml->xpath('fields/field[@name="required"]'));
     $result = $form->validateField($field);
     $this->assertThat($result instanceof Exception, $this->isTrue(), 'Line:' . __LINE__ . ' A required field missing a value should return an exception.');
     $this->assertThat($result->getCode(), $this->equalTo(2), 'Line:' . __LINE__ . ' The correct exception should be returned.');
     // Test general usage.
     $field = array_pop($xml->xpath('fields/field[@name="boolean"]'));
     $this->assertThat($form->validateField($field, null, 'true'), $this->isTrue(), 'Line:' . __LINE__ . ' A field with a passing validate attribute set should return true.');
     $field = array_pop($xml->xpath('fields/field[@name="optional"]'));
     $this->assertThat($form->validateField($field), $this->isTrue(), 'Line:' . __LINE__ . ' A field without required set should return true.');
     $field = array_pop($xml->xpath('fields/field[@name="required"]'));
     $this->assertThat($form->validateField($field, null, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' A required field with a value should return true.');
 }
开发者ID:Joomla-on-NoSQL,项目名称:LaMojo,代码行数:32,代码来源:JFormTest.php


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