I have the same problem but with Cache... Have you resolved you issue?
partialMock of RateLimiter-Facade does not seem to set the cache property
See Github issue #48248 for all information
Hi all!
When writing tests for a rate-limited endpoint I am trying to partially mock the RateLimiter facade to return a constant value for the availableIn call:
public function testRateLimitsAfterCertainAmountOfBadRequests(): void {
RateLimiter::partialMock()
->shouldReceive('availableIn')
->once()
->andReturn(60);
// ...
}
When executing the test the following error occurrs:
Error: Call to a member function get() on null in C:\Users\matth\Projects\SecureDAV\vendor\laravel\framework\src\Illuminate\Cache\RateLimiter.php:143
Which corresponds to the following line inside of the RateLimiter class (attempts-function):
return $this->cache->get($key, 0);
To me it seems like using the partial mock, does not initialize the class correctly and therefore does not set the cache property.
Am I doing something wrong here or is this an actual bug? Thanks!
(Steps to reproduce in the linked Issue)
Please or to participate in this conversation.