Skip to content

Instantly share code, notes, and snippets.

@gurindersingh
Last active April 1, 2019 13:38
Show Gist options
  • Save gurindersingh/9c620f5ac4e98b6a73dbd735a428b5ef to your computer and use it in GitHub Desktop.
Save gurindersingh/9c620f5ac4e98b6a73dbd735a428b5ef to your computer and use it in GitHub Desktop.
// 1
$mock = \Mockery::mock(Newsletter::class);
$mock->shouldReceive('someMethod')->with('key', $value)->once();
app()->instance(Newsletter::class, $mock);
// 2
$this->instance(Newsletter::class, \Mockery::mock(Newsletter::class, function($mock) {
$mock->shouldReceive('someMethd')->with('key', 'value')->once();
}));
// 5.8
$this->mock(Newsletter::class, function($mock) {
$mock->shouldReceive('someMethd')->with('key', 'value')->once();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment