/**
  * @return void
  */
 public function testTransform()
 {
     $srcHandler = $this->initHandler($this->sourceDocument, 0);
     $destHandler = $this->initHandler($this->destDocument, 1);
     $this->recordTransformer->init();
     $this->sourceDocument->expects($this->any())->method('getName')->willReturn('source_document_name');
     $recordFrom = $this->getMock('Migration\\ResourceModel\\Record', [], [], '', false);
     $recordFrom->expects($this->any())->method('getFields')->will($this->returnValue(['field1', 'field2']));
     $recordFrom->expects($this->any())->method('getData')->will($this->returnValue(['field1' => 1, 'field2' => 2]));
     $recordTo = $this->getMock('Migration\\ResourceModel\\Record', [], [], '', false);
     $recordTo->expects($this->any())->method('getFields')->will($this->returnValue(['field2']));
     $recordTo->expects($this->any())->method('setData')->with(['field2' => 2]);
     $field2Handler = $this->getMock('Migration\\Handler\\SetValue', ['handle'], [], '', false);
     $field2Handler->expects($this->once())->method('handle');
     $srcHandler->expects($this->any())->method('getHandlers')->willReturn(['field2' => $field2Handler]);
     $destHandler->expects($this->any())->method('getHandlers')->willReturn([]);
     $this->mapReader->expects($this->any())->method('getFieldMap')->with('source_document_name', 'field1')->willReturnArgument(1);
     $this->recordTransformer->transform($recordFrom, $recordTo);
 }
 /**
  * @return void
  */
 public function testPerformFieldFail()
 {
     $this->integrity = new Integrity($this->destination, $this->logger, $this->progress);
     $this->progress->expects($this->once())->method('start')->with(1);
     $this->progress->expects($this->once())->method('advance');
     $this->progress->expects($this->never())->method('finish');
     $this->destination->expects($this->once())->method('getDocumentList')->willReturn(['rating', 'rating_store']);
     $this->structure->expects($this->once())->method('getFields')->willReturn(['field' => []]);
     $this->document->expects($this->once())->method('getStructure')->willReturn($this->structure);
     $this->destination->expects($this->once())->method('getDocument')->with('rating')->willReturn($this->document);
     $this->logger->expects($this->once())->method('error')->with('"is_active" field does not exist in "rating" document of the destination resource');
     $this->assertFalse($this->integrity->perform());
 }
 /**
  * @param bool|false $dataTypeMismatch
  * @return void
  */
 protected function setupFieldsValidation($dataTypeMismatch = false)
 {
     $dataTypeSource = $dataTypeMismatch ? 'varchar' : 'int';
     $fieldsSource = ['field1' => ['DATA_TYPE' => $dataTypeSource]];
     $structureSource = $this->getMockBuilder('\\Migration\\ResourceModel\\Structure')->disableOriginalConstructor()->setMethods([])->getMock();
     $structureSource->expects($this->any())->method('getFields')->will($this->returnValue($fieldsSource));
     $this->documentSource = $this->getMockBuilder('\\Migration\\ResourceModel\\Document')->disableOriginalConstructor()->getMock();
     $this->documentSource->expects($this->any())->method('getStructure')->will($this->returnValue($structureSource));
     $dataTypeDestination = 'int';
     $fieldsDestination = ['field1' => ['DATA_TYPE' => $dataTypeDestination]];
     $structureDestination = $this->getMockBuilder('\\Migration\\ResourceModel\\Structure')->disableOriginalConstructor()->setMethods([])->getMock();
     $structureDestination->expects($this->any())->method('getFields')->will($this->returnValue($fieldsDestination));
     $this->documentDestination = $this->getMockBuilder('\\Migration\\ResourceModel\\Document')->disableOriginalConstructor()->getMock();
     $this->documentDestination->expects($this->any())->method('getStructure')->will($this->returnValue($structureDestination));
     $this->source->expects($this->any())->method('getDocument')->will($this->returnValue($this->documentSource));
     $this->destination->expects($this->any())->method('getDocument')->will($this->returnValue($this->documentDestination));
 }