Permalink
Browse files

Remove and unskip tests that now pass.

Remove tests that are related to now removed magic in FormHelper. We no
longer have issues with duplicate field names as we don't do nearly as
much magic on them.

Update some tests for secured forms.
  • Loading branch information...
1 parent 29a9f2b commit 94fe78b3fd9a9eeaf26fdcdec779f80e12b79c0f @markstory markstory committed Feb 25, 2014
Showing with 18 additions and 63 deletions.
  1. +18 −63 tests/TestCase/View/Helper/FormHelperTest.php
@@ -1162,35 +1162,6 @@ public function testValidateHashNoModel() {
$this->assertRegExp('/540ac9c60d323c22bafe997b72c0790f39a8bdef/', $result);
}
-/**
- * Tests that models with identical field names get resolved properly
- *
- * @return void
- */
- public function testDuplicateFieldNameResolution() {
- $this->markTestIncomplete('Need to revisit once models work again.');
- $result = $this->Form->create('ValidateUser');
- $this->assertEquals(array('ValidateUser'), $this->Form->entity());
-
- $result = $this->Form->input('ValidateItem.name');
- $this->assertEquals(array('ValidateItem', 'name'), $this->Form->entity());
-
- $result = $this->Form->input('ValidateUser.name');
- $this->assertEquals(array('ValidateUser', 'name'), $this->Form->entity());
- $this->assertContains('name="ValidateUser[name]"', $result);
- $this->assertContains('type="text"', $result);
-
- $result = $this->Form->input('ValidateItem.name');
- $this->assertEquals(array('ValidateItem', 'name'), $this->Form->entity());
- $this->assertContains('name="ValidateItem[name]"', $result);
- $this->assertContains('<textarea', $result);
-
- $result = $this->Form->input('name');
- $this->assertEquals(array('ValidateUser', 'name'), $this->Form->entity());
- $this->assertContains('name="ValidateUser[name]"', $result);
- $this->assertContains('type="text"', $result);
- }
-
/**
* Tests that hidden fields generated for checkboxes don't get locked
*
@@ -1212,11 +1183,9 @@ public function testNoCheckboxLocking() {
* @return void
*/
public function testFormSecurityFields() {
- $this->markTestIncomplete('Need to revisit once models work again.');
- $key = 'testKey';
$fields = array('Model.password', 'Model.username', 'Model.valid' => '0');
- $this->Form->request->params['_csrfToken'] = $key;
+ $this->Form->request->params['_Token'] = 'testKey';
$result = $this->Form->secure($fields);
$hash = Security::hash(serialize($fields) . Configure::read('Security.salt'));
@@ -1226,29 +1195,14 @@ public function testFormSecurityFields() {
$expected = array(
'div' => array('style' => 'display:none;'),
array('input' => array(
- 'type' => 'hidden', 'name' => '_Token[fields]',
- 'value' => $hash
- )),
- array('input' => array(
- 'type' => 'hidden', 'name' => '_Token[unlocked]',
- 'value' => '', 'id' => 'preg:/TokenUnlocked\d+/'
- )),
- '/div'
- );
- $this->assertTags($result, $expected);
-
- $path = CAKE . 'Test/TestApp/Config/';
- $this->Form->Html->loadConfig('htmlhelper_tags', $path);
- $result = $this->Form->secure($fields);
- $expected = array(
- 'div' => array('class' => 'hidden'),
- array('input' => array(
- 'type' => 'hidden', 'name' => '_Token[fields]',
+ 'type' => 'hidden',
+ 'name' => '_Token[fields]',
'value' => $hash
)),
array('input' => array(
- 'type' => 'hidden', 'name' => '_Token[unlocked]',
- 'value' => '', 'id' => 'preg:/TokenUnlocked\d+/'
+ 'type' => 'hidden',
+ 'name' => '_Token[unlocked]',
+ 'value' => '',
)),
'/div'
);
@@ -1408,13 +1362,11 @@ public function testFormSecurityMultipleFields() {
* @return void
*/
public function testFormSecurityMultipleSubmitButtons() {
- $this->markTestIncomplete('Need to revisit once models work again.');
- $key = 'testKey';
- $this->Form->request->params['_csrfToken'] = $key;
+ $this->Form->request->params['_Token'] = 'testKey';
- $this->Form->create('Addresses');
- $this->Form->input('Address.title');
- $this->Form->input('Address.first_name');
+ $this->Form->create($this->article);
+ $this->Form->text('Address.title');
+ $this->Form->text('Address.first_name');
$result = $this->Form->submit('Save', array('name' => 'save'));
$expected = array(
@@ -1423,24 +1375,27 @@ public function testFormSecurityMultipleSubmitButtons() {
'/div',
);
$this->assertTags($result, $expected);
+
$result = $this->Form->submit('Cancel', array('name' => 'cancel'));
$expected = array(
'div' => array('class' => 'submit'),
'input' => array('type' => 'submit', 'name' => 'cancel', 'value' => 'Cancel'),
'/div',
);
$this->assertTags($result, $expected);
- $result = $this->Form->end(null);
+ $result = $this->Form->end();
$expected = array(
'div' => array('style' => 'display:none;'),
array('input' => array(
- 'type' => 'hidden', 'name' => '_Token[fields]',
- 'value' => 'preg:/.+/'
+ 'type' => 'hidden',
+ 'name' => '_Token[fields]',
+ 'value'
)),
array('input' => array(
- 'type' => 'hidden', 'name' => '_Token[unlocked]',
- 'value' => 'cancel%7Csave', 'id' => 'preg:/TokenUnlocked\d+/'
+ 'type' => 'hidden',
+ 'name' => '_Token[unlocked]',
+ 'value' => 'cancel%7Csave'
)),
'/div'
);

0 comments on commit 94fe78b

Please sign in to comment.