Created
March 6, 2013 08:59
-
-
Save robertbasic/5097794 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Not sure about phpunit's mock building, but with mockery you could possibly mock | |
| the Article class - not the entire class, but just the createQueryBuilder method, | |
| which you set that to return a mock of the query builder, on which you further | |
| set the expectations. Something like: | |
| <?php | |
| use \Mockery as m; | |
| function testQueryBuilder() | |
| { | |
| $qbMock = m::mock(...QueryBuilderClassGoesHere...); | |
| $qbMock->shouldReceive("andWhere") | |
| ->with("a.publishDate IS NOT NULL") | |
| ->andReturn($qbMock); | |
| // ... rest of the expectations ... | |
| $article = m::mock("Article[createQueryBuilder]"); | |
| $article->shouldReceive("createQueryBuilder") | |
| ->with('a') | |
| ->andReturn($qbMock); | |
| $article->findRecent(1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment