Changeset 5632
- Timestamp:
- 10/23/07 09:04:55 (1 year ago)
- Files:
-
- trunk/lib/validator/sfValidatorAll.class.php (modified) (2 diffs)
- trunk/lib/validator/sfValidatorAny.class.php (modified) (2 diffs)
- trunk/test/unit/validator/sfValidatorAllTest.php (modified) (2 diffs)
- trunk/test/unit/validator/sfValidatorAnyTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/validator/sfValidatorAll.class.php
r5581 r5632 55 55 } 56 56 57 if (!isset($messages['invalid'])) 58 { 59 $messages['invalid'] = null; 60 } 61 57 62 parent::__construct($options, $messages); 58 63 } … … 107 112 if (count($errors)) 108 113 { 114 if ($this->getMessage('invalid')) 115 { 116 throw new sfValidatorError($this, 'invalid', array('value' => $value)); 117 } 118 109 119 throw new sfValidatorErrorSchema($this, $errors); 110 120 } trunk/lib/validator/sfValidatorAny.class.php
r5581 r5632 55 55 } 56 56 57 if (!isset($messages['invalid'])) 58 { 59 $messages['invalid'] = null; 60 } 61 57 62 parent::__construct($options, $messages); 58 63 } … … 104 109 } 105 110 111 if ($this->getMessage('invalid')) 112 { 113 throw new sfValidatorError($this, 'invalid', array('value' => $value)); 114 } 115 106 116 throw new sfValidatorErrorSchema($this, $errors); 107 117 } trunk/test/unit/validator/sfValidatorAllTest.php
r5581 r5632 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 7, new lime_output_color());13 $t = new lime_test(12, new lime_output_color()); 14 14 15 15 $v1 = new sfValidatorString(array('max_length' => 3)); … … 52 52 $v->clean('foo'); 53 53 $t->fail('->clean() throws an sfValidatorError exception if one of the validators fails'); 54 $t->skip('', 2); 54 55 } 55 56 catch (sfValidatorError $e) 56 57 { 57 58 $t->pass('->clean() throws an sfValidatorError exception if one of the validators fails'); 59 $t->is($e[0]->getCode(), 'max_length', '->clean() throws a sfValidatorSchemaError'); 60 $t->is($e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorSchemaError'); 58 61 } 59 62 63 try 64 { 65 $v->setMessage('invalid', 'Invalid.'); 66 $v->clean('foo'); 67 $t->fail('->clean() throws an sfValidatorError exception if one of the validators fails'); 68 $t->skip('', 2); 69 } 70 catch (sfValidatorError $e) 71 { 72 $t->pass('->clean() throws an sfValidatorError exception if one of the validators fails'); 73 $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError if invalid message is not empty'); 74 $t->is(!$e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorError if invalid message is not empty'); 75 } trunk/test/unit/validator/sfValidatorAnyTest.php
r5581 r5632 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 9, new lime_output_color());13 $t = new lime_test(14, new lime_output_color()); 14 14 15 15 $v1 = new sfValidatorString(array('max_length' => 3)); … … 53 53 $v->clean('foo'); 54 54 $t->fail('->clean() throws an sfValidatorError exception if all the validators fails'); 55 $t-> fail();55 $t->skip('', 3); 56 56 } 57 57 catch (sfValidatorError $e) … … 59 59 $t->pass('->clean() throws an sfValidatorError exception if all the validators fails'); 60 60 $t->is(count($e), 2, '->clean() throws an exception with all error messages'); 61 $t->is($e[0]->getCode(), 'max_length', '->clean() throws a sfValidatorSchemaError'); 62 $t->is($e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorSchemaError'); 63 } 64 65 try 66 { 67 $v->setMessage('invalid', 'Invalid.'); 68 $v->clean('foo'); 69 $t->fail('->clean() throws an sfValidatorError exception if one of the validators fails'); 70 $t->skip('', 2); 71 } 72 catch (sfValidatorError $e) 73 { 74 $t->pass('->clean() throws an sfValidatorError exception if one of the validators fails'); 75 $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError if invalid message is not empty'); 76 $t->is(!$e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorError if invalid message is not empty'); 61 77 } 62 78