On the solr query mock object, we add a method 'addQueryParameter' that will return a callback method, whenever the method is called on the object. The returned method is implemented as a closure, getting two arguments ($key and $value) and we give it a variable within its scope ($setParams).

Whenever addQueryParameter($key, $value) is called on the original object, we will now call our anonymous function function($key, $value) which will set some values on the given variable $setParams. Mind that we have to use $setParams as a reference in order to be able to actually write on the variable within our closure.

After that we can easily check on the values written in $setParams without depending on the order of which the values are written.