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()); }
/** * @return void */ public function testDeleteBackups() { $this->readerGroups->expects($this->once())->method('getGroup')->with('documents')->willReturn(['some_document' => 0]); $this->map->expects($this->once())->method('getDocumentMap')->with('some_document', MapInterface::TYPE_SOURCE)->will($this->returnValue('some_dest_document')); $this->destination->expects($this->once())->method('deleteDocumentBackup')->with('some_dest_document'); $this->helper->deleteBackups(); }
/** * Load migrated attributes data * @return array */ protected function loadNewAttributes() { $this->newAttributes = $this->helper->getDestinationRecords('eav_attribute', ['entity_type_id', 'attribute_code']); foreach ($this->initialData->getAttributes('dest') as $key => $attributeData) { $this->destAttributeOldNewMap[$attributeData['attribute_id']] = $this->newAttributes[$key]['attribute_id']; } return $this->newAttributes; }
/** * @return void */ public function testGetRecordTransformer() { $sourceDocument = $this->getMockBuilder('Migration\\ResourceModel\\Document')->disableOriginalConstructor()->getMock(); $destinationDocument = $this->getMockBuilder('Migration\\ResourceModel\\Document')->disableOriginalConstructor()->getMock(); $recordTransformer = $this->getMockBuilder('Migration\\RecordTransformer')->disableOriginalConstructor()->setMethods(['init'])->getMock(); $this->factory->expects($this->once())->method('create')->with(['sourceDocument' => $sourceDocument, 'destDocument' => $destinationDocument, 'mapReader' => $this->map])->will($this->returnValue($recordTransformer)); $recordTransformer->expects($this->once())->method('init')->will($this->returnSelf()); $this->assertSame($recordTransformer, $this->helper->getRecordTransformer($sourceDocument, $destinationDocument)); }
/** * @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'; } }
/** * Load attribute group data before migration * @return void */ protected function initAttributeGroups() { $this->attributeGroups['dest'] = $this->helper->getDestinationRecords('eav_attribute_group', ['attribute_set_id', 'attribute_group_name']); }