Changeset 7081
- Timestamp:
- 01/17/08 11:54:54 (8 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/validator/sfValidatorDate.class.php
r6875 r7081 159 159 return $clean; 160 160 } 161 162 /** 163 * @see sfValidator 164 */ 165 protected function isEmpty($value) 166 { 167 if (is_array($value)) 168 { 169 $filtered = array_filter($value); 170 171 return empty($filtered); 172 } 173 174 return parent::isEmpty($value); 175 } 161 176 } branches/1.1/test/unit/validator/sfValidatorDateTest.php
r6945 r7081 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 29, new lime_output_color());13 $t = new lime_test(33, new lime_output_color()); 14 14 15 15 $v = new sfValidatorDate(); … … 133 133 $v->setOption('with_time', true); 134 134 $t->is($v->clean(time()), time(), '->clean() output format can be change with the date_output option'); 135 136 // required 137 $v = new sfValidatorDate(); 138 foreach (array( 139 array('year' => '', 'month' => '', 'day' => ''), 140 array('year' => null, 'month' => null, 'day' => null), 141 '', 142 null, 143 ) as $input) 144 { 145 try 146 { 147 $v->clean($input); 148 $t->fail('->clean() throws an exception if the date is empty and required is true'); 149 } 150 catch (sfValidatorError $e) 151 { 152 $t->pass('->clean() throws an exception if the date is empty and required is true'); 153 } 154 }