janmarek/mockista — pull request #9 by MartinMystikJonas (2013-09-20 14:51:20+00:00)
Title: Custom ArgsMatcher support

Default object args matching based on spl_object_hash is not practical in case of value object, which equality is based only on properties values. Custom argsMatchers can replace default argsMatcher to support different matching policy.

Usage:
$registry = new \Mockista\Registry(new CustomArgsMatcher());
// all mocks created by registry will use CustomArgsMatcher

$mock = $registry->create();
$mock->setArgsMatcher(new CustomArgsMatcher());
// change argsMatcher only for specific mock

$obj1 = new ValueObject(10);
$obj2 = new ValueObject(10);
$mock->expects('method')->with($obj1)->once();
$mock->method($obj2);
$mock->assertExpectations();
// assert is valid if CustomArgsMatcher compare ValueObject only by value