diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index f2cfcce9c14..f4b5735e36a 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -607,7 +607,7 @@ function httpCodes($code = null) { * * @param string $modelClass Name of model class to load * @param mixed $id Initial ID the instanced model class should have - * @return mixed true when single model found and instance created error returned if models not found. + * @return mixed true when single model found and instance created, error returned if model not found. * @access public */ function loadModel($modelClass = null, $id = null) { @@ -657,6 +657,8 @@ function loadModel($modelClass = null, $id = null) { $this->_persist($modelClass, true, $object); $this->modelNames[] = $modelClass; } + + return true; } /** @@ -733,7 +735,7 @@ function redirect($url, $status = null, $exit = true) { } /** - * Convenience and object wrapper method for header(). Useful when doing tests and + * Convenience and object wrapper method for header(). Useful when doing tests and * asserting that particular headers have been set. * * @param string $status The header message that is being set. diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 8b63c8304bd..89e94aa3a87 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -442,6 +442,26 @@ function endTest() { App::build(); } +/** + * testLoadModel method + * + * @access public + * @return void + */ + function testLoadModel() { + $Controller =& new Controller(); + + $this->assertFalse(isset($Controller->ControllerPost)); + + $result = $Controller->loadModel('ControllerPost'); + $this->assertTrue($result); + $this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost')); + $this->assertTrue(in_array('ControllerPost', $Controller->modelNames)); + + ClassRegistry::flush(); + unset($Controller); + } + /** * testConstructClasses method *