Skip to content

Instantly share code, notes, and snippets.

@vranac
Created August 23, 2014 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vranac/cc7ca0728e7a9564cf99 to your computer and use it in GitHub Desktop.
Save vranac/cc7ca0728e7a9564cf99 to your computer and use it in GitHub Desktop.
public function testInsertingSomething()
{
$something = array(
'something_id' => 123,
'someother_value' => 10
);
$dbMock = m::mock('Zend_Db_Adapter_Mysqli');
$dbMock->shouldReceive('fetchOne')
->with('SELECT something_id FROM somethings WHERE something_id = ?', 123)
->andReturn(false);
$dbMock->shouldReceive('insert')
->with('somethings', $something)
->andReturn(1);
$this->model->setDb($dbMock);
$this->model->saveSomething($something);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment