diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index c89957765..9d1b43113 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -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; diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 5d7685de5..11c248bef 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -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 = ' @@ -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)); + } +} ?> \ No newline at end of file