$t->diag('->clean()'); $t->is($v->clean('foo'), 'foo', '->clean() returns the string unmodified'); $v->setOption('required', false); $t->ok($v->clean(null) === '', '->clean() converts the value to a string'); $t->ok($v->clean(1) === '1', '->clean() converts the value to a string'); $v->setOption('max_length', 2); $t->is($v->clean('fo'), 'fo', '->clean() checks the maximum length allowed'); try { $v->clean('foo'); $t->fail('"max_length" option set the maximum length of the string'); $t->skip('', 1); } catch (sfValidatorError $e) { $t->pass('"max_length" option set the maximum length of the string'); $t->is($e->getCode(), 'max_length', '->clean() throws a sfValidatorError'); } $v->setMessage('max_length', 'Too long'); try { $v->clean('foo'); $t->fail('"max_length" error message customization'); } catch (sfValidatorError $e) { $t->is($e->getMessage(), 'Too long', '"max_length" error message customization'); } $v->setOption('max_length', null); $v->setOption('min_length', 3); $t->is($v->clean('foo'), 'foo', '->clean() checks the minimum length allowed'); try { $v->clean('fo'); $t->fail('"min_length" option set the minimum length of the string'); $t->skip('', 1); } catch (sfValidatorError $e) { $t->pass('"min_length" option set the minimum length of the string');