/**
  * @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'));
 }
Пример #2
0
 public function testPerformWithError()
 {
     $eavAttributes = ['eav_attribute_1' => ['attribute_id' => '1', 'attribute_code' => 'attribute_code_1', 'attribute_model' => 1, 'backend_model' => 1, 'frontend_model' => 1, 'source_model' => 1, 'frontend_input_renderer' => 1, 'data_model' => 1], 'eav_attribute_2' => ['attribute_id' => '2', 'attribute_code' => 'attribute_code_2', 'attribute_model' => 1, 'backend_model' => 1, 'frontend_model' => 1, 'source_model' => 1, 'frontend_input_renderer' => 1, 'data_model' => 1]];
     $this->progress->expects($this->once())->method('start');
     $this->progress->expects($this->once())->method('finish');
     $this->progress->expects($this->any())->method('advance');
     $this->initialData->expects($this->atLeastOnce())->method('getAttributes')->willReturnMap([['source', $eavAttributes], ['destination', $eavAttributes]]);
     $this->helper->expects($this->any())->method('getDestinationRecords')->willReturn($eavAttributes);
     $this->helper->expects($this->any())->method('getSourceRecordsCount')->willReturnMap([['eav_attribute_set', 1], ['eav_attribute_group', 1], ['copy_document_1', 2], ['copy_document_2', 2]]);
     $this->initialData->expects($this->once())->method('getAttributeSets')->willReturn(1);
     $this->initialData->expects($this->once())->method('getAttributeGroups')->willReturn(1);
     $this->helper->expects($this->any())->method('getDestinationRecordsCount')->willReturn(1);
     $this->logger->expects($this->atLeastOnce())->method('warning');
     $this->assertFalse($this->volume->perform());
 }
Пример #3
0
 /**
  * @param int $sourceAttributeId
  * @return mixed
  */
 protected function getDestinationAttributeId($sourceAttributeId)
 {
     $id = null;
     $key = null;
     if (isset($this->initialData->getAttributes('source')[$sourceAttributeId])) {
         $key = $this->initialData->getAttributes('source')[$sourceAttributeId]['entity_type_id'] . '-' . $this->initialData->getAttributes('source')[$sourceAttributeId]['attribute_code'];
     }
     if ($key && isset($this->initialData->getAttributes('dest')[$key])) {
         $id = $this->initialData->getAttributes('dest')[$key]['attribute_id'];
     }
     return $id;
 }
Пример #4
0
 /**
  * @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';
     }
 }