diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 0e4ba7384eb..e279be969a4 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -723,7 +723,7 @@ public function loadModel($modelClass = null, $id = null) { } $this->uses = ($this->uses) ? (array)$this->uses : array(); - if (!in_array($modelClass, $this->uses)) { + if (!in_array($modelClass, $this->uses, true)) { $this->uses[] = $modelClass; } diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index 9e2d1619e3e..74b1d31c025 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -447,11 +447,24 @@ public function testLoadModel() { $result = $Controller->loadModel('ControllerPost'); $this->assertTrue($result); - $this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost')); - $this->assertTrue(in_array('ControllerPost', $Controller->uses)); + $this->assertInstanceOf('ControllerPost', $Controller->ControllerPost); + $this->assertContains('ControllerPost', $Controller->uses); + } - ClassRegistry::flush(); - unset($Controller); +/** + * Test loadModel() when uses = true. + * + * @return void + */ + public function testLoadModelUsesTrue() { + $request = new CakeRequest('controller_posts/index'); + $response = $this->getMock('CakeResponse'); + $Controller = new Controller($request, $response); + $Controller->uses = true; + + $Controller->loadModel('ControllerPost'); + $this->assertInstanceOf('ControllerPost', $Controller->ControllerPost); + $this->assertContains('ControllerPost', $Controller->uses); } /**