diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index f2cfcce9c..f4b5735e3 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -607,7 +607,7 @@ class Controller extends Object { * * @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 @@ class Controller extends Object { $this->_persist($modelClass, true, $object); $this->modelNames[] = $modelClass; } + + return true; } /** @@ -733,7 +735,7 @@ class Controller extends Object { } /** - * 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 8b63c8304..89e94aa3a 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -442,6 +442,26 @@ class ControllerTest extends CakeTestCase { 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 *