Beispiel #1
0
 public function testPerform()
 {
     $sourceDocName = 'core_config_data';
     $this->source->expects($this->any())->method('getDocumentList')->will($this->returnValue([$sourceDocName]));
     $dstDocName = 'config_data';
     $this->map->expects($this->once())->method('getDocumentMap')->will($this->returnValue($dstDocName));
     $sourceDocument = $this->getMock('\\Migration\\Resource\\Document', ['getRecords'], [], '', false);
     $this->source->expects($this->once())->method('getDocument')->will($this->returnValue($sourceDocument));
     $destinationDocument = $this->getMock('\\Migration\\Resource\\Document', [], [], '', false);
     $this->destination->expects($this->once())->method('getDocument')->will($this->returnValue($destinationDocument));
     $recordTransformer = $this->getMock('Migration\\RecordTransformer', ['init', 'transform'], [], '', false);
     $this->recordTransformerFactory->expects($this->once())->method('create')->will($this->returnValue($recordTransformer));
     $recordTransformer->expects($this->once())->method('init');
     $bulk = [['id' => 4, 'name' => 'john']];
     $this->source->expects($this->at(3))->method('getRecords')->will($this->returnValue($bulk));
     $this->source->expects($this->at(4))->method('getRecords')->will($this->returnValue([]));
     $this->source->expects($this->any())->method('getRecordsCount')->will($this->returnValue(2));
     $destinationRecords = $this->getMock('\\Migration\\Resource\\Record\\Collection', [], [], '', false);
     $destinationDocument->expects($this->once())->method('getRecords')->will($this->returnValue($destinationRecords));
     $srcRecord = $this->getMock('\\Migration\\Resource\\Record', [], [], '', false);
     $dstRecord = $this->getMock('\\Migration\\Resource\\Record', [], [], '', false);
     $this->recordFactory->expects($this->at(0))->method('create')->will($this->returnValue($srcRecord));
     $this->recordFactory->expects($this->at(1))->method('create')->will($this->returnValue($dstRecord));
     $recordTransformer->expects($this->once())->method('transform')->with($srcRecord, $dstRecord);
     $this->destination->expects($this->once())->method('saveRecords')->with($dstDocName, $destinationRecords);
     $this->destination->expects($this->exactly(2))->method('clearDocument');
     $this->logger->expects($this->any())->method('debug')->with('migrating', ['table' => 'source_document'])->willReturn(true);
     $this->data->perform();
 }
 public function testPerform()
 {
     $sourceDocName = 'core_config_data';
     $this->source->expects($this->any())->method('getDocumentList')->will($this->returnValue([$sourceDocName]));
     $this->source->expects($this->any())->method('getRecordsCount')->will($this->returnValue(2));
     $dstDocName = 'config_data';
     $this->progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([]));
     $this->map->expects($this->once())->method('getDocumentMap')->will($this->returnValue($dstDocName));
     $this->map->expects($this->any())->method('getHandlerConfig')->willReturn(['class' => 'Handler\\Class']);
     $sourceDocument = $this->getMock('\\Migration\\Resource\\Document', ['getRecords', 'getStructure'], [], '', false);
     $this->source->expects($this->once())->method('getDocument')->will($this->returnValue($sourceDocument));
     $destinationDocument = $this->getMockBuilder('\\Migration\\Resource\\Document')->disableOriginalConstructor()->setMethods(['getStructure', 'getRecords'])->getMock();
     $this->destination->expects($this->once())->method('getDocument')->will($this->returnValue($destinationDocument));
     $structure = $this->getMockBuilder('\\Migration\\Resource\\Structure')->disableOriginalConstructor()->setMethods(['getFields'])->getMock();
     $structure->expects($this->any())->method('getFields')->willReturn(['field' => []]);
     $sourceDocument->expects($this->any())->method('getStructure')->willReturn($structure);
     $destinationDocument->expects($this->any())->method('getStructure')->willReturn($structure);
     $recordTransformer = $this->getMock('Migration\\RecordTransformer', ['init', 'transform'], [], '', false);
     $this->recordTransformerFactory->expects($this->once())->method('create')->will($this->returnValue($recordTransformer));
     $recordTransformer->expects($this->once())->method('init');
     $bulk = [['id' => 4, 'name' => 'john']];
     $this->source->expects($this->at(4))->method('getRecords')->will($this->returnValue($bulk));
     $this->source->expects($this->at(5))->method('getRecords')->will($this->returnValue([]));
     $destinationRecords = $this->getMock('\\Migration\\Resource\\Record\\Collection', [], [], '', false);
     $destinationDocument->expects($this->once())->method('getRecords')->will($this->returnValue($destinationRecords));
     $srcRecord = $this->getMock('\\Migration\\Resource\\Record', [], [], '', false);
     $dstRecord = $this->getMock('\\Migration\\Resource\\Record', [], [], '', false);
     $this->recordFactory->expects($this->at(0))->method('create')->will($this->returnValue($srcRecord));
     $this->recordFactory->expects($this->at(1))->method('create')->will($this->returnValue($dstRecord));
     $recordTransformer->expects($this->once())->method('transform')->with($srcRecord, $dstRecord);
     $this->destination->expects($this->once())->method('saveRecords')->with($dstDocName, $destinationRecords);
     $this->destination->expects($this->once())->method('clearDocument')->with($dstDocName);
     $this->logger->expects($this->any())->method('debug')->with('migrating', ['table' => $sourceDocName])->willReturn(true);
     $this->data->perform();
 }
 /**
  * @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));
 }
 /**
  * @covers \Migration\Step\SalesOrder\Data::prepareEavEntityData
  * @covers \Migration\Step\SalesOrder\Data::getAttributeData
  * @covers \Migration\Step\SalesOrder\Data::getAttributeValue
  * @covers \Migration\Step\SalesOrder\Data::getDestEavDocument
  * @return void
  */
 public function testGetMap()
 {
     $sourceDocumentName = 'source_document';
     $destinationDocumentName = 'destination_document';
     $eavAttributes = ['eav_attr_1', 'eav_attr_2'];
     $eavAttributeData = ['entity_type_id' => 1, 'attribute_id' => 2, 'attribute_code' => 'eav_attr_1'];
     $this->helper->expects($this->any())->method('getDocumentList')->willReturn([$sourceDocumentName => $destinationDocumentName]);
     $this->helper->expects($this->once())->method('getDestEavDocument')->willReturn('eav_document');
     $this->helper->expects($this->at(3))->method('getEavAttributes')->willReturn($eavAttributes);
     $this->map->expects($this->once())->method('getDocumentMap')->willReturn($destinationDocumentName);
     $sourceDocument = $this->getMock('\\Migration\\ResourceModel\\Document', ['getRecords'], [], '', false);
     $this->source->expects($this->once())->method('getDocument')->willReturn($sourceDocument);
     $this->source->expects($this->any())->method('getRecordsCount')->willReturn(2);
     $destinationDocument = $this->getMock('\\Migration\\ResourceModel\\Document', [], [], '', false);
     $eavDestinationDocument = $this->getMock('\\Migration\\ResourceModel\\Document', [], [], '', false);
     $dstDocName = 'destination_document';
     $eavDstDocName = 'eav_document';
     $this->destination->expects($this->any())->method('getDocument')->willReturnMap([[$dstDocName, $destinationDocument], [$eavDstDocName, $eavDestinationDocument]]);
     $recordTransformer = $this->getMock('Migration\\RecordTransformer', ['init', 'transform'], [], '', false);
     $this->recordTransformerFactory->expects($this->once())->method('create')->willReturn($recordTransformer);
     $recordTransformer->expects($this->once())->method('init');
     $bulk = [['eav_attr_1' => 'attribute_value', 'store_id' => '1', 'entity_id' => '2']];
     $this->source->expects($this->at(3))->method('getRecords')->willReturn($bulk);
     $this->source->expects($this->at(4))->method('getRecords')->willReturn([]);
     $destinationRecords = $this->getMock('\\Migration\\ResourceModel\\Record\\Collection', [], [], '', false);
     $eavDestinationRecords = $this->getMock('\\Migration\\ResourceModel\\Record\\Collection', [], [], '', false);
     $destinationDocument->expects($this->once())->method('getRecords')->willReturn($destinationRecords);
     $srcRecord = $this->getMock('\\Migration\\ResourceModel\\Record', [], [], '', false);
     $dstRecord = $this->getMock('\\Migration\\ResourceModel\\Record', [], [], '', false);
     $this->recordFactory->expects($this->at(0))->method('create')->willReturn($srcRecord);
     $this->recordFactory->expects($this->at(1))->method('create')->willReturn($dstRecord);
     $recordTransformer->expects($this->once())->method('transform')->with($srcRecord, $dstRecord);
     $eavDestinationDocument->expects($this->once())->method('getRecords')->willReturn($eavDestinationRecords);
     $eavDestinationRecords->expects($this->once())->method('addRecord');
     $this->destination->expects($this->at(5))->method('saveRecords')->with($dstDocName, $destinationRecords);
     $this->destination->expects($this->at(6))->method('saveRecords')->with($eavDstDocName, $eavDestinationRecords);
     $this->destination->expects($this->once())->method('clearDocument')->with($dstDocName);
     $this->destination->expects($this->at(3))->method('getRecords')->willReturn([0 => $eavAttributeData]);
     $this->logger->expects($this->any())->method('debug')->with('migrating', ['table' => $sourceDocumentName])->willReturn(true);
     $this->salesOrder->perform();
 }