$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); $t->fail('->clean() throws a sfValidatorError if the value is required'); $t->skip('', 1); } catch (sfValidatorError $e) { $t->pass('->clean() throws a sfValidatorError if the value is required'); $t->is($e->getCode(), 'required', '->clean() throws a sfValidatorError'); } try { $v->clean('f'); $t->fail('->clean() throws a sfValidatorError if the wrapped validator failed'); $t->skip('', 1); } catch (sfValidatorError $e) { $t->pass('->clean() throws a sfValidatorError if the wrapped validator failed'); $t->is($e->getCode(), 'min_length', '->clean() throws a sfValidatorError'); } $t->is($v->clean(' foo '), 'foo', '->clean() cleans the value by executing the clean() method from the wrapped validator');