本文整理汇总了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']);
}