本文整理匯總了PHP中Zend\Validator\ValidatorChain::getValidators方法的典型用法代碼示例。如果您正苦於以下問題:PHP ValidatorChain::getValidators方法的具體用法?PHP ValidatorChain::getValidators怎麽用?PHP ValidatorChain::getValidators使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Validator\ValidatorChain
的用法示例。
在下文中一共展示了ValidatorChain::getValidators方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testCanAttachMultipleValidatorsOfTheSameTypeAsDiscreteInstances
/**
* @group ZF-412
*/
public function testCanAttachMultipleValidatorsOfTheSameTypeAsDiscreteInstances()
{
$this->validator->addByName('Callback', array('callback' => function ($value) {
return true;
}, 'messages' => array('callbackValue' => 'This should not be seen in the messages')));
$this->validator->addByName('Callback', array('callback' => function ($value) {
return false;
}, 'messages' => array('callbackValue' => 'Second callback trapped')));
$this->assertEquals(2, count($this->validator));
$validators = $this->validator->getValidators();
$compare = null;
foreach ($validators as $validator) {
$this->assertNotSame($compare, $validator);
$compare = $validator;
}
$this->assertFalse($this->validator->isValid('foo'));
$messages = $this->validator->getMessages();
$found = false;
$test = 'Second callback trapped';
foreach ($messages as $messageSet) {
if (is_string($messageSet) && $messageSet === $test) {
$found = true;
break;
}
if (is_array($messageSet) && in_array('Second callback trapped', $messageSet)) {
$found = true;
break;
}
}
$this->assertTrue($found);
}
示例2: testAttachByNameAllowsSpecifyingBreakChainOnFailureFlagViaOptions
/**
* @group zfcampus_zf-apigility-admin_89
* @dataProvider breakChainFlags
*/
public function testAttachByNameAllowsSpecifyingBreakChainOnFailureFlagViaOptions($option)
{
$this->validator->attachByName('GreaterThan', array($option => true, 'min' => 1));
$this->assertEquals(1, count($this->validator));
$validators = $this->validator->getValidators();
$spec = array_shift($validators);
$this->assertInternalType('array', $spec);
$this->assertArrayHasKey('instance', $spec);
$validator = $spec['instance'];
$this->assertInstanceOf('Zend\\Validator\\GreaterThan', $validator);
$this->assertArrayHasKey('breakChainOnFailure', $spec);
$this->assertTrue($spec['breakChainOnFailure']);
}