Phpunit mocking options

Hello,

I am still going through all my plugins increasing the test coverage. I was wondering if there is a good way to alter/mock plugin settings.

As the behavior of some of my plugins can change quite a lot depending on the options, I would like to test different combinations. It would cool if I could just set those options within my phpunit tests, is this possible?

An alternative way would be to hand in needed options as a param to the functions which use them, but I’d like to avoid that.

this is what i do at my plugins.

have options array property inside class with that default to kirby options

this way i can mock them in tests and test my class instance.

it gets a bit tedious if you have multiple classes but most of the time i found it easy enough to manage.

That’s a good idea, this way I wouldn’t have to hand the options to every method. Thank you, I will give this a try :slight_smile: