How to mock a static facade method in Laravel?

Posted by Andre Scott | Updated on

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:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers