Created
March 1, 2013 19:21
-
-
Save danharper/5067062 to your computer and use it in GitHub Desktop.
Laravel 4 Mocking
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 | |
class TestCase extends Illuminate\Foundation\Testing\TestCase { | |
// ... | |
public function appMock($name) | |
{ | |
$mock = Mockery::mock($name); | |
App::instance($name, $mock); | |
return $mock; | |
} | |
} |
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 | |
class JobsControllerTest extends TestCase | |
{ | |
public function testSomething() | |
{ | |
$this->appMock('JobRepositoryInterface') | |
->shouldReceive('all')->once() | |
->andReturn('lorem'); | |
$this->call('GET', 'jobs'); | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment