Permalink
Browse files

Clean up changes code standards and tests.

Refs #2582
  • Loading branch information...
1 parent b32deed commit 3433f4a1f0297b8ff232bfaabe6d5ad4b4b505d4 @markstory markstory committed Feb 17, 2014
Showing with 12 additions and 30 deletions.
  1. +3 −22 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  2. +9 −8 lib/Cake/View/Helper/FormHelper.php
@@ -690,7 +690,7 @@ public function testFormSecurityFields() {
$key = 'testKey';
$fields = array('Model.password', 'Model.username', 'Model.valid' => '0');
$secureAttributes = array('form' => 'MyTestForm');
-
+
$this->Form->request['_Token'] = array('key' => $key);
$result = $this->Form->secure($fields, $secureAttributes);
@@ -713,25 +713,6 @@ public function testFormSecurityFields() {
'/div'
);
$this->assertTags($result, $expected);
-
- $path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS;
- $this->Form->Html->loadConfig('htmlhelper_tags', $path);
- $result = $this->Form->secure($fields, $secureAttributes);
- $expected = array(
- 'div' => array('class' => 'hidden'),
- array('input' => array(
- 'type' => 'hidden', 'name' => 'data[_Token][fields]',
- 'value' => $hash, 'id' => 'preg:/TokenFields\d+/',
- 'form' => 'MyTestForm',
- )),
- array('input' => array(
- 'type' => 'hidden', 'name' => 'data[_Token][unlocked]',
- 'value' => '', 'id' => 'preg:/TokenUnlocked\d+/',
- 'form' => 'MyTestForm',
- )),
- '/div'
- );
- $this->assertTags($result, $expected);
}
/**
@@ -9052,10 +9033,10 @@ public function testFormMagicInputLabel() {
public function testFormEnd() {
$this->assertEquals('</form>', $this->Form->end());
- $result = $this->Form->end('', array('form' => 'MyTestFormWithSupportForSecurityComponent'));
+ $result = $this->Form->end('', array('form' => 'form-name'));
$expected = array(
'div' => array('class' => 'submit'),
- 'input' => array('type' => 'submit', 'value' => '', 'form' => 'MyTestFormWithSupportForSecurityComponent'),
+ 'input' => array('type' => 'submit', 'value' => ''),
'/div',
'/form'
);
@@ -541,20 +541,21 @@ public function end($options = null, $secureAttributes = array()) {
}
/**
- * Generates a hidden field with a security hash based on the fields used in the form.
+ * Generates a hidden field with a security hash based on the fields used in
+ * the form.
*
- * If $secureAttributes is set, these html attributes will be merged into the hidden input tags generated for the
- * Security Component. This is especially useful to set HTML5 attributes like 'form'.
+ * If $secureAttributes is set, these html attributes will be merged into
+ * the hidden input tags generated for the Security Component. This is
+ * especially useful to set HTML5 attributes like 'form'.
*
- * @param array|null $fields If set specifies the list of fields to use when generating the hash, else $this->fields
- * is being used.
- * @param array $secureAttributes will be passed as html attributes into the hidden input elements generated for the
- * Security Component.
+ * @param array|null $fields If set specifies the list of fields to use when
+ * generating the hash, else $this->fields is being used.
+ * @param array $secureAttributes will be passed as html attributes into the hidden
+ * input elements generated for the Security Component.
* @return string A hidden input field with a security hash
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::secure
*/
public function secure($fields = array(), $secureAttributes = array()) {
-
if (!isset($this->request['_Token']) || empty($this->request['_Token'])) {
return;
}

0 comments on commit 3433f4a

Please sign in to comment.