public function mapToObjectReconstitutesExpectedObjectAndRegistersItWithIdentityMapToObjects()
{
$mockEntityClassName = 'Entity' . md5(uniqid(mt_rand(), true));
$mockEntity = $this->createMock(ProxyInterface::class, ['Flow_Aop_Proxy_invokeJoinPoint', '__wakeup'], [], $mockEntityClassName);
$objectData = ['identifier' => '1234', 'classname' => $mockEntityClassName, 'properties' => ['foo']];
$mockClassSchema = $this->getMockBuilder(ClassSchema::class)->disableOriginalConstructor()->getMock();
$mockClassSchema->expects($this->any())->method('getModelType')->will($this->returnValue(ClassSchema::MODELTYPE_ENTITY));
$mockReflectionService = $this->getMockBuilder(ReflectionService::class)->disableOriginalConstructor()->getMock();
$mockReflectionService->expects($this->any())->method('getClassSchema')->with($mockEntityClassName)->will($this->returnValue($mockClassSchema));
$mockSession = $this->createMock(Persistence\Generic\Session::class);
$mockSession->expects($this->once())->method('registerReconstitutedEntity')->with($mockEntity, $objectData);
$mockSession->expects($this->once())->method('registerObject')->with($mockEntity, '1234');
$dataMapper = $this->getAccessibleMock(Persistence\Generic\DataMapper::class, ['thawProperties']);
$dataMapper->expects($this->once())->method('thawProperties')->with($mockEntity, $objectData['identifier'], $objectData);
$dataMapper->injectPersistenceSession($mockSession);
$dataMapper->injectReflectionService($mockReflectionService);
$dataMapper->_call('mapToObject', $objectData);
}