/**
  * @covers \Migration\Step\Eav\InitialData::Init
  * @covers \Migration\Step\Eav\InitialData::initAttributes
  * @covers \Migration\Step\Eav\InitialData::initAttributeSets
  * @covers \Migration\Step\Eav\InitialData::initAttributeGroups
  * @covers \Migration\Step\Eav\InitialData::getAttributes
  * @covers \Migration\Step\Eav\InitialData::getAttributeSets
  * @covers \Migration\Step\Eav\InitialData::getAttributeGroups
  * @return void
  */
 public function testInit()
 {
     $dataAttributes = ['source' => ['id_1' => 'value_1', 'id_2' => 'value_2'], 'dest' => ['id_1' => 'value_1', 'id_2' => 'value_2']];
     $attributeSets = ['attr_set_1', 'attr_set_2'];
     $attributeGroups = ['attr_group_1', 'attr_group_2'];
     $this->helper->expects($this->once())->method('getSourceRecords')->willReturnMap([['eav_attribute', ['attribute_id'], $dataAttributes['source']]]);
     $this->helper->expects($this->any())->method('getDestinationRecords')->willReturnMap([['eav_attribute', ['entity_type_id', 'attribute_code'], $dataAttributes['dest']], ['eav_attribute_set', ['attribute_set_id'], $attributeSets], ['eav_attribute_group', ['attribute_set_id', 'attribute_group_name'], $attributeGroups]]);
     $this->initialData->init();
     foreach ($dataAttributes as $resourceType => $resourceData) {
         $this->assertEquals($resourceData, $this->initialData->getAttributes($resourceType));
     }
     $this->assertEquals($attributeSets, $this->initialData->getAttributeSets('dest'));
     $this->assertEquals($attributeGroups, $this->initialData->getAttributeGroups('dest'));
 }
Example #2
0
 /**
  * Load migrated attribute sets data
  * @return void
  */
 protected function loadNewAttributeSets()
 {
     $this->newAttributeSets = $this->helper->getDestinationRecords('eav_attribute_set', ['entity_type_id', 'attribute_set_name']);
     foreach ($this->initialData->getAttributeSets('dest') as $attributeSetId => $record) {
         $newAttributeSet = $this->newAttributeSets[$record['entity_type_id'] . '-' . $record['attribute_set_name']];
         $this->destAttributeSetsOldNewMap[$attributeSetId] = $newAttributeSet['attribute_set_id'];
     }
 }
 /**
  * @return void
  */
 public function validateAttributeSetsAndGroups()
 {
     $sourceRecords = $this->helper->getSourceRecordsCount('eav_attribute_set');
     $initialDestRecords = count($this->initialData->getAttributeSets('dest'));
     if ($this->helper->getDestinationRecordsCount('eav_attribute_set') != $sourceRecords + $initialDestRecords) {
         $this->errors[] = 'Mismatch of entities in the document: eav_attribute_set';
     }
     $sourceRecords = $this->helper->getSourceRecordsCount('eav_attribute_group');
     $initialDestRecords = count($this->initialData->getAttributeGroups('dest'));
     if ($this->helper->getDestinationRecordsCount('eav_attribute_group') != $sourceRecords + $initialDestRecords) {
         $this->errors[] = 'Mismatch of entities in the document: eav_attribute_group';
     }
 }