Changeset 10802
- Timestamp:
- 08/12/08 09:10:53 (5 years ago)
- Files:
-
- branches/1.1/lib/validator/sfValidatorSchemaCompare.class.php (modified) (1 diff)
- branches/1.1/test/unit/validator/sfValidatorSchemaCompareTest.php (modified) (2 diffs)
- branches/1.2/lib/validator/sfValidatorSchemaCompare.class.php (modified) (1 diff)
- branches/1.2/test/unit/validator/sfValidatorSchemaCompareTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/validator/sfValidatorSchemaCompare.class.php
r9048 r10802 97 97 break; 98 98 case self::EQUAL: 99 $valid = $leftValue == $rightValue; 100 break; 99 101 default: 100 $valid = $leftValue == $rightValue;102 throw new InvalidArgumentException(sprintf('The operator "%s" does not exist.', $this->getOption('operator'))); 101 103 } 102 104 branches/1.1/test/unit/validator/sfValidatorSchemaCompareTest.php
r6954 r10802 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(4 3, new lime_output_color());13 $t = new lime_test(44, new lime_output_color()); 14 14 15 15 $v = new sfValidatorSchemaCompare('left', sfValidatorSchemaCompare::EQUAL, 'right'); … … 72 72 } 73 73 74 $v = new sfValidatorSchemaCompare('left', '==', 'right'); 75 try 76 { 77 $v->clean(array()); 78 $t->fail('->clean() throws an InvalidArgumentException exception if the operator does not exist'); 79 } 80 catch (InvalidArgumentException $e) 81 { 82 $t->pass('->clean() throws an InvalidArgumentException exception if the operator does not exist'); 83 } 84 74 85 // ->asString() 75 86 $t->diag('->asString()'); 76 $v = new sfValidatorSchemaCompare('left', '==', 'right');77 $t->is($v->asString(), 'left ==right', '->asString() returns a string representation of the validator');87 $v = new sfValidatorSchemaCompare('left', sfValidatorSchemaCompare::EQUAL, 'right'); 88 $t->is($v->asString(), 'left equal right', '->asString() returns a string representation of the validator'); 78 89 79 $v = new sfValidatorSchemaCompare('left', '==', 'right', array(), array('required' => 'This is required.'));80 $t->is($v->asString(), 'left ==({}, { required: \'This is required.\' }) right', '->asString() returns a string representation of the validator');90 $v = new sfValidatorSchemaCompare('left', sfValidatorSchemaCompare::EQUAL, 'right', array(), array('required' => 'This is required.')); 91 $t->is($v->asString(), 'left equal({}, { required: \'This is required.\' }) right', '->asString() returns a string representation of the validator'); branches/1.2/lib/validator/sfValidatorSchemaCompare.class.php
r10800 r10802 97 97 break; 98 98 case self::EQUAL: 99 $valid = $leftValue == $rightValue; 100 break; 99 101 default: 100 $valid = $leftValue == $rightValue;102 throw new InvalidArgumentException(sprintf('The operator "%s" does not exist.', $this->getOption('operator'))); 101 103 } 102 104 branches/1.2/test/unit/validator/sfValidatorSchemaCompareTest.php
r10800 r10802 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(8 3, new lime_output_color());13 $t = new lime_test(84, new lime_output_color()); 14 14 15 15 $v = new sfValidatorSchemaCompare('left', sfValidatorSchemaCompare::EQUAL, 'right'); … … 90 90 } 91 91 92 $v = new sfValidatorSchemaCompare('left', 'foo', 'right'); 93 try 94 { 95 $v->clean(array()); 96 $t->fail('->clean() throws an InvalidArgumentException exception if the operator does not exist'); 97 } 98 catch (InvalidArgumentException $e) 99 { 100 $t->pass('->clean() throws an InvalidArgumentException exception if the operator does not exist'); 101 } 102 92 103 // ->asString() 93 104 $t->diag('->asString()'); 94 $v = new sfValidatorSchemaCompare('left', '==', 'right');105 $v = new sfValidatorSchemaCompare('left', sfValidatorSchemaCompare::EQUAL, 'right'); 95 106 $t->is($v->asString(), 'left == right', '->asString() returns a string representation of the validator'); 96 107 97 $v = new sfValidatorSchemaCompare('left', '==', 'right', array(), array('required' => 'This is required.'));108 $v = new sfValidatorSchemaCompare('left', sfValidatorSchemaCompare::EQUAL, 'right', array(), array('required' => 'This is required.')); 98 109 $t->is($v->asString(), 'left ==({}, { required: \'This is required.\' }) right', '->asString() returns a string representation of the validator');