mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
"Fixes #4339, Providing null for variable with underscores leads to camelcased variable in view"
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6626 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
118c35f0d0
commit
06d06c85d9
2 changed files with 22 additions and 4 deletions
|
@ -577,7 +577,7 @@ class Controller extends Object {
|
|||
if ($name == 'title') {
|
||||
$this->pageTitle = $value;
|
||||
} else {
|
||||
if ($two === null) {
|
||||
if ($two === null && is_array($one)) {
|
||||
$this->viewVars[Inflector::variable($name)] = $value;
|
||||
} else {
|
||||
$this->viewVars[$name] = $value;
|
||||
|
|
|
@ -105,9 +105,8 @@ class ControllerTest extends CakeTestCase {
|
|||
|
||||
function testFlash() {
|
||||
$Controller =& new Controller();
|
||||
ob_start();
|
||||
$Controller->flash('this should work', '/flash');
|
||||
$result = ob_get_clean();
|
||||
$result = $Controller->output;
|
||||
|
||||
$expected = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -128,6 +127,25 @@ class ControllerTest extends CakeTestCase {
|
|||
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
}
|
||||
|
||||
function testControllerSet() {
|
||||
$Controller =& new Controller();
|
||||
$Controller->set('variable_with_underscores', null);
|
||||
$this->assertTrue(array_key_exists('variable_with_underscores', $Controller->viewVars));
|
||||
|
||||
$Controller->viewVars = array();
|
||||
$viewVars = array('ModelName' => array('id' => 1, 'name' => 'value'));
|
||||
$Controller->set($viewVars);
|
||||
$this->assertTrue(array_key_exists('modelName', $Controller->viewVars));
|
||||
|
||||
$Controller->viewVars = array();
|
||||
$Controller->set('variable_with_underscores', 'value');
|
||||
$this->assertTrue(array_key_exists('variable_with_underscores', $Controller->viewVars));
|
||||
|
||||
$Controller->viewVars = array();
|
||||
$viewVars = array('ModelName' => 'name');
|
||||
$Controller->set($viewVars);
|
||||
$this->assertTrue(array_key_exists('modelName', $Controller->viewVars));
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue