Created
February 25, 2013 21:00
-
-
Save bakura10/5033253 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function fetchAll() | |
{ | |
$sqlSelect = $this->tableGateway->getSql() | |
->select()->columns(array('artist', 'title', 'id')) | |
->join('track', 'track.album_id = album.id', array(), 'left'); | |
return $this->tableGateway->select($sqlSelect); | |
} | |
class AlbumTableTest extends PHPUnit_Framework_TestCase | |
{ | |
public function testFetchAllReturnsAllAlbums() | |
{ | |
$resultSet = new ResultSet(); | |
$mockTableGateway = $this->getMock('Zend\Db\TableGateway\TableGateway', | |
array('select', 'getSql'), array(), '', false); | |
$sqlMock = $this->getMock('Zend\Db\Sql\Sql', array('select'), array(), '', false); | |
$mockTableGateway->expects($this->once()) | |
->method('getSql') | |
->will($this->returnValue($sqlMock)); | |
$select = $this->getMock('Zend\Db\Sql\Select', array('columns'), array(), '', false); | |
// ... blablabla | |
$mockTableGateway->expects($this->once()) | |
->method('select') | |
->will($this->returnValue($resultSet)); | |
$albumTable = new AlbumTable($mockTableGateway); | |
$albumTable->fetchAll(); | |
$this->assertSame($resultSet, $albumTable->fetchAll()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment