Skip to content

Instantly share code, notes, and snippets.

@karptonite
Created February 17, 2013 21:15
Show Gist options
  • Save karptonite/4973520 to your computer and use it in GitHub Desktop.
Save karptonite/4973520 to your computer and use it in GitHub Desktop.
Alternative facade mocking method
//this would go in the base TestCase class
public function mockFacade($facadeName)
{
$facadeClass = get_class(call_user_func([$facadeName, 'getFacadeRoot']));
$mock = m::mock($facadeClass);
call_user_func([$facadeName, 'swap'], $mock);
return $mock;
}
//it would be invoked like this:
$this->mockFacade('Session')->shouldReceive('getToken')->once()->andReturn('token');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment