Skip to content

Instantly share code, notes, and snippets.

@robertbasic
Created February 27, 2013 12:25
Show Gist options
  • Save robertbasic/5047567 to your computer and use it in GitHub Desktop.
Save robertbasic/5047567 to your computer and use it in GitHub Desktop.
<?php
public function testFetchAllReturnsAllAlbums()
{
$resultSet = new ResultSet();
$mockSelect = $this->getMock('Zend\Db\Sql\Select', array('columns'), array(), '', false);
$mockSelect->expects($this->once())
->method('columns')
->with(array('artist', 'title', 'id'))
->will($this->returnValue($mockSelect));
$mockSql = $this->getMock('Zend\Db\Sql\Sql', array('select'), array(), '', false);
$mockSql->expects($this->once())
->method('select')
->with()
->will($this->returnValue($mockSelect));
$mockTableGateway = $this->getMock('Zend\Db\TableGateway\TableGateway',
array('getSql', 'select'), array(), '', false);
$mockTableGateway->expects($this->once())
->method('getSql')
->with()
->will($this->returnValue($mockSql));
$mockTableGateway->expects($this->once())
->method('select')
->with($mockSelect)
->will($this->returnValue($resultSet));
$albumTable = new AlbumTable($mockTableGateway);
$this->assertSame($resultSet, $albumTable->fetchAll());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment