Changeset 7124
- Timestamp:
- 01/21/08 14:42:38 (9 months ago)
- Files:
-
- branches/1.1/lib/form/sfForm.class.php (modified) (1 diff)
- branches/1.1/test/unit/form/sfFormTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/form/sfForm.class.php
r7053 r7124 402 402 $this->defaults = $defaults; 403 403 404 if (self::$CSRFProtection) 405 { 406 $this->setDefault(self::$CSRFFieldName, $this->getCSRFToken(self::$CSRFSecret)); 407 } 408 404 409 $this->resetFormFields(); 405 410 } branches/1.1/test/unit/form/sfFormTest.php
r7053 r7124 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(8 3, new lime_output_color());13 $t = new lime_test(84, new lime_output_color()); 14 14 15 15 class FormTest extends sfForm … … 64 64 $t->is($f->getDefault('first_name'), 'Fabien', 'getDefault() returns a default value for a given field'); 65 65 $t->is($f->getDefault('name'), null, 'getDefault() returns null if the form does not have a default value for a given field'); 66 67 sfForm::enableCSRFProtection('*mygreatsecret*'); 68 $f = new FormTest(); 69 $f->setDefaults(array('first_name' => 'Fabien')); 70 $t->is($f->getDefault('_csrf_token'), $f->getCSRFToken('*mygreatsecret*'), '->getDefaults() keeps the CSRF token default value'); 71 sfForm::disableCSRFProtection(); 66 72 67 73 // ::enableCSRFProtection() ::disableCSRFProtection() ->isCSRFProtected() … … 78 84 79 85 $f = new FormTest(array(), array(), false); 80 $t->ok(!$f->isCSRFProtected(), '->isCSRFProtected() returns true if the form is CSRF protected');86 $t->ok(!$f->isCSRFProtected(), '->isCSRFProtected() returns true if the form is CSRF protected'); 81 87 82 88 sfForm::enableCSRFProtection('mygreatsecret');