According to the Laravel docs, I should be able to mock a facade via Object::shouldReceive()
, but when I do it says I cannot redeclare the method. The view works correctly when I view it in my browser, I just need to figure out how to test this correctly.
Cannot redeclare Mockery_1_Facades_MyService::shouldReceive() in /path-to-project/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php(16) : eval()'d code on line 672
Here's my test:
public function testSend()
{
MessageService::shouldReceive('find')->once()->with(1);
$this->call('GET', '/message/1/send');
$this->assertRedirectedToRoute('message.index');
}
Here's my controller:
public function send($id)
{
$message = MessageService::find($id);
$this->messageService->sendBroadcast($message);
return Redirect::route('message.index')
->with('message', "Sending message: {$message->name}, stand by...");
}