Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Easy Mocking For Cake3 Table Classes #140

Open
justinyost opened this issue Aug 7, 2015 · 0 comments
Open

Provide Easy Mocking For Cake3 Table Classes #140

justinyost opened this issue Aug 7, 2015 · 0 comments

Comments

@justinyost
Copy link
Contributor

Create a Trait that provide a getTableMock($tableName, $methodsToMock = []) method.

Maybe also create a class that extends IntegrationTestCase that pulls that trait in by default.

This is the basic flow to mock a Table Class for a Controller Structure.

$connection = \Cake\Datasource\ConnectionManager::get('test');
$config = ['connection' => $connection];

$UsersTable = $this->getMock(
    'App\Model\Table\UsersTable',
    ['save'],
    [$config]
);

$UsersTable->expects($this->once())
    ->method('save')
    ->will($this->returnValue(false));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant