Skip to content

Commit 76ee700

Browse files
committed
getMockForModel() method can take null for $methods parameter
1 parent d080e1d commit 76ee700

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/TestSuite/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,12 +673,12 @@ protected function skipUnless($condition, $message = '')
673673
* Mock a model, maintain fixtures and table association
674674
*
675675
* @param string $alias The model to get a mock for.
676-
* @param array $methods The list of methods to mock
676+
* @param array|null $methods The list of methods to mock
677677
* @param array $options The config data for the mock's constructor.
678678
* @throws \Cake\ORM\Exception\MissingTableClassException
679679
* @return \Cake\ORM\Table|\PHPUnit_Framework_MockObject_MockObject
680680
*/
681-
public function getMockForModel($alias, array $methods = [], array $options = [])
681+
public function getMockForModel($alias, $methods = [], array $options = [])
682682
{
683683
/** @var \Cake\ORM\Table $className */
684684
$className = $this->_getTableClassName($alias, $options);

tests/TestCase/TestSuite/TestCaseTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,16 @@ public function testGetMockForModelTable()
494494
$entity = new Entity([]);
495495
$this->assertTrue($Mock->save($entity));
496496
$this->assertFalse($Mock->save($entity));
497+
498+
$Mock = $this->getMockForModel(
499+
'Table',
500+
null,
501+
['alias' => 'Comments', 'className' => '\Cake\ORM\Table']
502+
);
503+
504+
$result = $this->getTableLocator()->get('Comments');
505+
$this->assertInstanceOf('Cake\ORM\Table', $result);
506+
$this->assertEquals('Comments', $Mock->getAlias());
497507
}
498508

499509
/**

0 commit comments

Comments
 (0)