mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding tests for FormHelper::postButton() and SecurityComponent.
This commit is contained in:
parent
2ce2d06de2
commit
6026aa4019
1 changed files with 29 additions and 0 deletions
|
@ -5701,6 +5701,35 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTrue(strpos($result, '<input type="hidden" name="data[extra]" value="value"/>') !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that postButton adds _Token fields.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSecurePostButton() {
|
||||
$this->Form->request->params['_Token'] = array('key' => 'testkey');
|
||||
|
||||
$result = $this->Form->postButton('Delete', '/posts/delete/1');
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'method' => 'post', 'action' => '/posts/delete/1', 'accept-charset' => 'utf-8',
|
||||
'style' => 'display:none;'
|
||||
),
|
||||
array('div' => array('style' => 'display:none;')),
|
||||
array('input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST')),
|
||||
array('input' => array('type' => 'hidden', 'name' => 'data[_Token][key]', 'value' => 'testkey', 'id' => 'preg:/Token\d+/')),
|
||||
'/div',
|
||||
'button' => array('type' => 'submit'),
|
||||
'Delete',
|
||||
'/button',
|
||||
array('div' => array('style' => 'display:none;')),
|
||||
array('input' => array('type' => 'hidden', 'name' => 'data[_Token][fields]', 'value' => 'preg:/[\w\d%]+/', 'id' => 'preg:/TokenFields\d+/')),
|
||||
array('input' => array('type' => 'hidden', 'name' => 'data[_Token][unlocked]', 'value' => '', 'id' => 'preg:/TokenUnlocked\d+/')),
|
||||
'/div',
|
||||
'/form',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testPostLink method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue