diff --git a/src/TestSuite/TestCase.php b/src/TestSuite/TestCase.php index d990a24dd89..66057605fa8 100644 --- a/src/TestSuite/TestCase.php +++ b/src/TestSuite/TestCase.php @@ -673,12 +673,12 @@ protected function skipUnless($condition, $message = '') * Mock a model, maintain fixtures and table association * * @param string $alias The model to get a mock for. - * @param array $methods The list of methods to mock + * @param array|null $methods The list of methods to mock * @param array $options The config data for the mock's constructor. * @throws \Cake\ORM\Exception\MissingTableClassException * @return \Cake\ORM\Table|\PHPUnit_Framework_MockObject_MockObject */ - public function getMockForModel($alias, array $methods = [], array $options = []) + public function getMockForModel($alias, $methods = [], array $options = []) { /** @var \Cake\ORM\Table $className */ $className = $this->_getTableClassName($alias, $options); diff --git a/tests/TestCase/TestSuite/TestCaseTest.php b/tests/TestCase/TestSuite/TestCaseTest.php index d6525b49ffc..2a87e53e333 100644 --- a/tests/TestCase/TestSuite/TestCaseTest.php +++ b/tests/TestCase/TestSuite/TestCaseTest.php @@ -494,6 +494,16 @@ public function testGetMockForModelTable() $entity = new Entity([]); $this->assertTrue($Mock->save($entity)); $this->assertFalse($Mock->save($entity)); + + $Mock = $this->getMockForModel( + 'Table', + null, + ['alias' => 'Comments', 'className' => '\Cake\ORM\Table'] + ); + + $result = $this->getTableLocator()->get('Comments'); + $this->assertInstanceOf('Cake\ORM\Table', $result); + $this->assertEquals('Comments', $Mock->getAlias()); } /**