Development

Changeset 10894

You must first sign up to be able to contribute.

Changeset 10894

Show
Ignore:
Timestamp:
08/14/08 14:31:48 (5 months ago)
Author:
hartym
Message:

[1.2] fixes #3929

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/validator/sfValidatorBase.class.php

    r9048 r10894  
    327327  protected function isEmpty($value) 
    328328  { 
    329     return in_array($value, array(null, '')); 
     329    return in_array($value, array(null, '', array()), true); 
    330330  } 
    331331 
  • branches/1.2/test/unit/validator/sfValidatorBaseTest.php

    r7902 r10894  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(38, new lime_output_color()); 
     13$t = new lime_test(42, new lime_output_color()); 
    1414 
    1515class ValidatorIdentity extends sfValidatorBase 
     
    1919    $this->addOption('foo', 'bar'); 
    2020    $this->addMessage('foo', 'bar'); 
     21  } 
     22 
     23  public function testIsEmpty($value) 
     24  { 
     25    return $this->isEmpty($value); 
    2126  } 
    2227 
     
    107112} 
    108113$t->is($v->clean('  foo  '), '  foo  ', '->clean() does not trim whitespaces by default'); 
     114 
     115// ->isEmpty() 
     116$t->diag('->isEmpty()'); 
     117$t->is($v->testIsEmpty(null), true, 'null value isEmpty()'); 
     118$t->is($v->testIsEmpty(''), true, 'empty string value is isEmpty()'); 
     119$t->is($v->testIsEmpty(array()), true, 'null value is considered isEmpty()'); 
     120$t->is($v->testIsEmpty(false), false, 'false value !isEmpty()'); 
    109121 
    110122// ->getEmptyValue()