Permalink
Browse files

Merge branch 'release'

  • Loading branch information...
weierophinney committed Sep 14, 2012
2 parents f81be2b + c3fefd2 commit 1ff26588fe6e44c6ece137c1b2cc1feaac4e1bdb
Showing with 33 additions and 0 deletions.
  1. +18 −0 library/Zend/Form/Element/Csrf.php
  2. +15 −0 tests/ZendTest/Form/Element/CsrfTest.php
@@ -42,6 +42,24 @@ class Csrf extends Element implements InputProviderInterface, ElementPrepareAwar
*/ */
protected $csrfValidator; protected $csrfValidator;
/**
* Accepted options for Csrf:
* - csrf_options: an array used in the Csrf
*
* @param array|\Traversable $options
* @return Csrf
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($options['csrf_options'])) {
$this->setCsrfValidatorOptions($options['csrf_options']);
}
return $this;
}
/** /**
* @return array * @return array
*/ */
@@ -37,6 +37,7 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri
break; break;
default: default:
break; break;
} }
} }
} }
@@ -57,4 +58,18 @@ public function testAllowSettingCsrfValidatorOptions()
$this->assertEquals('foo', $validator->getName()); $this->assertEquals('foo', $validator->getName());
$this->assertEquals(777, $validator->getTimeout()); $this->assertEquals(777, $validator->getTimeout());
} }
public function testAllowSettingCsrfOptions()
{
$element = new CsrfElement('foo');
$element->setOptions(array(
'csrf_options' => array(
'timeout' => 777,
'salt' => 'MySalt')
));
$validator = $element->getCsrfValidator();
$this->assertEquals('foo', $validator->getName());
$this->assertEquals(777, $validator->getTimeOut());
$this->assertEquals('MySalt', $validator->getSalt());
}
} }

0 comments on commit 1ff2658

Please sign in to comment.