Development

Changeset 7210

You must first sign up to be able to contribute.

Changeset 7210

Show
Ignore:
Timestamp:
01/29/08 13:49:22 (9 months ago)
Author:
pookey
Message:

adding a test for leapyear handling, and adding a test to check for invalid dates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/test/unit/validator/sfValidatorDateTest.php

    r7081 r7210  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(33, new lime_output_color()); 
     13$t = new lime_test(36, new lime_output_color()); 
    1414 
    1515$v = new sfValidatorDate(); 
     
    4747$t->is($v->clean(array('year' => '2005', 'month' => '10', 'day' => '15')), '2005-10-15', '->clean() accepts an array as an input'); 
    4848$t->is($v->clean(array('year' => '', 'month' => '', 'day' => '')), null, '->clean() accepts an array as an input'); 
     49$t->is($v->clean(array('year' => 2008, 'month' => 02, 'day' => 29)), '2008-02-29', '->clean() recognises a leapyear'); 
    4950try 
    5051{ 
     
    6768  $t->pass('->clean() throws a sfValidatorError if the date is not valid'); 
    6869} 
     70try 
     71{ 
     72  $v->clean(array('year' => 2008, 'month' => 2, 'day' => 30)); 
     73  $t->fail('->clean() throws a sfValidatorError if the date is not valid'); 
     74  $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError'); 
     75} 
     76catch (sfValidatorError $e) 
     77{ 
     78  $t->pass('->clean() throws a sfValidatorError if the date is not valid'); 
     79} 
     80 
    6981 
    7082// validate regex