Skip to content

Instantly share code, notes, and snippets.

@danharper
Created March 1, 2013 19:21
Show Gist options
  • Save danharper/5067062 to your computer and use it in GitHub Desktop.
Save danharper/5067062 to your computer and use it in GitHub Desktop.
Laravel 4 Mocking
<?php
class TestCase extends Illuminate\Foundation\Testing\TestCase {
// ...
public function appMock($name)
{
$mock = Mockery::mock($name);
App::instance($name, $mock);
return $mock;
}
}
<?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