Merge branch '2.0' of github.com:cakephp/cakephp into 2.0

This commit is contained in:
Ceeram 2011-07-19 10:57:41 +02:00
commit 4ae9058012
3 changed files with 89 additions and 75 deletions

View file

@ -5666,7 +5666,7 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->postLink('Delete', '/posts/delete/1');
$this->assertTags($result, array(
'form' => array(
'method' => 'post', 'action' => '/posts/delete/1', 'accept-charset' => 'utf-8',
'method' => 'post', 'action' => '/posts/delete/1',
'name' => 'preg:/post_\w+/', 'id' => 'preg:/post_\w+/', 'style' => 'display:none;'
),
'div' => array('style' => 'display:none;'),
@ -5681,7 +5681,7 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->postLink('Delete', '/posts/delete/1', array(), 'Confirm?');
$this->assertTags($result, array(
'form' => array(
'method' => 'post', 'action' => '/posts/delete/1', 'accept-charset' => 'utf-8',
'method' => 'post', 'action' => '/posts/delete/1',
'name' => 'preg:/post_\w+/', 'id' => 'preg:/post_\w+/', 'style' => 'display:none;'
),
'div' => array('style' => 'display:none;'),

View file

@ -383,28 +383,31 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
/**
* Compatibility wrapper function for assertEquals
* @param mixed $a
* @param mixed $b
*
* @param mixed $result
* @param mixed $expected
* @param string $message the text to display if the assertion is not correct
* @return void
*/
protected function assertEqual($a, $b, $message = '') {
return $this->assertEquals($a, $b, $message);
protected function assertEqual($result, $expected, $message = '') {
return $this->assertEquals($expected, $result, $message);
}
/**
* Compatibility wrapper function for assertNotEquals
* @param mixed $a
* @param mixed $b
*
* @param mixed $result
* @param mixed $expected
* @param string $message the text to display if the assertion is not correct
* @return void
*/
protected function assertNotEqual($a, $b, $message = '') {
return $this->assertNotEquals($a, $b, $message);
protected function assertNotEqual($result, $expected, $message = '') {
return $this->assertNotEquals($expected, $result, $message);
}
/**
* Compatibility wrapper function for assertRegexp
*
* @param mixed $pattern a regular expression
* @param string $string the text to be matched
* @param string $message the text to display if the assertion is not correct
@ -416,27 +419,31 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
/**
* Compatibility wrapper function for assertEquals
* @param mixed $expected
*
* @param mixed $actual
* @param mixed $expected
* @param string $message the text to display if the assertion is not correct
* @return void
*/
protected function assertIdentical($expected, $actual, $message = '') {
protected function assertIdentical($actual, $expected, $message = '') {
return $this->assertSame($expected, $actual, $message);
}
/**
* Compatibility wrapper function for assertNotEquals
* @param mixed $expected
*
* @param mixed $actual
* @param mixed $expected
* @param string $message the text to display if the assertion is not correct
* @return void
*/
protected function assertNotIdentical($expected, $actual, $message = '') {
protected function assertNotIdentical($actual, $expected, $message = '') {
return $this->assertNotSame($expected, $actual, $message);
}
/**
* Compatibility wrapper function for assertNotRegExp
*
* @param mixed $pattern a regular expression
* @param string $string the text to be matched
* @param string $message the text to display if the assertion is not correct
@ -451,6 +458,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
/**
* Compatibility wrapper function for setExpectedException
*
* @param mixed $expected the name of the Exception or error
* @param string $message the text to display if the assertion is not correct
* @return void
@ -464,6 +472,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
/**
* Compatibility wrapper function for setExpectedException
*
* @param mixed $expected the name of the Exception
* @param string $message the text to display if the assertion is not correct
* @return void
@ -474,8 +483,9 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
/**
* Compatibility wrapper function for assertSame
* @param mixed $expected
* @param mixed $actual
*
* @param mixed $first
* @param mixed $second
* @param string $message the text to display if the assertion is not correct
* @return void
*/
@ -497,15 +507,16 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
/**
* Compatibility function to test if value is between an acceptable range
* @param mixed $value
*
* @param mixed $result
* @param mixed $expected
* @param mixed $margin the rage of acceptation
* @param string $message the text to display if the assertion is not correct
* @return void
*/
protected function assertWithinMargin($value, $expected, $margin, $message = '') {
$upper = $value + $margin;
$lower = $value - $margin;
protected function assertWithinMargin($result, $expected, $margin, $message = '') {
$upper = $result + $margin;
$lower = $result - $margin;
$this->assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
}

View file

@ -335,8 +335,8 @@ class FormHelper extends AppHelper {
if ($model !== false) {
$object = $this->_getModel($model);
$key = $this->_introspectModel($model, 'key');
}
$this->setEntity($model, true);
}
if ($model !== false && $key) {
$recordExists = (
@ -419,7 +419,6 @@ class FormHelper extends AppHelper {
}
$this->requestType = strtolower($options['type']);
$action = $this->url($options['action']);
unset($options['type'], $options['action']);
@ -457,7 +456,9 @@ class FormHelper extends AppHelper {
$append = $this->Html->useTag('block', ' style="display:none;"', $append);
}
if ($model !== false) {
$this->setEntity($model, true);
}
return $this->Html->useTag('form', $action, $htmlAttributes) . $append;
}
@ -1504,14 +1505,16 @@ class FormHelper extends AppHelper {
}
$formName = uniqid('post_');
$out = $this->create(false, array('url' => $url, 'name' => $formName, 'id' => $formName, 'style' => 'display:none;'));
$formUrl = $this->url($url);
$out = $this->Html->useTag('form', $formUrl, array('name' => $formName, 'id' => $formName, 'style' => 'display:none;', 'method' => 'post'));
$out .= $this->Html->useTag('block', ' style="display:none;"', $this->Html->useTag('hidden', '_method', ' value="POST"'));
if (isset($options['data']) && is_array($options['data'])) {
foreach ($options['data'] as $key => $value) {
$out .= $this->hidden($key, array('value' => $value, 'id' => false));
}
unset($options['data']);
}
$out .= $this->end();
$out .= $this->Html->useTag('formend');
$url = '#';
$onClick = 'document.' . $formName . '.submit();';