Skip to content

Commit cd59ab9

Browse files
author
Mark Scherer
committed
Fix tests
1 parent 7076e6d commit cd59ab9

File tree

2 files changed

+23
-32
lines changed

2 files changed

+23
-32
lines changed

lib/Cake/Test/Case/View/Helper/FormHelperTest.php

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,9 @@ public function testFormValidationAssociated() {
17841784
$encoding = strtolower(Configure::read('App.encoding'));
17851785
$expected = array(
17861786
'form' => array(
1787-
'method' => 'post', 'action' => '/user_forms/login', 'id' => 'UserFormLoginForm',
1787+
'action' => '/user_forms/login',
1788+
'id' => 'UserFormLoginForm',
1789+
'method' => 'post',
17881790
'accept-charset' => $encoding
17891791
),
17901792
'div' => array('style' => 'display:none;'),
@@ -8539,7 +8541,9 @@ public function testCreate() {
85398541
$result = $this->Form->create('User', array('url' => array('action' => 'login')));
85408542
$expected = array(
85418543
'form' => array(
8542-
'id' => 'UserAddForm', 'method' => 'post', 'action' => '/users/login',
8544+
'action' => '/users/login',
8545+
'id' => 'UserLoginForm',
8546+
'method' => 'post',
85438547
'accept-charset' => $encoding
85448548
),
85458549
'div' => array('style' => 'display:none;'),
@@ -8548,7 +8552,7 @@ public function testCreate() {
85488552
);
85498553
$this->assertTags($result, $expected);
85508554

8551-
$result = $this->Form->create('User', array('action' => 'login'));
8555+
$result = $this->Form->create('User', array('url' => array('action' => 'login')));
85528556
$expected = array(
85538557
'form' => array(
85548558
'id' => 'UserLoginForm', 'method' => 'post', 'action' => '/users/login',
@@ -8562,15 +8566,20 @@ public function testCreate() {
85628566

85638567
$result = $this->Form->create('User', array('url' => '/users/login'));
85648568
$expected = array(
8565-
'form' => array('method' => 'post', 'action' => '/users/login', 'accept-charset' => $encoding, 'id' => 'UserAddForm'),
8569+
'form' => array(
8570+
'action' => '/users/login',
8571+
'id' => 'UserAddForm',
8572+
'method' => 'post',
8573+
'accept-charset' => $encoding
8574+
),
85668575
'div' => array('style' => 'display:none;'),
85678576
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
85688577
'/div'
85698578
);
85708579
$this->assertTags($result, $expected);
85718580

85728581
$this->Form->request['controller'] = 'pages';
8573-
$result = $this->Form->create('User', array('action' => 'signup'));
8582+
$result = $this->Form->create('User', array('url' => array('action' => 'signup')));
85748583
$expected = array(
85758584
'form' => array(
85768585
'id' => 'UserSignupForm', 'method' => 'post', 'action' => '/users/signup',
@@ -8588,7 +8597,7 @@ public function testCreate() {
85888597
$result = $this->Form->create(array('url' => array('action' => 'index', 'param')));
85898598
$expected = array(
85908599
'form' => array(
8591-
'id' => 'ContactAddForm', 'method' => 'post', 'action' => '/contacts/index/param',
8600+
'id' => 'ContactIndexForm', 'method' => 'post', 'action' => '/contacts/index/param',
85928601
'accept-charset' => 'utf-8'
85938602
),
85948603
'div' => array('style' => 'display:none;'),
@@ -8598,27 +8607,6 @@ public function testCreate() {
85988607
$this->assertTags($result, $expected);
85998608
}
86008609

8601-
8602-
/**
8603-
* Test create() with no URL (no "action" attribute for <form> tag)
8604-
*
8605-
* @return void
8606-
*/
8607-
public function testCreateNoUrl() {
8608-
$result = $this->Form->create(false, array('url' => false));
8609-
$expected = array(
8610-
'form' => array(
8611-
'id' => 'addForm',
8612-
'method' => 'post',
8613-
'accept-charset' => strtolower(Configure::read('App.encoding'))
8614-
),
8615-
'div' => array('style' => 'display:none;'),
8616-
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
8617-
'/div'
8618-
);
8619-
$this->assertHtml($expected, $result);
8620-
}
8621-
86228610
/**
86238611
* Test the onsubmit option for create()
86248612
*
@@ -8631,7 +8619,7 @@ public function testCreateOnSubmit() {
86318619
$result = $this->Form->create(array('url' => array('action' => 'index', 'param'), 'default' => false));
86328620
$expected = array(
86338621
'form' => array(
8634-
'id' => 'ContactAddForm', 'method' => 'post', 'onsubmit' => 'event.returnValue = false; return false;', 'action' => '/contacts/index/param',
8622+
'id' => 'ContactIndexForm', 'method' => 'post', 'onsubmit' => 'event.returnValue = false; return false;', 'action' => '/contacts/index/param',
86358623
'accept-charset' => 'utf-8'
86368624
),
86378625
'div' => array('style' => 'display:none;'),
@@ -8651,7 +8639,7 @@ public function testCreateOnSubmit() {
86518639

86528640
$expected = array(
86538641
'form' => array(
8654-
'id' => 'ContactAddForm', 'method' => 'post',
8642+
'id' => 'ContactIndexForm', 'method' => 'post',
86558643
'onsubmit' => 'someFunction();event.returnValue = false; return false;',
86568644
'action' => '/contacts/index/param',
86578645
'accept-charset' => 'utf-8'
@@ -8814,7 +8802,7 @@ public function testCreateQuerystringrequest() {
88148802
));
88158803
$expected = array(
88168804
'form' => array(
8817-
'id' => 'ContactAddForm',
8805+
'id' => 'ContactActionForm',
88188806
'method' => 'post',
88198807
'action' => '/controller/action?param1=value1&amp;param2=value2',
88208808
'accept-charset' => $encoding
@@ -8835,7 +8823,7 @@ public function testCreateQuerystringrequest() {
88358823
));
88368824
$expected = array(
88378825
'form' => array(
8838-
'id' => 'ContactAddForm',
8826+
'id' => 'ContactActionForm',
88398827
'method' => 'post',
88408828
'action' => '/controller/action?param1=value1&amp;param2=value2',
88418829
'accept-charset' => $encoding
@@ -8891,7 +8879,7 @@ public function testCreatePassedArgs() {
88918879
));
88928880
$expected = array(
88938881
'form' => array(
8894-
'id' => 'ContactAddForm',
8882+
'id' => 'ContactEditForm',
88958883
'method' => 'post',
88968884
'action' => '/contacts/edit/0/myparam',
88978885
'accept-charset' => $encoding

lib/Cake/View/Helper/FormHelper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ public function create($model = null, $options = array()) {
382382
if (isset($options['action'])) {
383383
trigger_error('Using key `action` is deprecated, use `url` directly instead.', E_USER_DEPRECATED);
384384
}
385+
if (isset($options['url']) && isset($options['url']['action'])) {
386+
$options['action'] = $options['url']['action'];
387+
}
385388

386389
if (!isset($options['id'])) {
387390
$domId = isset($options['action']) ? $options['action'] : $this->request['action'];

0 commit comments

Comments
 (0)