/**
  * @return void
  */
 public function testPerform()
 {
     $this->data = new Data($this->destination, $this->progress);
     $this->progress->expects($this->once())->method('start')->with(1);
     $this->progress->expects($this->once())->method('advance');
     $this->progress->expects($this->once())->method('finish');
     $this->destination->expects($this->once())->method('getAdapter')->willReturn($this->adapter);
     $this->adapter->expects($this->once())->method('getSelect')->willReturn($this->select);
     $this->select->expects($this->once())->method('from')->with('rating_store', ['rating_id'])->will($this->returnSelf());
     $this->select->expects($this->once())->method('where')->with('store_id > 0')->will($this->returnSelf());
     $this->adapter->expects($this->once())->method('loadDataFromSelect')->with($this->select)->willReturn([['rating_id' => 1]]);
     $this->adapter->expects($this->once())->method('updateDocument')->with('rating', ['is_active' => 1], 'rating_id IN (1)');
     $this->data->perform();
 }
 /**
  * @return void
  */
 public function testDeleteDocumentBackup()
 {
     $docName = 'somename';
     $this->adapter->expects($this->once())->method('deleteBackup')->with('pfx_' . $docName);
     $this->config->expects($this->once())->method('getOption')->with('dest_prefix')->will($this->returnValue('pfx_'));
     $this->resourceDestination->deleteDocumentBackup($docName);
 }
 /**
  * @return void
  */
 public function testPerformFailed()
 {
     $this->volume = new Volume($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->once())->method('finish');
     $this->destination->expects($this->once())->method('getAdapter')->willReturn($this->adapter);
     $this->adapter->expects($this->exactly(2))->method('getSelect')->willReturn($this->select);
     $this->select->expects($this->at(0))->method('from')->with('rating_store', ['rating_id'])->will($this->returnSelf());
     $this->select->expects($this->at(1))->method('where')->with('store_id > 0')->will($this->returnSelf());
     $this->adapter->expects($this->at(1))->method('loadDataFromSelect')->with($this->select)->willReturn([['rating_id' => 1]]);
     $this->adapter->expects($this->at(3))->method('loadDataFromSelect')->with($this->select)->willReturn([['rating_id' => 2]]);
     $this->select->expects($this->at(2))->method('from')->with('rating', ['rating_id'])->will($this->returnSelf());
     $this->select->expects($this->at(3))->method('where')->with('is_active = ?', 1)->will($this->returnSelf());
     $this->logger->expects($this->once())->method('addRecord')->with(Logger::ERROR, 'Mismatch of entities in the documents: rating, rating_store');
     $this->assertFalse($this->volume->perform());
 }
 /**
  * @return void
  */
 public function testGetRecords()
 {
     $resourceName = 'core_config_data';
     $pageNumber = 2;
     $this->config->expects($this->at(0))->method('getOption')->with('bulk_size')->will($this->returnValue(100));
     $this->config->expects($this->at(1))->method('getOption')->with('dest_prefix')->will($this->returnValue(100));
     $this->adapter->expects($this->once())->method('loadPage');
     $this->resourceDestination->getRecords($resourceName, $pageNumber);
 }
 /**
  * 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);
 }
 /**
  * @return void
  */
 public function testGetDeletedRecords()
 {
     $this->adapter->expects($this->once())->method('loadDeletedRecords')->with('m2_cl_document', 'key_field', 0, 100);
     $this->config->expects($this->any())->method('getOption')->willReturnMap([['source_prefix', ''], ['bulk_size', 100]]);
     $this->resourceSource->getDeletedRecords('document', 'key_field');
 }