Development

Changeset 9535

You must first sign up to be able to contribute.

Changeset 9535

Show
Ignore:
Timestamp:
06/11/08 10:51:26 (2 years ago)
Author:
fabien
Message:

fixed sfValidatorDate Validation of Minutes '00' fails (closes #3729)

Files:

Legend:

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

    r9456 r9535  
    129129      // but second can be empty 
    130130      $empties = 
    131         (!isset($value['hour']) || !$value['hour'] ? 1 : 0) + 
    132         (!isset($value['minute']) || !$value['minute'] ? 1 : 0) + 
    133         (!isset($value['second']) || !$value['second'] ? 1 : 0) 
     131        (!isset($value['hour']) || in_array($value['hour'], array(null, ''), true) ? 1 : 0) + 
     132        (!isset($value['minute']) || in_array($value['minute'], array(null, ''), true) ? 1 : 0) + 
     133        (!isset($value['second']) || in_array($value['second'], array(null, ''), true) ? 1 : 0) 
    134134      ; 
    135135      if ($empties > 0 && $empties < 3) 
    136136      { 
    137         if (1 == $empties && (!isset($value['second']) || empty($value['second']))) 
     137        if (1 == $empties && (!isset($value['second']) || in_array($value['second'], array(null, '')))) 
    138138        { 
    139139          // OK 
  • branches/1.1/test/unit/validator/sfValidatorDateTest.php

    r9456 r9535  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(38, new lime_output_color()); 
     13$t = new lime_test(40, new lime_output_color()); 
    1414 
    1515$v = new sfValidatorDate(); 
     
    124124$t->is($v->clean(array('year' => 2005, 'month' => 10, 'day' => 15, 'hour' => 12, 'minute' => 10, 'second' => '')), '2005-10-15 12:10:00', '->clean() accepts an array as an input'); 
    125125$t->is($v->clean(array('year' => 2005, 'month' => 10, 'day' => 15, 'hour' => 12, 'minute' => 10)), '2005-10-15 12:10:00', '->clean() accepts an array as an input'); 
     126$t->is($v->clean(array('year' => 2005, 'month' => 10, 'day' => 15, 'hour' => 0, 'minute' => 10)), '2005-10-15 00:10:00', '->clean() accepts an array as an input'); 
     127$t->is($v->clean(array('year' => 2005, 'month' => 10, 'day' => 15, 'hour' => '0', 'minute' => 10)), '2005-10-15 00:10:00', '->clean() accepts an array as an input'); 
    126128try 
    127129{ 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.