I've written a method that basically looks like this:
public function collectData($input, FooInterface $foo) {
$data = array();
$data['products']['name'] = $this->some_method();
if(empty($input['bar'])) {
$data['products']['type'] = "Baz";
}
// hundreds of calls later
$foo->persist($data);
}
Now I'd like to unit test the collectData method to check if values in $data are set for certain inputs. For object parameters I'd normally use a mock like this:
$mock = $this->getMock('FooInterface');
$mock->expects($this->once())
->method('persist')
->with($this->identicalTo($expectedObject));
But how would I test for certain nested array keys (for example, if $data['products']['prices']['taxgroup'] is 1), ignoring all other keys that might be in the array? Does PHPUnit or Mockery provide such checks? Or could they easily extended to provide such a check?
Or is it better to do what I'm doing at the moment: create my own FooClassMock class that implements FooInterface and just stores the data in the persist call?