Skip to content

Commit

Permalink
getMockForModel() method can take null for $methods parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mirko-pagliai committed Nov 11, 2018
1 parent d080e1d commit 76ee700
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/TestSuite/TestCase.php
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions tests/TestCase/TestSuite/TestCaseTest.php
Expand Up @@ -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());
}

/**
Expand Down

0 comments on commit 76ee700

Please sign in to comment.