Created
January 14, 2014 06:50
-
-
Save coreymcmahon/8414199 to your computer and use it in GitHub Desktop.
Building Testable Applications using the Repository Pattern - http://www.slashnode.com/the-repository-pattern/
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
<?php | |
use Mockery as m; | |
class PostControllerTest extends PHPUnit_Framework_Testcase { | |
private $postRepository; | |
private $postController; | |
public function setUp() | |
{ | |
parent::setup(); | |
$this->postRepository = m::mock('Acme\Storage\PostRepository'); | |
// inject the mocked version of the repository | |
$this->postController = new Acme\Controllers\PostController($this->postRepository); | |
} | |
public function tearDown() | |
{ | |
m::close(); | |
parent::tearDown(); | |
} | |
public function testIndex() | |
{ | |
$this->postRepository->shoudlReceive('paginate')->once()->andReturn(array()); | |
$response = $this->postController->index(); | |
$this->assertEqual(array(), $response); | |
} | |
// etc... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment