Mocking a call to Cache::store ->get() in unit tests in Laravel

Viewed 94

I am unit testing a method that with the following call to the Cache facade. According to the laravel docs, this is the correct way to mock the call to the cache. I cannot find any docs on how to specify the store part of the call, which I am assuming is the cause of the error which is being thrown. My question is: how do I mock this Cache get call that is using the cache store?

Service Method:

    someMethod() 
{
         $option = Cache::store('ruleConditionsOptions')->get($condition->rule_conditions_option_id);
         return some stuff
}

Test:

Cache::shouldReceive('get')
            ->once()
            ->with(4)
            ->andReturn('Platform');

$result = someMethodCall
$this->assertSomething

Error:

Received Mockery_0_Illuminate_Cache_CacheManager::store(), but no expectations were specified
0 Answers
Related