Testing stateful API endpoints in Laravel, you may come across this exception message:

BadMethodCallException: Method Mockery_1_Illuminate_Cache_CacheManager::store() does not exist on this mock object

In the official documentation, the facade service mock example covers Cache::shouldReceive() but there are potential limitations. Generally APIs are stateless, so developers are less likely to hit this roadblock. Here’s a solution to it anyhow!

Read the rest of this entry »