/**
  * @return void
  */
 public function setUp()
 {
     $this->progress = $this->getMock('\\Migration\\App\\ProgressBar\\LogLevelProcessor', ['start', 'finish', 'advance'], [], '', false);
     $this->source = $this->getMock('Migration\\ResourceModel\\Source', ['getDocument', 'getDocumentList', 'getRecords', 'getRecordsCount', 'getAdapter', 'addDocumentPrefix', 'getPageSize'], [], '', false);
     $this->destination = $this->getMock('Migration\\ResourceModel\\Destination', ['getDocument', 'getDocumentList', 'saveRecords', 'clearDocument'], [], '', false);
     $this->recordFactory = $this->getMock('Migration\\ResourceModel\\RecordFactory', ['create'], [], '', false);
     $this->recordTransformerFactory = $this->getMock('Migration\\RecordTransformerFactory', ['create'], [], '', false);
     $this->map = $this->getMockBuilder('Migration\\Reader\\Map')->disableOriginalConstructor()->setMethods(['getDocumentMap', 'init', 'getDocumentList', 'getDestDocumentsToClear'])->getMock();
     $this->sourceAdapter = $this->getMockBuilder('Migration\\ResourceModel\\Adapter\\Mysql')->disableOriginalConstructor()->setMethods(['getSelect', 'loadDataFromSelect'])->getMock();
     $select = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->setMethods(['from', 'joinLeft', 'where', 'group'])->disableOriginalConstructor()->getMock();
     $select->expects($this->any())->method('from')->willReturnSelf();
     $select->expects($this->any())->method('joinLeft')->willReturnSelf();
     $select->expects($this->any())->method('where')->willReturnSelf();
     $select->expects($this->any())->method('group')->willReturnSelf();
     $this->sourceAdapter->expects($this->any())->method('getSelect')->willReturn($select);
     $this->source->expects($this->any())->method('getAdapter')->willReturn($this->sourceAdapter);
     $this->source->expects($this->any())->method('addDocumentPrefix')->willReturn($this->returnArgument(1));
     $this->source->expects($this->any())->method('getPageSize')->willReturn(100);
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMock('\\Migration\\Reader\\MapFactory', [], [], '', false);
     $mapFactory->expects($this->any())->method('create')->with('log_map_file')->willReturn($this->map);
     $this->readerGroups = $this->getMock('\\Migration\\Reader\\Groups', ['getGroup'], [], '', false);
     $this->readerGroups->expects($this->any())->method('getGroup')->willReturnMap([['source_documents', ['source_document' => '']], ['destination_documents_to_clear', ['source_document_to_clear' => '']]]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMock('\\Migration\\Reader\\GroupsFactory', ['create'], [], '', false);
     $groupsFactory->expects($this->any())->method('create')->with('log_document_groups_file')->willReturn($this->readerGroups);
     $this->logger = $this->getMockBuilder('Migration\\Logger\\Logger')->disableOriginalConstructor()->setMethods(['debug'])->getMock();
     $this->data = new Data($this->progress, $this->source, $this->destination, $this->recordFactory, $this->recordTransformerFactory, $mapFactory, $groupsFactory, $this->logger);
 }
Exemplo n.º 2
0
 /**
  * @return void
  */
 public function setUp()
 {
     $this->config = $this->getMockBuilder('Migration\\Config')->disableOriginalConstructor()->setMethods(['getSource'])->getMock();
     $this->config->expects($this->any())->method('getSource')->will($this->returnValue(['type' => DatabaseStage::SOURCE_TYPE]));
     $this->source = $this->getMockBuilder('Migration\\ResourceModel\\Source')->disableOriginalConstructor()->setMethods(['getDocument', 'getRecordsCount', 'getAdapter', 'addDocumentPrefix', 'getRecords'])->getMock();
     $this->source->expects($this->any())->method('addDocumentPrefix')->willReturnCallback(function ($name) {
         return 'source_suffix_' . $name;
     });
     $this->destination = $this->getMockBuilder('Migration\\ResourceModel\\Destination')->disableOriginalConstructor()->setMethods(['getDocument', 'getRecordsCount', 'getAdapter', 'addDocumentPrefix', 'saveRecords'])->getMock();
     $this->destination->expects($this->any())->method('addDocumentPrefix')->willReturnCallback(function ($name) {
         return 'destination_suffix_' . $name;
     });
     $this->progress = $this->getMockBuilder('Migration\\App\\ProgressBar\\LogLevelProcessor')->disableOriginalConstructor()->setMethods(['start', 'finish', 'advance'])->getMock();
     $this->progress->expects($this->any())->method('start');
     $this->progress->expects($this->any())->method('finish');
     $this->progress->expects($this->any())->method('advance');
     $this->recordFactory = $this->getMockBuilder('Migration\\ResourceModel\\RecordFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->logger = $this->getMockBuilder('Migration\\Logger\\Logger')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->map = $this->getMockBuilder('Migration\\Reader\\Map')->disableOriginalConstructor()->setMethods(['getDocumentMap', 'init', 'getDocumentList', 'getDestDocumentsToClear'])->getMock();
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMockBuilder('Migration\\Reader\\MapFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $mapFactory->expects($this->any())->method('create')->with('customer_attr_map_file')->willReturn($this->map);
     $this->groups = $this->getMockBuilder('Migration\\Reader\\Groups')->disableOriginalConstructor()->getMock();
     $this->groups->expects($this->any())->method('getGroup')->with('source_documents')->willReturn(['source_document_1' => 'entity_id']);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMockBuilder('Migration\\Reader\\GroupsFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $groupsFactory->expects($this->any())->method('create')->with('customer_attr_document_groups_file')->willReturn($this->groups);
     $this->logger = $this->getMockBuilder('Migration\\Logger\\Logger')->disableOriginalConstructor()->setMethods(['debug'])->getMock();
     $this->step = new Data($this->config, $this->source, $this->destination, $this->progress, $this->recordFactory, $mapFactory, $groupsFactory, $this->logger);
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->groups = $this->getMockBuilder('Migration\\Reader\\Groups')->disableOriginalConstructor()->setMethods(['getGroup'])->getMock();
     $this->groups->expects($this->once())->method('getGroup')->with('destination_documents_update_on_duplicate')->willReturn([$this->fieldsUpdateOnDuplicate['document'] => implode(',', $this->fieldsUpdateOnDuplicate['fields'])]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMockBuilder('Migration\\Reader\\GroupsFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $groupsFactory->expects($this->any())->method('create')->with('map_document_groups')->willReturn($this->groups);
     $this->helper = new Helper($groupsFactory);
 }
 /**
  * @return void
  */
 public function testDeleteBackups()
 {
     $this->readerGroups->expects($this->once())->method('getGroup')->with('documents')->willReturn(['some_document' => 0]);
     $this->map->expects($this->once())->method('getDocumentMap')->with('some_document', MapInterface::TYPE_SOURCE)->will($this->returnValue('some_dest_document'));
     $this->destination->expects($this->once())->method('deleteDocumentBackup')->with('some_dest_document');
     $this->helper->deleteBackups();
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->logger = $this->getMock('\\Migration\\Logger\\Logger', ['debug', 'error'], [], '', false);
     $this->source = $this->getMock('\\Migration\\ResourceModel\\Source', ['getDocumentList', 'getDocument'], [], '', false);
     $this->progress = $this->getMock('\\Migration\\App\\ProgressBar\\LogLevelProcessor', ['start', 'finish', 'advance'], [], '', false);
     $this->destination = $this->getMock('\\Migration\\ResourceModel\\Destination', ['getDocumentList', 'getDocument'], [], '', false);
     $this->map = $this->getMockBuilder('\\Migration\\Reader\\Map')->disableOriginalConstructor()->getMock();
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMock('\\Migration\\Reader\\MapFactory', [], [], '', false);
     $mapFactory->expects($this->any())->method('create')->with('log_map_file')->willReturn($this->map);
     $this->readerGroups = $this->getMock('\\Migration\\Reader\\Groups', ['getGroup'], [], '', false);
     $this->readerGroups->expects($this->any())->method('getGroup')->willReturnMap([['source_documents', ['document1' => '']], ['destination_documents_to_clear', ['document_to_clear' => '']]]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMock('\\Migration\\Reader\\GroupsFactory', ['create'], [], '', false);
     $groupsFactory->expects($this->any())->method('create')->with('log_document_groups_file')->willReturn($this->readerGroups);
     $this->log = new Integrity($this->progress, $this->logger, $this->source, $this->destination, $mapFactory, $groupsFactory);
 }
Exemplo n.º 6
0
 public function setUp()
 {
     $this->progress = $this->getMock('\\Migration\\App\\ProgressBar\\LogLevelProcessor', ['start', 'finish', 'advance'], [], '', false);
     $this->source = $this->getMock('Migration\\Resource\\Source', ['getDocument', 'getDocumentList', 'getRecords', 'getRecordsCount'], [], '', false);
     $this->destination = $this->getMock('Migration\\Resource\\Destination', ['getDocument', 'getDocumentList', 'saveRecords', 'clearDocument'], [], '', false);
     $this->recordFactory = $this->getMock('Migration\\Resource\\RecordFactory', ['create'], [], '', false);
     $this->recordTransformerFactory = $this->getMock('Migration\\RecordTransformerFactory', ['create'], [], '', false);
     $this->map = $this->getMockBuilder('Migration\\Reader\\Map')->disableOriginalConstructor()->setMethods(['getDocumentMap', 'init', 'getDocumentList', 'getDestDocumentsToClear'])->getMock();
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMock('\\Migration\\Reader\\MapFactory', [], [], '', false);
     $mapFactory->expects($this->any())->method('create')->with('log_map_file')->willReturn($this->map);
     $this->readerGroups = $this->getMock('\\Migration\\Reader\\Groups', ['getGroup'], [], '', false);
     $this->readerGroups->expects($this->any())->method('getGroup')->willReturnMap([['source_documents', ['source_document' => '']], ['destination_documents_to_clear', ['source_document_to_clear' => '']]]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMock('\\Migration\\Reader\\GroupsFactory', ['create'], [], '', false);
     $groupsFactory->expects($this->any())->method('create')->with('log_document_groups_file')->willReturn($this->readerGroups);
     $this->logger = $this->getMockBuilder('Migration\\Logger\\Logger')->disableOriginalConstructor()->setMethods(['debug'])->getMock();
     $this->data = new Data($this->progress, $this->source, $this->destination, $this->recordFactory, $this->recordTransformerFactory, $mapFactory, $groupsFactory, $this->logger);
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->source = $this->getMock('\\Migration\\ResourceModel\\Source', [], [], '', false);
     $this->logger = $this->getMock('\\Migration\\Logger\\Logger', [], [], '', false);
     $this->map = $this->getMock('\\Migration\\Reader\\Map', [], [], '', false);
     /** @var \Migration\Reader\MapFactory|\PHPUnit_Framework_MockObject_MockObject $mapFactory */
     $mapFactory = $this->getMock('\\Migration\\Reader\\MapFactory', [], [], '', false);
     $mapFactory->expects($this->any())->method('create')->with('map_file')->willReturn($this->map);
     $this->destination = $this->getMock('\\Migration\\ResourceModel\\Destination', ['getAdapter'], [], '', false);
     $this->recordFactory = $this->getMock('\\Migration\\ResourceModel\\RecordFactory', [], [], '', false);
     $this->recordTransformerFactory = $this->getMock('\\Migration\\RecordTransformerFactory', [], [], '', false);
     $this->data = $this->getMock('\\Migration\\Step\\Map\\Data', [], [], '', false);
     $this->readerGroups = $this->getMock('\\Migration\\Reader\\Groups', ['getGroup'], [], '', false);
     $this->readerGroups->expects($this->any())->method('getGroup')->willReturnMap([['delta_map', ['orders' => 'order_id']]]);
     /** @var \Migration\Reader\GroupsFactory|\PHPUnit_Framework_MockObject_MockObject $groupsFactory */
     $groupsFactory = $this->getMock('\\Migration\\Reader\\GroupsFactory', ['create'], [], '', false);
     $groupsFactory->expects($this->any())->method('create')->with('delta_document_groups_file')->willReturn($this->readerGroups);
     $this->delta = new Delta($this->source, $mapFactory, $groupsFactory, $this->logger, $this->destination, $this->recordFactory, $this->recordTransformerFactory, $this->data);
 }
 /**
  * Init EAV attributes
  * @return void
  */
 protected function getAttributeType()
 {
     $entities = [self::ENTITY => ''];
     $documentGroups = [self::ATTRIBUTE => ''];
     $this->readerGroups->expects($this->at(0))->method('getGroup')->with('eav_entities')->willReturn($entities);
     $this->readerGroups->expects($this->at(1))->method('getGroup')->with(self::ENTITY)->willReturn($this->sourceDocuments);
     $this->source->expects($this->any())->method('getAdapter')->willReturn($this->adapter);
     $this->adapter->expects($this->at(1))->method('fetchAll')->with($this->select)->willReturn($this->attribute);
     $this->readerAttributes->expects($this->any())->method('getGroup')->willReturn($documentGroups);
     $this->helper->getAttributeType(self::DOCUMENT);
 }
Exemplo n.º 9
0
 public function testPerformWithError()
 {
     $fields = ['field1' => ['DATA_TYPE' => 'int']];
     $this->map->expects($this->atLeastOnce())->method('getDocumentMap')->willReturnMap([['source_document', MapInterface::TYPE_SOURCE, 'source_document'], ['common_document', MapInterface::TYPE_SOURCE, 'common_document'], ['source_document', MapInterface::TYPE_DEST, 'source_document'], ['common_document', MapInterface::TYPE_DEST, 'common_document']]);
     $structure = $this->getMockBuilder('\\Migration\\Resource\\Structure')->disableOriginalConstructor()->setMethods([])->getMock();
     $structure->expects($this->any())->method('getFields')->will($this->returnValue($fields));
     $document = $this->getMockBuilder('\\Migration\\Resource\\Document')->disableOriginalConstructor()->getMock();
     $document->expects($this->any())->method('getStructure')->will($this->returnValue($structure));
     $this->source->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['source_document', 'common_document']));
     $this->source->expects($this->atLeastOnce())->method('getDocument')->willReturn($document);
     $this->destination->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['common_document']));
     $this->destination->expects($this->atLeastOnce())->method('getDocument')->willReturn($document);
     $this->logger->expects($this->once())->method('error')->with('Source documents not mapped: source_document');
     $this->readerGroups->expects($this->any())->method('getGroup')->with('documents')->willReturn(['source_document' => 0, 'common_document' => 1]);
     $this->assertFalse($this->integrity->perform());
 }