Slide 39
Slide 39 text
HOW DO YOU TEST THIS?
class BarTest extends PHPUnit_Framework_Testcase
{
! public function testGetBazById()
! {
! ! $bazId = 666;
! ! $expectedResults = array(1, 2, 3, 4, 5);
! ! $mockDb = $this->getMockBuilder('\Grumpy\Db')
! ! ! ->disableOriginalConstructor()
! ! ! ->setMethods(array('query', 'execute', 'bind'))
! ! ! ->getMock();
! ! $mockDb->expects($this->once())
! ! ! ->method('query');
! ! $mockDb->expects($this->once())
! ! ! ->method('bind');
! ! $mockDb->expects($this->once())
! ! ! ->method('execute')
! ! ! ->will($this->returnValue($expectedResults));
...!
!
! }
}