public function testGettersAndSetters()
 {
     $entity1 = new \stdClass();
     $entity2 = new \stdClass();
     $this->entityRegistry->addEntity('Test\\Entity', 'test1', $entity1);
     $this->entityRegistry->addEntity('Test\\Entity', 'test2', $entity2);
     // entity1
     $this->assertTrue($this->entityRegistry->hasEntity('Test\\Entity', 'test1'));
     $this->assertSame($entity1, $this->entityRegistry->getEntity('Test\\Entity', 'test1'));
     // entity2
     $this->assertTrue($this->entityRegistry->hasEntity('Test\\Entity', 'test2'));
     $this->assertSame($entity2, $this->entityRegistry->getEntity('Test\\Entity', 'test2'));
     // unknown entity
     $this->assertFalse($this->entityRegistry->hasEntity('Test\\Entity', 'test3'));
     $this->setExpectedException('Oro\\Bundle\\ImportExportBundle\\Exception\\LogicException', 'The entity "Test\\Entity" with key "test3" does not exist.');
     $this->entityRegistry->getEntity('Test\\Entity', 'test3');
 }
 public function testGetEntityData()
 {
     $entityKey = 'test1';
     $entity = new \stdClass();
     $repository = $this->getMock('Oro\\Bundle\\ImportExportBundle\\TemplateFixture\\TemplateEntityRepositoryInterface');
     $repository->expects($this->once())->method('getEntityClass')->will($this->returnValue(self::ENTITY_CLASS));
     $this->templateManager->addEntityRepository($repository);
     $this->templateRepository->expects($this->once())->method('createEntity')->with($entityKey)->will($this->returnValue($entity));
     $repository->expects($this->once())->method('fillEntityData')->with($entityKey, $this->identicalTo($entity));
     // test that new entity is created
     $data = $this->callProtectedMethod($this->templateRepository, 'getEntityData', [$entityKey]);
     $data = iterator_to_array($data);
     $this->assertSame($entity, current($data));
     $this->assertSame($entity, $this->entityRegistry->getEntity(self::ENTITY_CLASS, $entityKey));
     // test that existing entity is returned
     $data = $this->callProtectedMethod($this->templateRepository, 'getEntityData', [$entityKey]);
     $data = iterator_to_array($data);
     $this->assertSame($entity, current($data));
     $this->assertSame($entity, $this->entityRegistry->getEntity(self::ENTITY_CLASS, $entityKey));
 }