Changeset 7437
- Timestamp:
- 02/09/08 17:51:14 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/validator/sfValidatorDate.class.php
r7081 r7437 116 116 } 117 117 118 if (!checkdate(intval($value['month']), intval($value['day']), intval($value['year']))) 119 { 120 throw new sfValidatorError($this, 'invalid', array('value' => $value)); 121 } 122 118 123 if ($this->getOption('with_time')) 119 124 { branches/1.1/test/unit/validator/sfValidatorDateTest.php
r7210 r7437 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(3 6, new lime_output_color());13 $t = new lime_test(37, new lime_output_color()); 14 14 15 15 $v = new sfValidatorDate(); … … 48 48 $t->is($v->clean(array('year' => '', 'month' => '', 'day' => '')), null, '->clean() accepts an array as an input'); 49 49 $t->is($v->clean(array('year' => 2008, 'month' => 02, 'day' => 29)), '2008-02-29', '->clean() recognises a leapyear'); 50 50 51 try 51 52 { 52 53 $v->clean(array('year' => '', 'month' => 1, 'day' => 15)); 53 54 $t->fail('->clean() throws a sfValidatorError if the date is not valid'); 55 $t->skip('', 1); 54 56 } 55 57 catch (sfValidatorError $e) 56 58 { 57 59 $t->pass('->clean() throws a sfValidatorError if the date is not valid'); 58 $t-> skip('', 1);60 $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError'); 59 61 } 62 60 63 try 61 64 { 62 65 $v->clean(array('year' => -2, 'month' => 1, 'day' => 15)); 63 66 $t->fail('->clean() throws a sfValidatorError if the date is not valid'); 64 $t-> is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError');67 $t->skip('', 1); 65 68 } 66 69 catch (sfValidatorError $e) 67 70 { 68 71 $t->pass('->clean() throws a sfValidatorError if the date is not valid'); 72 $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError'); 69 73 } 74 70 75 try 71 76 { 72 77 $v->clean(array('year' => 2008, 'month' => 2, 'day' => 30)); 73 78 $t->fail('->clean() throws a sfValidatorError if the date is not valid'); 74 $t-> is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError');79 $t->skip('', 1); 75 80 } 76 81 catch (sfValidatorError $e) 77 82 { 78 83 $t->pass('->clean() throws a sfValidatorError if the date is not valid'); 84 $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError'); 79 85 } 80 81 86 82 87 // validate regex