Пример #1
0
 public function testPerformJustCopy()
 {
     $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([]);
     $sourceDocument = $this->getMock('\\Migration\\Resource\\Document', ['getRecords', 'getStructure'], [], '', false);
     $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([]));
     $this->source->expects($this->once())->method('getDocument')->willReturn($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);
     $destinationRecords = $this->getMock('\\Migration\\Resource\\Record\\Collection', [], [], '', false);
     $destinationDocument->expects($this->once())->method('getRecords')->will($this->returnValue($destinationRecords));
     $dstRecord = $this->getMock('\\Migration\\Resource\\Record', [], [], '', false);
     $this->recordFactory->expects($this->at(0))->method('create')->will($this->returnValue($dstRecord));
     $this->destination->expects($this->once())->method('saveRecords')->with($dstDocName, $destinationRecords);
     $this->destination->expects($this->once())->method('clearDocument')->with($dstDocName);
     $this->data->perform();
 }
 public function testRunStepsWithSuccessProgress()
 {
     $stepIntegrity = $this->getMockBuilder('\\Migration\\App\\Step\\StageInterface')->getMock();
     $stepIntegrity->expects($this->never())->method('perform');
     $stepData = $this->getMockBuilder('\\Migration\\App\\Step\\StageInterface')->getMock();
     $stepData->expects($this->never())->method('perform');
     $stepVolume = $this->getMockBuilder('\\Migration\\App\\Step\\StageInterface')->getMock();
     $stepVolume->expects($this->never())->method('perform');
     $this->progress->expects($this->never())->method('saveResult');
     $this->progress->expects($this->any())->method('isCompleted')->willReturn(true);
     $this->logger->expects($this->at(0))->method('info')->with("started");
     $this->logger->expects($this->at(1))->method('info')->with("started");
     $this->logger->expects($this->at(2))->method('info')->with("started");
     $this->logger->expects($this->at(3))->method('info')->with("Migration completed");
     $this->stepList->expects($this->any())->method('getSteps')->willReturn(['Title' => ['integrity' => $stepIntegrity, 'data' => $stepData, 'volume' => $stepVolume]]);
     $this->assertTrue($this->settings->run());
 }