Facades provide a “static” interface to classes that are available in the application’s service container. Unlike traditional static method calls, facades may be mocked. We can mock the call to the static facade method by using the shouldReceive
method, which will return an instance of a Mockery
mock.
// actual code
$value = Cache::get('key');
// testing
Cache::shouldReceive('get')
->once()
->with('key')
->andReturn('value');