public function setupMockQuery($numberOfResults, $howOftenIsGetFirstCalled)
{
$mockClassSchema = $this->createMock(ClassSchema::class, [], ['Dummy']);
$mockClassSchema->expects($this->once())->method('getIdentityProperties')->will($this->returnValue(['key1' => 'someType']));
$this->mockReflectionService->expects($this->once())->method('getClassSchema')->with('SomeType')->will($this->returnValue($mockClassSchema));
$mockConstraint = $this->getMockBuilder(Persistence\Generic\Qom\Comparison::class)->disableOriginalConstructor()->getMock();
$mockObject = new \stdClass();
$mockQuery = $this->createMock(Persistence\QueryInterface::class);
$mockQueryResult = $this->createMock(Persistence\QueryResultInterface::class);
$mockQueryResult->expects($this->once())->method('count')->will($this->returnValue($numberOfResults));
$mockQueryResult->expects($howOftenIsGetFirstCalled)->method('getFirst')->will($this->returnValue($mockObject));
$mockQuery->expects($this->once())->method('equals')->with('key1', 'value1')->will($this->returnValue($mockConstraint));
$mockQuery->expects($this->once())->method('matching')->with($mockConstraint)->will($this->returnValue($mockQuery));
$mockQuery->expects($this->once())->method('execute')->will($this->returnValue($mockQueryResult));
$this->mockPersistenceManager->expects($this->once())->method('createQueryForType')->with('SomeType')->will($this->returnValue($mockQuery));
return $mockObject;
}