Skip to content

Instantly share code, notes, and snippets.

@PierreRambaud
Created June 15, 2013 18:17
Show Gist options
  • Select an option

  • Save PierreRambaud/5789037 to your computer and use it in GitHub Desktop.

Select an option

Save PierreRambaud/5789037 to your computer and use it in GitHub Desktop.
Mock Zend\Db\Adapter\Adapter
<?php
$mockResult = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface');
$mockStatement = $this->getMock('Zend\Db\Adapter\Driver\StatementInterface');
$mockStatement->expects($this->any())->method('execute')->will($this->returnValue($mockResult));
$mockConnection = $this->getMock('Zend\Db\Adapter\Driver\ConnectionInterface');
$mockDriver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface');
$mockDriver->expects($this->any())->method('createStatement')->will($this->returnValue($mockStatement));
$mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection));
// setup mock adapter
$mockDbAdapter = $this->getMock('Zend\Db\Adapter\Adapter', null, array($mockDriver));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment