mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix tests
This commit is contained in:
parent
7076e6d481
commit
cd59ab9c40
2 changed files with 23 additions and 32 deletions
|
@ -1784,7 +1784,9 @@ class FormHelperTest extends CakeTestCase {
|
|||
$encoding = strtolower(Configure::read('App.encoding'));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'method' => 'post', 'action' => '/user_forms/login', 'id' => 'UserFormLoginForm',
|
||||
'action' => '/user_forms/login',
|
||||
'id' => 'UserFormLoginForm',
|
||||
'method' => 'post',
|
||||
'accept-charset' => $encoding
|
||||
),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
|
@ -8539,7 +8541,9 @@ class FormHelperTest extends CakeTestCase {
|
|||
$result = $this->Form->create('User', array('url' => array('action' => 'login')));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'UserAddForm', 'method' => 'post', 'action' => '/users/login',
|
||||
'action' => '/users/login',
|
||||
'id' => 'UserLoginForm',
|
||||
'method' => 'post',
|
||||
'accept-charset' => $encoding
|
||||
),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
|
@ -8548,7 +8552,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->create('User', array('action' => 'login'));
|
||||
$result = $this->Form->create('User', array('url' => array('action' => 'login')));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'UserLoginForm', 'method' => 'post', 'action' => '/users/login',
|
||||
|
@ -8562,7 +8566,12 @@ class FormHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Form->create('User', array('url' => '/users/login'));
|
||||
$expected = array(
|
||||
'form' => array('method' => 'post', 'action' => '/users/login', 'accept-charset' => $encoding, 'id' => 'UserAddForm'),
|
||||
'form' => array(
|
||||
'action' => '/users/login',
|
||||
'id' => 'UserAddForm',
|
||||
'method' => 'post',
|
||||
'accept-charset' => $encoding
|
||||
),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||
'/div'
|
||||
|
@ -8570,7 +8579,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Form->request['controller'] = 'pages';
|
||||
$result = $this->Form->create('User', array('action' => 'signup'));
|
||||
$result = $this->Form->create('User', array('url' => array('action' => 'signup')));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'UserSignupForm', 'method' => 'post', 'action' => '/users/signup',
|
||||
|
@ -8588,7 +8597,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
$result = $this->Form->create(array('url' => array('action' => 'index', 'param')));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'ContactAddForm', 'method' => 'post', 'action' => '/contacts/index/param',
|
||||
'id' => 'ContactIndexForm', 'method' => 'post', 'action' => '/contacts/index/param',
|
||||
'accept-charset' => 'utf-8'
|
||||
),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
|
@ -8598,27 +8607,6 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test create() with no URL (no "action" attribute for <form> tag)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateNoUrl() {
|
||||
$result = $this->Form->create(false, array('url' => false));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'addForm',
|
||||
'method' => 'post',
|
||||
'accept-charset' => strtolower(Configure::read('App.encoding'))
|
||||
),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||
'/div'
|
||||
);
|
||||
$this->assertHtml($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the onsubmit option for create()
|
||||
*
|
||||
|
@ -8631,7 +8619,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
$result = $this->Form->create(array('url' => array('action' => 'index', 'param'), 'default' => false));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'ContactAddForm', 'method' => 'post', 'onsubmit' => 'event.returnValue = false; return false;', 'action' => '/contacts/index/param',
|
||||
'id' => 'ContactIndexForm', 'method' => 'post', 'onsubmit' => 'event.returnValue = false; return false;', 'action' => '/contacts/index/param',
|
||||
'accept-charset' => 'utf-8'
|
||||
),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
|
@ -8651,7 +8639,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'ContactAddForm', 'method' => 'post',
|
||||
'id' => 'ContactIndexForm', 'method' => 'post',
|
||||
'onsubmit' => 'someFunction();event.returnValue = false; return false;',
|
||||
'action' => '/contacts/index/param',
|
||||
'accept-charset' => 'utf-8'
|
||||
|
@ -8814,7 +8802,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'ContactAddForm',
|
||||
'id' => 'ContactActionForm',
|
||||
'method' => 'post',
|
||||
'action' => '/controller/action?param1=value1&param2=value2',
|
||||
'accept-charset' => $encoding
|
||||
|
@ -8835,7 +8823,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'ContactAddForm',
|
||||
'id' => 'ContactActionForm',
|
||||
'method' => 'post',
|
||||
'action' => '/controller/action?param1=value1&param2=value2',
|
||||
'accept-charset' => $encoding
|
||||
|
@ -8891,7 +8879,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'ContactAddForm',
|
||||
'id' => 'ContactEditForm',
|
||||
'method' => 'post',
|
||||
'action' => '/contacts/edit/0/myparam',
|
||||
'accept-charset' => $encoding
|
||||
|
|
|
@ -382,6 +382,9 @@ class FormHelper extends AppHelper {
|
|||
if (isset($options['action'])) {
|
||||
trigger_error('Using key `action` is deprecated, use `url` directly instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
if (isset($options['url']) && isset($options['url']['action'])) {
|
||||
$options['action'] = $options['url']['action'];
|
||||
}
|
||||
|
||||
if (!isset($options['id'])) {
|
||||
$domId = isset($options['action']) ? $options['action'] : $this->request['action'];
|
||||
|
|
Loading…
Reference in a new issue