本文整理汇总了PHP中Symfony\Component\Validator\ConstraintViolationList::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP ConstraintViolationList::__toString方法的具体用法?PHP ConstraintViolationList::__toString怎么用?PHP ConstraintViolationList::__toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Validator\ConstraintViolationList
的用法示例。
在下文中一共展示了ConstraintViolationList::__toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_throws_exception_on_validation_failure(MethodInterface $method, ValidatorInterface $validator, ConstraintViolationList $violations)
{
$attributes = ['field' => 'value'];
$constraints = ['constraints'];
$method->getValidationConstraints()->shouldBeCalled()->willReturn($constraints);
$method->getAttributes()->shouldBeCalled()->willReturn($attributes);
$violations->count()->willReturn(1);
$violations->__toString()->willReturn('');
$validator->validate($attributes, $constraints)->willReturn($violations);
$this->shouldThrow('Cardinity\\Exception\\InvalidAttributeValue')->duringValidate($method);
}
示例2: isValidRedirectUrl
/**
* Checks whether the given value is a valid URL that may probably be safely used as a redirect url.
*
* @param string $value URL to validate
*
* @return boolean true if the url is correct
*/
protected function isValidRedirectUrl($value)
{
$validator = Validation::createValidator();
$constraints = array(new Constraints\Type(array('type' => 'string')), new Constraints\Length(array('min' => $this->getParameter('min_length', 10), 'max' => $this->getParameter('max_length', 1000))), new Constraints\Url(array('protocols' => $this->getParameter('allowed_protocols', array('http', 'https')))));
if ($this->getParameter('check_base_href', true)) {
$constraints[] = new Constraints\Callback(array('methods' => array(array($this, 'hasCorrectBaseHref'))));
}
$violations = new ConstraintViolationList();
foreach ($constraints as $constraint) {
$violations->addAll($validator->validateValue($value, $constraint));
}
if ($violations->count() === 0) {
return true;
} else {
$this->getContext()->getLoggerManager()->logTo('default', \AgaviLogger::WARNING, __METHOD__, $violations->__toString());
return false;
}
}
示例3: let
function let(ConstraintViolationList $violations)
{
$violations->__toString()->willReturn($this->violation);
$this->beConstructedWith('Message', $violations);
}