public function testGetRecordsCount() { $sourceCount = $this->source->getRecordsCount('table_with_data'); $destinationCount = $this->destination->getRecordsCount('table_without_data'); $this->assertEquals(7, $sourceCount); $this->assertEquals(0, $destinationCount); }
/** * @return bool */ public function perform() { $documents = $this->helper->getDocumentList(); $this->progressBar->start(1); $oldDestinationRecordsCount = $this->helper->getDestinationRecordsCount(); $newDestinationRecordsCount = $this->destination->getRecordsCount($documents[MapInterface::TYPE_DEST]) - $oldDestinationRecordsCount; if ($newDestinationRecordsCount != 0) { $this->errors[] = 'Mismatch of entities in the document: ' . $documents[MapInterface::TYPE_DEST]; } $this->progressBar->finish(); return $this->checkForErrors(); }
/** * @return bool */ public function perform() { $this->progressBar->start($this->getIterationsCount()); foreach ($this->helper->getDocumentList() as $sourceDocumentName => $destinationDocumentName) { $this->progressBar->advance(); $sourceRecordsCount = $this->source->getRecordsCount($sourceDocumentName); $destinationRecordsCount = $this->destination->getRecordsCount($destinationDocumentName); if ($sourceRecordsCount != $destinationRecordsCount) { $this->errors[] = 'Mismatch of entities in the document: ' . $destinationDocumentName; } } $this->progressBar->finish(); return $this->checkForErrors(); }
/** * @return bool * @throws \Migration\Exception */ protected function data() { $destinationDocument = $this->destination->getDocument(self::CONFIG_TABLE_NAME_DESTINATION); $recordsCountSource = $this->source->getRecordsCount(self::CONFIG_TABLE_NAME_SOURCE); $recordsCountDestination = $this->destination->getRecordsCount(self::CONFIG_TABLE_NAME_DESTINATION); $this->progress->start($recordsCountSource); $sourceRecords = $this->source->getRecords(self::CONFIG_TABLE_NAME_SOURCE, 0, $recordsCountSource); $destinationRecords = $this->destination->getRecords(self::CONFIG_TABLE_NAME_DESTINATION, 0, $recordsCountDestination); foreach ($sourceRecords as $sourceRecord) { $this->progress->advance(); if (!$this->readerSettings->isNodeIgnored($sourceRecord[self::CONFIG_FIELD_PATH])) { $sourceRecordPathMapped = $this->readerSettings->getNodeMap($sourceRecord[self::CONFIG_FIELD_PATH]); foreach ($destinationRecords as &$destinationRecord) { if ($destinationRecord[self::CONFIG_FIELD_SCOPE] == $sourceRecord[self::CONFIG_FIELD_SCOPE] && $destinationRecord[self::CONFIG_FIELD_SCOPE_ID] == $sourceRecord[self::CONFIG_FIELD_SCOPE_ID] && $destinationRecord[self::CONFIG_FIELD_PATH] == $sourceRecordPathMapped) { $record = $this->applyHandler($destinationDocument, $sourceRecord, $destinationRecord); $destinationRecord[self::CONFIG_FIELD_VALUE] = $record->getValue(self::CONFIG_FIELD_VALUE); continue 2; } } $record = $this->applyHandler($destinationDocument, $sourceRecord, []); $record->setValue(self::CONFIG_FIELD_PATH, $sourceRecordPathMapped); $destinationRecords[] = $record->getData(); } } foreach ($destinationRecords as &$destinationRecord) { unset($destinationRecord[self::CONFIG_FIELD_CONFIG_ID]); } $this->destination->clearDocument(self::CONFIG_TABLE_NAME_DESTINATION); $this->destination->saveRecords(self::CONFIG_TABLE_NAME_DESTINATION, $destinationRecords); $this->progress->finish(); return true; }
public function testGetRecordsCount() { $prefix = 'prefix_'; $this->config->expects($this->any())->method('getOption')->with('dest_prefix')->will($this->returnValue($prefix)); $resourceName = 'core_config_data'; $this->adapter->expects($this->any())->method('getRecordsCount')->with($prefix . $resourceName)->willReturn(10); $this->assertEquals(10, $this->resourceDestination->getRecordsCount($resourceName)); }
/** * @param string $sourceDocName * @param array $keyFields * @return array */ public function getDestinationRecords($sourceDocName, $keyFields = []) { $destinationDocumentName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE); $data = []; $count = $this->destination->getRecordsCount($destinationDocumentName); foreach ($this->destination->getRecords($destinationDocumentName, 0, $count) as $row) { if ($keyFields) { $key = []; foreach ($keyFields as $keyField) { $key[] = $row[$keyField]; } $data[implode('-', $key)] = $row; } else { $data[] = $row; } } return $data; }
/** * @return bool */ public function perform() { $sourceDocuments = $this->source->getDocumentList(); $this->progressBar->start(count($sourceDocuments)); foreach ($sourceDocuments as $sourceDocName) { $this->progressBar->advance(); $destinationName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE); if (!$destinationName) { continue; } $sourceCount = $this->source->getRecordsCount($sourceDocName); $destinationCount = $this->destination->getRecordsCount($destinationName); if ($sourceCount != $destinationCount) { $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName; } } $this->progressBar->finish(); return $this->checkForErrors(); }
/** * @return bool */ public function perform() { $sourceDocuments = array_keys($this->readerGroups->getGroup('source_documents')); $this->progress->start($this->getIterationsCount()); foreach ($sourceDocuments as $sourceDocName) { $this->progress->advance(); $destinationName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE); if (!$destinationName) { continue; } $sourceCount = $this->helper->getSourceRecordsCount($sourceDocName); $destinationCount = $this->destination->getRecordsCount($destinationName); if ($sourceCount != $destinationCount) { $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName; } } $this->progress->finish(); return $this->checkForErrors(); }
/** * Volume check * * @return bool */ protected function volume() { $result = true; $this->progress->start(1); $result &= $this->source->getRecordsCount(self::SOURCE) == $this->destination->getRecordsCount(self::DESTINATION); if (!$result) { $this->logger->warning('Mismatch of entities in the document: url_rewrite'); } $this->progress->advance(); $this->progress->finish(); return (bool) $result; }
/** * {@inheritdoc} */ protected function volume() { $this->progress->start(1); $this->getRewritesSelect(); $this->progress->advance(); $result = $this->source->getRecordsCount($this->tableName) == $this->destination->getRecordsCount('url_rewrite'); if (!$result) { $this->logger->error('Mismatch of entities in the document: url_rewrite'); } $this->progress->finish(); return $result; }
/** * Volume check * * @return bool */ protected function volume() { $result = true; $this->progress->start(count($this->getDocumentList())); foreach ($this->getDocumentList() as $sourceName => $destinationName) { $this->progress->advance(); if ($this->source->getRecordsCount($sourceName) != $this->destination->getRecordsCount($destinationName)) { $this->logger->error('Mismatch of entities in the document: ' . $destinationName); $result = false; } } $this->progress->finish(); return $result; }
/** * @param array $documents * @return bool */ protected function checkCleared($documents) { $documentsAreEmpty = true; foreach ($documents as $documentName) { $this->progress->advance(); $destinationCount = $this->destination->getRecordsCount($documentName); if ($destinationCount > 0) { $documentsAreEmpty = false; break; } $destinationCount = null; } return $documentsAreEmpty; }
/** * @return void */ public function init() { if (!$this->getDestinationRecordsCount()) { $this->destinationRecordsCount = $this->destination->getRecordsCount($this->getDocumentList()['destination']); } }