Skip to content

Instantly share code, notes, and snippets.

@robertbasic robertbasic/Test.php
Created Sep 13, 2012

Embed
What would you like to do?
Zend\Db\Adapter\Adapter mocking with mockery
<?php
protected function getAdapterMock()
{
$adapter = m::mock('Zend\Db\Adapter\Adapter');
$platform = m::mock('Zend\Db\Adapter\Platform\Mysql[getName]');
$stmt = m::mock('Zend\Db\Adapter\Driver\Pdo\Statement');
$paramContainer = m::mock('Zend\Db\Adapter\ParameterContainer');
$platform->shouldReceive('getName')
->once()
->andReturn('MySQL');
$stmt->shouldReceive('getParameterContainer')
->once()
->andReturn($paramContainer);
$stmt->shouldReceive('setSql')
->once()
->andReturn($stmt);
$stmt->shouldReceive('execute')
->once()
->andReturn(array());
$adapter->shouldReceive('getPlatform')
->once()
->andReturn($platform);
$adapter->shouldReceive('createStatement')
->once()
->andReturn($stmt);
return $adapter;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.