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));
 }