/** * @covers \Migration\Step\SalesOrder\InitialData::initDestAttributes * @covers \Migration\Step\SalesOrder\InitialData::getDestEavAttributesCount * @return void */ public function testInit() { $eavEntityDocument = 'eav_entity_int'; $this->helper->expects($this->once())->method('getDestEavDocument')->willReturn($eavEntityDocument); $this->destination->expects($this->once())->method('getRecordsCount')->willReturn(2); $this->initialData->init(); $this->assertEquals($this->initialData->getDestEavAttributesCount($eavEntityDocument), 2); }
/** * @return void */ protected function checkEavEntities() { $countBeforeRun = $this->initialData->getDestEavAttributesCount($this->helper->getDestEavDocument()); $countAfterRun = $this->destination->getRecordsCount($this->helper->getDestEavDocument()); $countEavAttributes = null; foreach ($this->helper->getEavAttributes() as $eavAttribute) { $countEavAttributes += count($this->helper->getSourceAttributes($eavAttribute)); } if ($countBeforeRun + $countEavAttributes != $countAfterRun) { $this->errors[] = sprintf('Mismatch of entities in the document: %s', $this->helper->getDestEavDocument()); } }
/** * @return void */ public function testPerformFailExistingDocumentEntities() { $sourceDocumentName = 'source_document'; $destDocumentName = 'dest_document'; $eavDocumentName = 'eav_entity_int'; $eavAttributes = ['eav_attribute_1', 'eav_attribute_2']; $this->helper->expects($this->any())->method('getDocumentList')->willReturn([$sourceDocumentName => $destDocumentName]); $this->helper->expects($this->any())->method('getEavAttributes')->willReturn($eavAttributes); $this->helper->expects($this->any())->method('getDestEavDocument')->willReturn($eavDocumentName); $this->helper->expects($this->at(3))->method('getSourceAttributes')->willReturn(1); $this->helper->expects($this->at(4))->method('getSourceAttributes')->willReturn(0); $this->progress->expects($this->any())->method('start')->with(1); $this->progress->expects($this->once())->method('advance'); $this->map->expects($this->any())->method('getDocumentMap')->with($sourceDocumentName)->willReturn($destDocumentName); $this->source->expects($this->any())->method('getRecordsCount')->with($sourceDocumentName)->willReturn(1); $this->destination->expects($this->any())->method('getRecordsCount')->willReturnMap([[$destDocumentName, true, [], 2], [$eavDocumentName, true, [], 1]]); $this->initialData->expects($this->once())->method('getDestEavAttributesCount')->with('eav_entity_int')->willReturn(0); $this->logger->expects($this->once())->method('addRecord')->with(Logger::WARNING, 'Mismatch of entities in the document: ' . $destDocumentName); $this->assertFalse($this->salesOrder->perform()); }