If you're mocking the with
method, you should be able to use Mockery::on()
like this:
$b = \Mockery::mock("your_builder_class");
$b->shouldReceive("with")
->with(\Mockery::on(function($x){
// test $x any way you like, for example...
// ...a simple check to see if $x["companies"] is a function
return is_callable($x["companies"]);
}))
->once()
->andReturn("hello!");