From 3433f4a1f0297b8ff232bfaabe6d5ad4b4b505d4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 17 Feb 2014 11:03:49 -0500 Subject: [PATCH] Clean up changes code standards and tests. Refs #2582 --- .../Test/Case/View/Helper/FormHelperTest.php | 25 +++---------------- lib/Cake/View/Helper/FormHelper.php | 17 +++++++------ 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 873e54956..da964a449 100755 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -690,7 +690,7 @@ class FormHelperTest extends CakeTestCase { $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 @@ class FormHelperTest extends CakeTestCase { '/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 @@ class FormHelperTest extends CakeTestCase { public function testFormEnd() { $this->assertEquals('', $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' ); diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 0379f283a..fe668f8ca 100755 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -541,20 +541,21 @@ class FormHelper extends AppHelper { } /** - * 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; }