/** * @return void */ public function testPerformDestinationFail() { $this->progress->expects($this->once())->method('start')->with(1); $this->progress->expects($this->once())->method('advance'); $this->progress->expects($this->never())->method('finish'); $this->source->expects($this->once())->method('getDocumentList')->willReturn(['core_config_data']); $this->destination->expects($this->once())->method('getDocumentList')->willReturn([]); $this->logger->expects($this->once())->method('error')->with('Integrity check failed due to "core_config_data" document does not exist in the destination resource'); $this->integrity = new Integrity($this->destination, $this->source, $this->logger, $this->progress, $this->recordFactory, $this->readerSettings, $this->handlerManagerFactory); $this->assertFalse($this->integrity->perform()); }
/** * @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()); }
public function testPerformWithMismatchDocumentFieldDataTypes() { $this->setupFieldsValidation(true); $this->documentSource->expects($this->any())->method('getName')->will($this->returnValue('document1')); $this->documentDestination->expects($this->any())->method('getName')->will($this->returnValue('document1')); $this->source->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document1'])); $this->destination->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document1'])); $this->map->expects($this->any())->method('getDocumentMap')->will($this->returnArgument(0)); $this->map->expects($this->any())->method('isDocumentIgnored')->willReturn(false); $this->map->expects($this->any())->method('getFieldMap')->will($this->returnValue('field1')); $this->map->expects($this->any())->method('isFieldDataTypeIgnored')->will($this->returnValue(false)); $this->logger->expects($this->at(0))->method('warning')->with('Mismatch of data types. Source document: document1. Fields: field1'); $this->logger->expects($this->at(1))->method('warning')->with('Mismatch of data types. Destination document: document1. Fields: field1'); $this->integrity->perform(); }
public function testPerformWithSourceFieldErrors() { $structure = $this->getMockBuilder('\\Migration\\Resource\\Structure')->disableOriginalConstructor()->setMethods([])->getMock(); $structure->expects($this->at(0))->method('getFields')->will($this->returnValue(['field1' => []])); $structure->expects($this->at(1))->method('getFields')->will($this->returnValue(['field2' => []])); $structure->expects($this->at(2))->method('getFields')->will($this->returnValue(['field2' => []])); $structure->expects($this->at(3))->method('getFields')->will($this->returnValue(['field1' => []])); $document = $this->getMockBuilder('\\Migration\\Resource\\Document')->disableOriginalConstructor()->getMock(); $document->expects($this->any())->method('getStructure')->willReturn($structure); $document->expects($this->any())->method('getName')->willReturn('document'); $this->source->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document'])); $this->destination->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document'])); $this->source->expects($this->any())->method('getDocument')->will($this->returnValue($document)); $this->destination->expects($this->any())->method('getDocument')->with('document')->will($this->returnValue($document)); $this->map->expects($this->any())->method('isDocumentIgnored')->willReturn(false); $this->map->expects($this->exactly(2))->method('getDocumentMap')->with('document')->will($this->returnArgument(0)); $this->map->expects($this->at(2))->method('getFieldMap')->with('document', 'field1')->will($this->returnValue('field1')); $this->map->expects($this->at(5))->method('getFieldMap')->with('document', 'field2')->will($this->returnValue('field2')); $this->logger->expects($this->at(0))->method('error')->with('Source fields not mapped. Document: document. Fields: field1'); $this->logger->expects($this->at(1))->method('error')->with('Destination fields not mapped. Document: document. Fields: field2'); $this->integrity->perform(); }
/** * @return void */ public function testPerform() { $integrity = new Integrity($this->progress, $this->source, $this->destination, $this->helper); $this->assertTrue($integrity->perform()); }