Permalink
Browse files

Improving test coverage on FormHelper to show the usage of the 'secur…

…e' key for inputs.

Fixing issue with select inputs that does not honor the value of 'secure'
  • Loading branch information...
lorenzo committed Apr 8, 2010
1 parent 7668894 commit 59f7cb47d34f70a6d61947fedf8b18c1a74a24d6
Showing with 33 additions and 3 deletions.
  1. +7 −2 cake/libs/view/helpers/form.php
  2. +26 −1 cake/tests/cases/libs/view/helpers/form.test.php
@@ -1412,6 +1412,9 @@ function select($fieldName, $options = array(), $selected = null, $attributes =
$escapeOptions = $attributes['escape'];
unset($attributes['escape']);
}
+ if (isset($attributes['secure'])) {
+ $secure = $attributes['secure'];
+ }
if (isset($attributes['empty'])) {
$showEmpty = $attributes['empty'];
unset($attributes['empty']);
@@ -1452,7 +1455,9 @@ function select($fieldName, $options = array(), $selected = null, $attributes =
}
if (!empty($tag) || isset($template)) {
- $this->__secure();
+ if (!isset($secure) || $secure == true) {
+ $this->__secure();
+ }
$select[] = sprintf($tag, $attributes['name'], $this->_parseAttributes(
$attributes, array('name', 'value'))
);
@@ -2169,4 +2174,4 @@ function _initInputField($field, $options = array()) {
}
}
-?>
+?>
@@ -1224,6 +1224,31 @@ function testFormSecuredRadio() {
$this->assertEqual($this->Form->fields, $expected);
}
+/**
+ * testDisableSecurityUsingForm method
+ *
+ * @access public
+ * @return void
+ */
+ function testDisableSecurityUsingForm() {
+ $this->Form->params['_Token']['key'] = 'testKey';
+ $this->Form->params['_Token']['disabledFields'] = array();
+ $this->Form->create();
+
+ $this->Form->hidden('Addresses.id', array('value' => '123456'));
+ $this->Form->input('Addresses.title');
+ $this->Form->input('Addresses.first_name', array('secure' => false));
+ $this->Form->input('Addresses.city', array('type' => 'textarea', 'secure' => false));
+ $this->Form->input('Addresses.zip', array(
+ 'type' => 'select', 'options' => array(1,2), 'secure' => false
+ ));
+
+ $result = $this->Form->fields;
+ $expected = array(
+ 'Addresses.id' => '123456', 'Addresses.title',
+ );
+ $this->assertEqual($result, $expected);
+ }
/**
* testPasswordValidation method
*
@@ -6173,4 +6198,4 @@ function testInputTemplate() {
$this->assertTags($result, $expected);
}
}
-?>
+?>

0 comments on commit 59f7cb4

Please sign in to comment.