Add tests for changes in #8387

Add tests covering the new behavior.
This commit is contained in:
mark_story 2016-04-01 23:08:31 -04:00
parent 95558d0bba
commit c551faad46

View file

@ -8073,6 +8073,34 @@ class FormHelperTest extends CakeTestCase {
));
}
/**
* Test that postLink doesn't modify the fields in the containing form.
*
* postLink() calls inside open forms should not modify the field list
* for the form.
*
* @return void
*/
public function testPostLinkSecurityHashInline() {
$hash = Security::hash(
'/posts/delete/1' .
serialize(array()) .
'' .
Configure::read('Security.salt')
);
$hash .= '%3A';
$this->Form->request->params['_Token']['key'] = 'test';
$this->Form->create('Post', ['url' => ['action' => 'add']]);
$this->Form->input('title');
$this->Form->postLink('Delete', '/posts/delete/1', ['inline' => false]);
$result = $this->View->fetch('postLink');
$this->assertEquals(array('Post.title'), $this->Form->fields);
$this->assertContains($hash, $result, 'Should contain the correct hash.');
$this->assertAttributeEquals('/posts/add', '_lastAction', $this->Form, 'lastAction was should be restored.');
}
/**
* Test using postLink with N dimensional data.
*