/**
  * @return void
  */
 public function testPerformFailed()
 {
     $sourceDocName = 'core_config_data';
     $dstDocName = 'config_data';
     $this->source->expects($this->once())->method('getDocumentList')->willReturn([$sourceDocName]);
     $this->map->expects($this->once())->method('getDocumentMap')->willReturn($dstDocName);
     $this->source->expects($this->once())->method('getRecordsCount')->willReturn(2);
     $this->destination->expects($this->once())->method('getRecordsCount')->willReturn(3);
     $this->logger->expects($this->once())->method('addRecord')->with(Logger::WARNING, 'Mismatch of entities in the document: ' . $dstDocName);
     $this->helper->expects($this->once())->method('getFieldsUpdateOnDuplicate')->with($dstDocName)->willReturn(false);
     $this->assertFalse($this->volume->perform());
 }
 /**
  * @return void
  */
 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\\ResourceModel\\Document', ['getRecords', 'getStructure'], [], '', false);
     $this->source->expects($this->once())->method('getDocument')->will($this->returnValue($sourceDocument));
     $destinationDocument = $this->getMockBuilder('\\Migration\\ResourceModel\\Document')->disableOriginalConstructor()->setMethods(['getStructure', 'getRecords'])->getMock();
     $this->destination->expects($this->once())->method('getDocument')->will($this->returnValue($destinationDocument));
     $structure = $this->getMockBuilder('\\Migration\\ResourceModel\\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->any())->method('getRecords')->willReturnOnConsecutiveCalls($bulk, []);
     $this->source->expects($this->any())->method('setLastLoadedRecord')->withConsecutive([$sourceDocName, $bulk[0]], [$sourceDocName, []]);
     $this->source->expects($this->any())->method('getPageSize')->willReturn(100);
     $destinationRecords = $this->getMock('\\Migration\\ResourceModel\\Record\\Collection', [], [], '', false);
     $destinationDocument->expects($this->once())->method('getRecords')->will($this->returnValue($destinationRecords));
     $srcRecord = $this->getMock('\\Migration\\ResourceModel\\Record', [], [], '', false);
     $dstRecord = $this->getMock('\\Migration\\ResourceModel\\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->helper->expects($this->once())->method('getFieldsUpdateOnDuplicate')->with($dstDocName)->willReturn(false);
     $this->data->perform();
 }