Support the ongoing development of Laravel.io →
Laravel Testing
0
moderator

Hello @m-thalmann

If I'm correctly the constructor of your class will not be executed if you create a partial mock. That results that cache is never set for the partial mock of your RateLimiter. That is the reason for this error.

To be honest my advice is only to mock if really needed and if you need create the full mock and not a partial to prevent problems like this.

0

Hi @tvbeek , thanks for your reply!

Yeah that seems to be the case here, but I do really need to create a partial mock for this test. The RateLimiter used here is the default facade included in Laravel, so I would have assumed it should work, but it seems like it doesn't.

In my opinion this is a bug which should be fixed, since I think there could be more people wanting to test something similar.

Do you think my opinion on this is valid or should I just let it go?

Thanks and have a good one!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.