Skip to content

Instantly share code, notes, and snippets.

@alihammad-gist
Created February 11, 2015 05:31
Show Gist options
  • Save alihammad-gist/f2a1516c095dd2522392 to your computer and use it in GitHub Desktop.
Save alihammad-gist/f2a1516c095dd2522392 to your computer and use it in GitHub Desktop.
<?php
/**
* @expectedException \Postit\Db\Exception
*/
function testInsertPost_throwsException()
{
$pdoMock = $this->getMockBuilder('PDO')
->disableOriginalConstructor()
->getMock();
$pdoMock->expects($this->once())
->method('prepare')
->will($this->throwException(new \PDOException));
$repo = new PostRepo($pdoMock);
$repo->insertPost(new PostEntity(null, null), 23);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment