/**
  * @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);
 }
 /**
  * @param array $columns
  * @param \Zend_Db_Expr|array $entityIds
  * @return \Magento\Framework\DB\Select
  */
 public function getSelectSalesCreditmemoGrid(array $columns, $entityIds)
 {
     foreach ($columns as $key => $value) {
         $columns[$key] = new \Zend_Db_Expr($value);
     }
     /** @var \Magento\Framework\DB\Select $select */
     $select = $this->destinationAdapter->getSelect();
     $select->from(['sales_creditmemo' => $this->destination->addDocumentPrefix('sales_creditmemo')], [])->joinLeft(['sales_order' => $this->destination->addDocumentPrefix('sales_order')], 'sales_creditmemo.order_id = sales_order.entity_id', [])->joinLeft(['sales_shipping_address' => $this->destination->addDocumentPrefix('sales_order_address')], 'sales_creditmemo.shipping_address_id = sales_shipping_address.entity_id', [])->joinLeft(['sales_billing_address' => $this->destination->addDocumentPrefix('sales_order_address')], 'sales_creditmemo.billing_address_id = sales_billing_address.entity_id', [])->where('sales_creditmemo.entity_id in (?)', $entityIds);
     $select->columns($columns);
     return $select;
 }
 /**
  * Fulfill temporary table with redirects
  *
  * @param \Migration\ResourceModel\Adapter\Mysql $adapter
  * @return void
  */
 protected function collectRedirects(\Migration\ResourceModel\Adapter\Mysql $adapter)
 {
     $select = $adapter->getSelect();
     $select->from(['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')], ['id' => 'IFNULL(NULL, NULL)', 'request_path' => 'r.request_path', 'target_path' => 'r.target_path', 'is_system' => 'r.is_system', 'store_id' => "s.store_id", 'entity_type' => "trim('custom')", 'redirect_type' => "(SELECT CASE eurr.options WHEN 'RP' THEN 301 WHEN 'R' THEN 302 ELSE 0 END)", 'product_id' => "trim('0')", 'category_id' => "trim('0')", 'cms_page_id' => "trim('0')", 'priority' => "trim('2')"]);
     $select->join(['eurrr' => $this->source->addDocumentPrefix('enterprise_url_rewrite_redirect_rewrite')], 'eurrr.url_rewrite_id = r.url_rewrite_id', []);
     $select->join(['eurr' => $this->source->addDocumentPrefix('enterprise_url_rewrite_redirect')], 'eurrr.redirect_id = eurr.redirect_id', []);
     $select->join(['s' => $this->source->addDocumentPrefix('core_store')], 's.store_id > 0', []);
     $query = $select->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
     $select->getAdapter()->query($query);
 }
 /**
  * @return string
  */
 protected function getPriceAttributeId()
 {
     $select = $this->sourceAdapter->getSelect();
     $select->from($this->source->addDocumentPrefix('eav_attribute'))->where('attribute_code = ?', 'price');
     return $select->getAdapter()->fetchOne($select);
 }
 /**
  * @return void
  */
 public function testDeleteBackup()
 {
     $this->pdoMysql->expects($this->once())->method('isTableExists')->willReturn(true);
     $this->pdoMysql->expects($this->once())->method('dropTable')->with('migration_backup_document_name');
     $this->adapterMysql->deleteBackup('document_name');
 }
 /**
  * @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');
 }