Development

Changeset 7437

You must first sign up to be able to contribute.

Changeset 7437

Show
Ignore:
Timestamp:
02/09/08 17:51:14 (10 months ago)
Author:
fabien
Message:

fixed sfValidatorDate for dates like 2008-02-30

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/validator/sfValidatorDate.class.php

    r7081 r7437  
    116116    } 
    117117 
     118    if (!checkdate(intval($value['month']), intval($value['day']), intval($value['year']))) 
     119    { 
     120      throw new sfValidatorError($this, 'invalid', array('value' => $value)); 
     121    } 
     122 
    118123    if ($this->getOption('with_time')) 
    119124    { 
  • branches/1.1/test/unit/validator/sfValidatorDateTest.php

    r7210 r7437  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(36, new lime_output_color()); 
     13$t = new lime_test(37, new lime_output_color()); 
    1414 
    1515$v = new sfValidatorDate(); 
     
    4848$t->is($v->clean(array('year' => '', 'month' => '', 'day' => '')), null, '->clean() accepts an array as an input'); 
    4949$t->is($v->clean(array('year' => 2008, 'month' => 02, 'day' => 29)), '2008-02-29', '->clean() recognises a leapyear'); 
     50 
    5051try 
    5152{ 
    5253  $v->clean(array('year' => '', 'month' => 1, 'day' => 15)); 
    5354  $t->fail('->clean() throws a sfValidatorError if the date is not valid'); 
     55  $t->skip('', 1); 
    5456} 
    5557catch (sfValidatorError $e) 
    5658{ 
    5759  $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'); 
    5961} 
     62 
    6063try 
    6164{ 
    6265  $v->clean(array('year' => -2, 'month' => 1, 'day' => 15)); 
    6366  $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); 
    6568} 
    6669catch (sfValidatorError $e) 
    6770{ 
    6871  $t->pass('->clean() throws a sfValidatorError if the date is not valid'); 
     72  $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError'); 
    6973} 
     74 
    7075try 
    7176{ 
    7277  $v->clean(array('year' => 2008, 'month' => 2, 'day' => 30)); 
    7378  $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); 
    7580} 
    7681catch (sfValidatorError $e) 
    7782{ 
    7883  $t->pass('->clean() throws a sfValidatorError if the date is not valid'); 
     84  $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError'); 
    7985} 
    80  
    8186 
    8287// validate regex