Development

Changeset 7052

You must first sign up to be able to contribute.

Changeset 7052

Show
Ignore:
Timestamp:
01/14/08 19:11:44 (8 months ago)
Author:
fabien
Message:

fixed sfValidatorSchema::clone() for pre and post validators

Files:

Legend:

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

    r7051 r7052  
    352352      $this->fields[$name] = clone $field; 
    353353    } 
     354 
     355    if (!is_null($this->preValidator)) 
     356    { 
     357      $this->preValidator = clone $this->preValidator; 
     358    } 
     359 
     360    if (!is_null($this->postValidator)) 
     361    { 
     362      $this->postValidator = clone $this->postValidator; 
     363    } 
    354364  } 
    355365} 
  • branches/1.1/test/unit/validator/sfValidatorSchemaTest.php

    r7051 r7052  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(78, new lime_output_color()); 
     13$t = new lime_test(84, new lime_output_color()); 
    1414 
    1515class PreValidator extends sfValidator 
     
    381381  $t->ok($validator == $f[$name], '__clone() clones embedded validators'); 
    382382} 
     383$t->is($v1->getPreValidator(), null, '__clone() clones the pre validator'); 
     384$t->is($v1->getPostValidator(), null, '__clone() clones the post validator'); 
     385 
     386$v->setPreValidator(new sfValidatorString(array('min_length' => 4))); 
     387$v->setPostValidator(new sfValidatorString(array('min_length' => 4))); 
     388$v1 = clone $v; 
     389$t->ok($v1->getPreValidator() !== $v->getPreValidator(), '__clone() clones the pre validator'); 
     390$t->ok($v1->getPreValidator() == $v->getPreValidator(), '__clone() clones the pre validator'); 
     391$t->ok($v1->getPostValidator() !== $v->getPostValidator(), '__clone() clones the post validator'); 
     392$t->ok($v1->getPostValidator() == $v->getPostValidator(), '__clone() clones the post validator');