diff --git a/src/TestSuite/TestCase.php b/src/TestSuite/TestCase.php index 9a0a45232bb..afac6ef308c 100644 --- a/src/TestSuite/TestCase.php +++ b/src/TestSuite/TestCase.php @@ -670,6 +670,7 @@ public function getMockForModel($alias, array $methods = [], array $options = [] } TableRegistry::set($baseClass, $mock); + TableRegistry::set($alias, $mock); return $mock; } diff --git a/tests/TestCase/TestSuite/TestCaseTest.php b/tests/TestCase/TestSuite/TestCaseTest.php index 2c04edbae87..c296759540c 100644 --- a/tests/TestCase/TestSuite/TestCaseTest.php +++ b/tests/TestCase/TestSuite/TestCaseTest.php @@ -490,6 +490,7 @@ public function testGetMockForModelWithPlugin() $result = TableRegistry::get('TestPlugin.TestPluginComments'); $this->assertInstanceOf('TestPlugin\Model\Table\TestPluginCommentsTable', $result); + $this->assertSame($TestPluginComment, $result); $TestPluginComment = $this->getMockForModel('TestPlugin.TestPluginComments', ['save']);