/** * @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')); }
/** * Load migrated attribute groups data * @return void */ protected function loadNewAttributeGroups() { $this->newAttributeGroups = $this->helper->getDestinationRecords('eav_attribute_group', ['attribute_set_id', 'attribute_group_name']); foreach ($this->initialData->getAttributeGroups('dest') as $record) { $newKey = $this->destAttributeSetsOldNewMap[$record['attribute_set_id']] . '-' . $record['attribute_group_name']; $newAttributeGroup = $this->newAttributeGroups[$newKey]; $this->destAttributeGroupsOldNewMap[$record['attribute_group_id']] = $newAttributeGroup['attribute_group_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'; } }