Skip to content

Instantly share code, notes, and snippets.

@Sankame
Created May 6, 2020 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sankame/c19a7080ea1ca8a2bfe7a6655cc181ac to your computer and use it in GitHub Desktop.
Save Sankame/c19a7080ea1ca8a2bfe7a6655cc181ac to your computer and use it in GitHub Desktop.
Sample code using Laravel, PHPUnit and Mockery
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testEditWhenRecordNotFound()
{
$this->mock = M::mock('alias:App\Contact')->makePartial();
$this->mock->shouldReceive('find')->once()->with(self::ID)->andReturnUsing(function(){
return null;
});
$response = $this->get('/contacts/' . self::ID . '/edit');
$response->assertRedirect('/contacts');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment