$f = new TestForm3(); sfForm::disableCSRFProtection(); $t->ok(!$f->isCSRFProtected(), '->disableLocalCSRFProtection() disabled CSRF protection for the current form'); sfForm::enableCSRFProtection(); $t->ok(!$f->isCSRFProtected(), '->disableLocalCSRFProtection() disabled CSRF protection for the current form, even if the global CSRF protection is enabled'); $f = new TestForm3(array(), array(), 'foo'); $t->ok(!$f->isCSRFProtected(), '->disableLocalCSRFProtection() disabled CSRF protection for the current form, even a CSRF secret is provided in the constructor'); sfForm::disableCSRFProtection(); $f = new TestForm4(); $t->ok($f->isCSRFProtected(), '->enableLocalCSRFProtection() enables CSRF protection when passed null and global CSRF is disabled'); $f = new TestForm4(array(), array('csrf_secret' => '**localsecret**')); $t->ok($f->isCSRFProtected(), '->enableLocalCSRFProtection() enables CSRF protection when passed a string global CSRF is disabled'); // ::getCSRFFieldName() ::setCSRFFieldName() $t->diag('::getCSRFFieldName() ::setCSRFFieldName()'); sfForm::enableCSRFProtection(); sfForm::setCSRFFieldName('_token_'); $f = new FormTest(); $v = $f->getValidatorSchema(); $t->ok(isset($v['_token_']), '::setCSRFFieldName() changes the CSRF token field name'); $t->is(sfForm::getCSRFFieldName(), '_token_', '::getCSRFFieldName() returns the CSRF token field name'); // ->isMultipart() $t->diag('->isMultipart()'); $f = new FormTest(); $t->ok(!$f->isMultipart(), '->isMultipart() returns false if the form does not need a multipart form'); $f->setWidgetSchema(new sfWidgetFormSchema(array('image' => new sfWidgetFormInputFile()))); $t->ok($f->isMultipart(), '->isMultipart() returns true if the form needs a multipart form'); // ->setValidators() ->setValidatorSchema() ->getValidatorSchema() ->setValidator() ->getValidator() $t->diag('->setValidators() ->setValidatorSchema() ->getValidatorSchema() ->setValidator() ->getValidator()'); $f = new FormTest(); $validators = array('first_name' => new sfValidatorPass(), 'last_name' => new sfValidatorPass()); $validatorSchema = new sfValidatorSchema($validators);