In Laravel, Facades are used to provide a static interface to classes available inside the application's service container.

Now, unlike conventional static method calls, facades can be mocked in Laravel. It can be done using the shouldRecieve method, which shall return an instance of a facade mock.

Example

                                        

$value = Cache::get('key');

Cache::shouldReceive('get')->once()->with('key')->andReturn('value');

Suggest An Answer

No suggestions Available!