Permalink
Browse files

Merge branch 'hotfix/form-csrf-options-inheritance' into release

  • Loading branch information...
weierophinney committed Sep 14, 2012
2 parents 9ff5e2c + 9d72376 commit c3fefd2d91f3898041e35680fea9d78004104e0c
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;
/**
* 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
*/
@@ -37,6 +37,7 @@ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttri
break;
default:
break;
}
}
}
@@ -57,4 +58,18 @@ public function testAllowSettingCsrfValidatorOptions()
$this->assertEquals('foo', $validator->getName());
$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 c3fefd2

Please sign in to comment.