public function magicCallMethodAcceptsCountBySomethingCallsAndExecutesAQueryWithThatCriteria()
{
$mockQuery = $this->createMock(Persistence\QueryInterface::class);
$mockQuery->expects($this->once())->method('equals')->with('foo', 'bar')->will($this->returnValue('matchCriteria'));
$mockQuery->expects($this->once())->method('matching')->with('matchCriteria')->will($this->returnValue($mockQuery));
$mockQuery->expects($this->once())->method('count')->will($this->returnValue(2));
$repository = $this->getMockBuilder(Persistence\Repository::class)->setMethods(['createQuery'])->getMock();
$repository->expects($this->once())->method('createQuery')->will($this->returnValue($mockQuery));
$this->assertSame(2, $repository->countByFoo('bar'));
}