Skip to content
Permalink
Browse files

Fix tests

  • Loading branch information...
dereuromark committed Jan 4, 2016
1 parent 7076e6d commit cd59ab9c409ade6e868614da798f8ebd31625e21
Showing with 23 additions and 32 deletions.
  1. +20 −32 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  2. +3 −0 lib/Cake/View/Helper/FormHelper.php
@@ -1784,7 +1784,9 @@ public function testFormValidationAssociated() {
$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 @@ public function testCreate() {
$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 @@ public function testCreate() {
);
$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,15 +8566,20 @@ public function testCreate() {
$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'
);
$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 @@ public function testCreate() {
$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 @@ public function testCreate() {
$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 @@ public function testCreateOnSubmit() {
$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 @@ public function testCreateOnSubmit() {
$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 @@ public function testCreateQuerystringrequest() {
));
$expected = array(
'form' => array(
'id' => 'ContactAddForm',
'id' => 'ContactActionForm',
'method' => 'post',
'action' => '/controller/action?param1=value1&amp;param2=value2',
'accept-charset' => $encoding
@@ -8835,7 +8823,7 @@ public function testCreateQuerystringrequest() {
));
$expected = array(
'form' => array(
'id' => 'ContactAddForm',
'id' => 'ContactActionForm',
'method' => 'post',
'action' => '/controller/action?param1=value1&amp;param2=value2',
'accept-charset' => $encoding
@@ -8891,7 +8879,7 @@ public function testCreatePassedArgs() {
));
$expected = array(
'form' => array(
'id' => 'ContactAddForm',
'id' => 'ContactEditForm',
'method' => 'post',
'action' => '/contacts/edit/0/myparam',
'accept-charset' => $encoding
@@ -382,6 +382,9 @@ public function create($model = null, $options = array()) {
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'];

0 comments on commit cd59ab9

Please sign in to comment.
You can’t perform that action at this time.