Beispiel #1
0
$t->is($v->getErrorCodes(), $v->getValidator()->getErrorCodes(), '->getErrorCodes() is a proxy to the embedded validator method');
// ->asString()
$t->diag('->asString()');
$t->is($v->asString(), $v->getValidator()->asString(), '->asString() is a proxy to the embedded validator method');
// ->getDefaultMessages()
$t->diag('->getDefaultMessages()');
$t->is($v->getDefaultMessages(), $v->getValidator()->getDefaultMessages(), '->getDefaultMessages() is a proxy to the embedded validator method');
// ->getDefaultOptions()
$t->diag('->getDefaultOptions()');
$t->is($v->getDefaultOptions(), $v->getValidator()->getDefaultOptions(), '->getDefaultOptions() is a proxy to the embedded validator method');
// ->getMessage() ->getMessages() ->setMessage() ->setMessages()
$t->diag('->getMessage() ->getMessages() ->setMessage() ->setMessages()');
$v = new MyValidator();
$t->is($v->getMessage('required'), 'This string is required.', '->getMessage() returns a message from the embedded validator');
$v->setMessage('invalid', 'This string is invalid.');
$t->is($v->getMessages(), array('required' => 'This string is required.', 'invalid' => 'This string is invalid.', 'max_length' => '"%value%" is too long (%max_length% characters max).', 'min_length' => '"%value%" is too short (%min_length% characters min).'), '->getMessages() returns messages from the embedded validator');
$v->setMessages(array('required' => 'Required...'));
$t->is($v->getMessages(), array('required' => 'Required...', 'invalid' => 'Invalid.'), '->setMessages() sets all messages for the embedded validator');
// ->getOption() ->getOptions() ->hasOption() ->getOptions() ->setOptions()
$v = new MyValidator();
$t->is($v->getOption('trim'), true, '->getOption() returns an option from the embedded validator');
$v->setOption('trim', false);
$t->is($v->getOptions(), array('required' => true, 'trim' => false, 'empty_value' => '', 'min_length' => 2, 'max_length' => null), '->getOptions() returns an array of options from the embedded validator');
$t->is($v->hasOption('min_length'), true, '->hasOption() returns true if the embedded validator has a given option');
$v->setOptions(array('min_length' => 10));
$t->is($v->getOptions(), array('required' => true, 'trim' => false, 'empty_value' => null, 'min_length' => 10), '->setOptions() sets all options for the embedded validator');
$v = new MyValidator();
// ->clean()
$t->diag('->clean()');
try {
    $v->clean(null);