本文整理汇总了PHP中Zend_Filter_Input::hasUnknown方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_Input::hasUnknown方法的具体用法?PHP Zend_Filter_Input::hasUnknown怎么用?PHP Zend_Filter_Input::hasUnknown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Filter_Input
的用法示例。
在下文中一共展示了Zend_Filter_Input::hasUnknown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProcessMissingThrowsException
public function testProcessMissingThrowsException()
{
$data = array('field1' => 'ab&c');
$filters = array('*' => 'StringTrim', 'field2' => 'digits');
$validators = array('field1' => array(Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'field2' => array('digits', Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED));
$input = new Zend_Filter_Input($filters, $validators, $data);
try {
$input->process();
$this->fail('Expected to catch Zend_Filter_Exception');
} catch (Zend_Exception $e) {
$this->assertType('Zend_Filter_Exception', $e, 'Expected object of type Zend_Filter_Exception, got ' . get_class($e));
$this->assertEquals("Input has missing fields", $e->getMessage());
$this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true');
$this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false');
$this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false');
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
}
}
示例2: testTranslateNotEmptyMessagesByUsingRegistry
/**
* @group ZF-3736
*/
public function testTranslateNotEmptyMessagesByUsingRegistry()
{
require_once 'Zend/Translate/Adapter/Array.php';
$translator = new Zend_Translate_Adapter_Array(array('missingMessage' => 'Still missing'), 'en');
require_once 'Zend/Registry.php';
Zend_Registry::set('Zend_Translate', $translator);
$validators = array('rule1' => array('presence' => 'required', 'fields' => array('field1', 'field2'), 'default' => array('field1default')));
$data = array();
$input = new Zend_Filter_Input(null, $validators, $data);
$this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true');
$this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false');
$this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false');
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$missing = $input->getMissing();
$this->assertType('array', $missing);
$this->assertEquals(array('rule1'), array_keys($missing));
$this->assertEquals(array("Still missing"), $missing['rule1']);
}