Exemple #1
0
 public function testPerform()
 {
     $progress = $this->getMock('Migration\\App\\Progress', ['getProcessedEntities', 'addProcessedEntity'], [], '', false);
     $progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([]));
     $progress->expects($this->any())->method('addProcessedEntity');
     $helper = \Migration\TestFramework\Helper::getInstance();
     $objectManager = $helper->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/../_files/' . $helper->getFixturePrefix() . 'config.xml');
     $logManager = $objectManager->create('\\Migration\\Logger\\Manager');
     $logger = $objectManager->create('\\Migration\\Logger\\Logger');
     $logger->pushHandler($objectManager->create('\\Migration\\Logger\\ConsoleHandler'));
     $config = $objectManager->get('\\Migration\\Config');
     $destination = $objectManager->get('\\Migration\\Resource\\Destination');
     /** @var \Migration\Logger\Manager $logManager */
     $logManager->process(\Migration\Logger\Manager::LOG_LEVEL_ERROR);
     \Migration\Logger\Logger::clearMessages();
     $map = $objectManager->create('\\Migration\\Step\\Map\\Data', ['logger' => $logger, 'config' => $config, 'progress' => $progress]);
     ob_start();
     $map->perform();
     ob_end_clean();
     $migratedData = $destination->getRecords('table_without_data', 0);
     $migratedDataExpected = [['key' => 1, 'field1' => 1, 'field2' => 2, 'field3' => 3], ['key' => 2, 'field1' => 2, 'field2' => 3, 'field3' => 4], ['key' => 3, 'field1' => 3, 'field2' => 4, 'field3' => 5], ['key' => 4, 'field1' => 4, 'field2' => 5, 'field3' => 6], ['key' => 5, 'field1' => 5, 'field2' => 5, 'field3' => 5], ['key' => 6, 'field1' => 6, 'field2' => 6, 'field3' => 7], ['key' => 7, 'field1' => 7, 'field2' => 7, 'field3' => 7]];
     $migratedDataIgnored = $destination->getRecords('table_ignored', 0);
     $migratedDataIgnoredExpected = [];
     $migratedDataPresetValue = $destination->getRecords('common_table', 0);
     $migratedDataPresetValueExpected = [['key' => 1, 'dest_field_ignored' => 0, 'common_field' => 123], ['key' => 2, 'dest_field_ignored' => 0, 'common_field' => 123], ['key' => 3, 'dest_field_ignored' => 0, 'common_field' => 123], ['key' => 4, 'dest_field_ignored' => 0, 'common_field' => 123], ['key' => 5, 'dest_field_ignored' => 0, 'common_field' => 123], ['key' => 6, 'dest_field_ignored' => 0, 'common_field' => 123], ['key' => 7, 'dest_field_ignored' => 0, 'common_field' => 123]];
     $logOutput = \Migration\Logger\Logger::getMessages();
     $this->assertFalse(isset($logOutput[\Monolog\Logger::ERROR]));
     $this->assertEquals($migratedDataExpected, $migratedData);
     $this->assertEquals($migratedDataIgnoredExpected, $migratedDataIgnored);
     $this->assertEquals($migratedDataPresetValueExpected, $migratedDataPresetValue);
 }
Exemple #2
0
 public function testIntegrityWithoutMap()
 {
     $objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/../_files/config-with-empty-map.xml');
     $logManager = $objectManager->create('\\Migration\\Logger\\Manager');
     $logger = $objectManager->create('\\Migration\\Logger\\Logger');
     $logger->pushHandler($objectManager->create('\\Migration\\Logger\\ConsoleHandler'));
     $config = $objectManager->get('\\Migration\\Config');
     /** @var \Migration\Logger\Manager $logManager */
     $logManager->process(\Migration\Logger\Manager::LOG_LEVEL_ERROR);
     \Migration\Logger\Logger::clearMessages();
     /** @var \Migration\Step\Map\Integrity $map */
     $map = $objectManager->create('\\Migration\\Step\\Map\\Integrity', ['logger' => $logger, 'config' => $config]);
     ob_start();
     $map->perform();
     ob_end_clean();
     $messages = [];
     $messages[] = 'Source documents not mapped: ';
     $messages[] = 'source_table_1,source_table_2,source_table_ignored,source_table_renamed,table_with_data';
     $messages[] = 'Destination documents not mapped: ';
     $messages[] = 'dest_table_1,dest_table_2,dest_table_ignored,dest_table_renamed,table_without_data';
     $messages[] = 'Source fields not mapped. ';
     $messages[] = 'Document: common_table. Fields: source_field_ignored';
     $messages[] = 'Destination fields not mapped. ';
     $messages[] = 'Document: common_table. Fields: dest_field_ignored';
     $logOutput = \Migration\Logger\Logger::getMessages();
     $this->assertTrue(isset($logOutput[\Monolog\Logger::ERROR]));
     $errors = implode("\n", $logOutput[\Monolog\Logger::ERROR]);
     foreach ($messages as $text) {
         $this->assertContains($text, $errors);
     }
 }
Exemple #3
0
 public function setUp()
 {
     $objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/../_files/config.xml');
     $initialData = $objectManager->get('Migration\\Step\\Eav\\InitialData');
     $this->eav = $objectManager->create('Migration\\Step\\Eav\\Integrity', ['initialData' => $initialData]);
 }
 /**
  * @throws \Migration\Exception
  * @return void
  */
 public function testPerform()
 {
     $helper = \Migration\TestFramework\Helper::getInstance();
     $objectManager = $helper->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/../_files/' . $helper->getFixturePrefix() . 'config.xml');
     $logManager = $objectManager->create('\\Migration\\Logger\\Manager');
     $recordFactory = $objectManager->create('\\Migration\\ResourceModel\\RecordFactory');
     $progress = $objectManager->create('\\Migration\\App\\ProgressBar\\LogLevelProcessor');
     $logger = $objectManager->create('\\Migration\\Logger\\Logger');
     $mapReader = $objectManager->create('\\Migration\\Reader\\Settings');
     $handlerManagerFactory = $objectManager->get('\\Migration\\Handler\\ManagerFactory');
     $destination = $objectManager->get('\\Migration\\ResourceModel\\Destination');
     $source = $objectManager->get('\\Migration\\ResourceModel\\Source');
     /** @var \Migration\Logger\Manager $logManager */
     $logManager->process(\Migration\Logger\Manager::LOG_LEVEL_ERROR);
     \Migration\Logger\Logger::clearMessages();
     $data = $objectManager->create('\\Migration\\Step\\Settings\\Data', ['destination' => $destination, 'source' => $source, 'logger' => $logger, 'progress' => $progress, 'recordFactory' => $recordFactory, 'mapReader' => $mapReader, 'handlerManagerFactory' => $handlerManagerFactory]);
     ob_start();
     $data->perform();
     ob_end_clean();
     $migratedData = $destination->getRecords('core_config_data', 0);
     $migratedDataExpected = [['config_id' => 1, 'scope' => 'default', 'scope_id' => 0, 'path' => 'web/seo/use_rewrites', 'value' => 1], ['config_id' => 2, 'scope' => 'default', 'scope_id' => 0, 'path' => 'web/unsecure/base_url', 'value' => 'http://magento2.dev/'], ['config_id' => 3, 'scope' => 'default', 'scope_id' => 0, 'path' => 'admin/security/session_lifetime', 'value' => 90], ['config_id' => 4, 'scope' => 'default', 'scope_id' => 0, 'path' => 'catalog/seo/product_url_suffix', 'value' => '.phtml'], ['config_id' => 5, 'scope' => 'default', 'scope_id' => 0, 'path' => 'my/extension/path', 'value' => 'value1']];
     $logOutput = \Migration\Logger\Logger::getMessages();
     $this->assertFalse(isset($logOutput[\Monolog\Logger::ERROR]));
     $this->assertEquals($migratedDataExpected, $migratedData);
 }
 /**
  * @throws \Migration\Exception
  * @return void
  */
 public function testPerform()
 {
     $salesOrderToMigrate = [['entity_id' => '1', 'store_id' => '1'], ['entity_id' => '2', 'store_id' => '1'], ['entity_id' => '3', 'store_id' => '1']];
     $eavAttributesToMigrate = [['value_id' => '1', 'entity_type_id' => '1', 'attribute_id' => '1', 'store_id' => '1', 'entity_id' => '1', 'value' => '1'], ['value_id' => '2', 'entity_type_id' => '1', 'attribute_id' => '2', 'store_id' => '1', 'entity_id' => '1', 'value' => '2'], ['value_id' => '3', 'entity_type_id' => '1', 'attribute_id' => '1', 'store_id' => '1', 'entity_id' => '2', 'value' => '1'], ['value_id' => '4', 'entity_type_id' => '1', 'attribute_id' => '2', 'store_id' => '1', 'entity_id' => '3', 'value' => '2']];
     $objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/../_files/config.xml');
     $logManager = $objectManager->create('\\Migration\\Logger\\Manager');
     $logger = $objectManager->create('\\Migration\\Logger\\Logger');
     $config = $objectManager->get('\\Migration\\Config');
     $initialData = $objectManager->get('\\Migration\\Step\\SalesOrder\\InitialData');
     $destination = $objectManager->get('\\Migration\\ResourceModel\\Destination');
     /** @var \Migration\Logger\Manager $logManager */
     $logManager->process(\Migration\Logger\Manager::LOG_LEVEL_ERROR);
     \Migration\Logger\Logger::clearMessages();
     $data = $objectManager->create('\\Migration\\Step\\SalesOrder\\Data', ['logger' => $logger, 'config' => $config, 'initialData' => $initialData]);
     $volume = $objectManager->create('\\Migration\\Step\\SalesOrder\\Volume', ['logger' => $logger, 'config' => $config, 'initialData' => $initialData]);
     ob_start();
     $data->perform();
     $this->assertTrue($volume->perform());
     ob_end_clean();
     $this->assertEquals($eavAttributesToMigrate, $destination->getRecords('eav_entity_int', 0));
     $this->assertEquals($salesOrderToMigrate, $destination->getRecords('sales_order', 0));
     $logOutput = \Migration\Logger\Logger::getMessages();
     $this->assertFalse(isset($logOutput[\Monolog\Logger::ERROR]));
 }
 /**
  * @return void
  */
 protected function setUp()
 {
     $helper = \Migration\TestFramework\Helper::getInstance();
     $objectManager = $helper->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/_files/' . $helper->getFixturePrefix() . 'config.xml');
     $this->source = $objectManager->get('\\Migration\\ResourceModel\\Source');
     $this->destination = $objectManager->get('\\Migration\\ResourceModel\\Destination');
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $helper = \Migration\TestFramework\Helper::getInstance();
     $objectManager = $helper->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/../_files/' . $helper->getFixturePrefix() . 'config.xml');
     $this->progress = $objectManager->create('Migration\\App\\ProgressBar\\LogLevelProcessor');
     $this->source = $objectManager->create('Migration\\ResourceModel\\Source');
     $this->destination = $objectManager->create('Migration\\ResourceModel\\Destination');
     $this->helper = $objectManager->create('Migration\\Step\\Stores\\Helper');
 }
 /**
  * @throws \Migration\Exception
  * @return void
  */
 protected function setUp()
 {
     $helper = \Migration\TestFramework\Helper::getInstance();
     $this->objectManager = $helper->getObjectManager();
     $this->objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/../_files/' . $helper->getFixturePrefix() . 'config.xml');
     $this->tableName = 'url_rewrite_m2' . md5('url_rewrite_m2');
     $logManager = $this->objectManager->create('\\Migration\\Logger\\Manager');
     $this->logger = $this->objectManager->create('\\Migration\\Logger\\Logger');
     $this->logger->pushHandler($this->objectManager->create('\\Migration\\Logger\\ConsoleHandler'));
     $this->config = $this->objectManager->get('\\Migration\\Config');
     /** @var \Migration\Logger\Manager $logManager */
     $logManager->process(\Migration\Logger\Manager::LOG_LEVEL_ERROR);
     \Migration\Logger\Logger::clearMessages();
 }
 /**
  * @throws \Migration\Exception
  * @return void
  */
 public function testPerform()
 {
     $objectManager = \Migration\TestFramework\Helper::getInstance()->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/../_files/config.xml');
     $logManager = $objectManager->create('\\Migration\\Logger\\Manager');
     $logger = $objectManager->create('\\Migration\\Logger\\Logger');
     $config = $objectManager->get('\\Migration\\Config');
     $initialData = $objectManager->get('\\Migration\\Step\\SalesOrder\\InitialData');
     /** @var \Migration\Logger\Manager $logManager */
     $logManager->process(\Migration\Logger\Manager::LOG_LEVEL_ERROR);
     \Migration\Logger\Logger::clearMessages();
     /** @var \Migration\Step\SalesOrder\Integrity $salesOrder */
     $salesOrder = $objectManager->create('\\Migration\\Step\\SalesOrder\\Integrity', ['logger' => $logger, 'config' => $config, 'initialData' => $initialData]);
     ob_start();
     $salesOrder->perform();
     ob_end_clean();
     $logOutput = \Migration\Logger\Logger::getMessages();
     $this->assertFalse(isset($logOutput[\Monolog\Logger::ERROR]));
 }
 /**
  * @throws \Migration\Exception
  * @return void
  */
 public function testPerform()
 {
     $progress = $this->getMock('Migration\\App\\Progress', ['getProcessedEntities', 'addProcessedEntity'], [], '', false);
     $progress->expects($this->once())->method('getProcessedEntities')->will($this->returnValue([]));
     $progress->expects($this->any())->method('addProcessedEntity');
     $helper = \Migration\TestFramework\Helper::getInstance();
     $objectManager = $helper->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/../_files/' . $helper->getFixturePrefix() . 'config.xml');
     $logManager = $objectManager->create('\\Migration\\Logger\\Manager');
     $logger = $objectManager->create('\\Migration\\Logger\\Logger');
     $config = $objectManager->get('\\Migration\\Config');
     /** @var \Migration\Logger\Manager $logManager */
     $logManager->process(\Migration\Logger\Manager::LOG_LEVEL_ERROR);
     $data = $objectManager->create('\\Migration\\Step\\Map\\Data', ['logger' => $logger, 'config' => $config, 'progress' => $progress]);
     $volume = $objectManager->create('\\Migration\\Step\\Map\\Volume', ['logger' => $logger, 'config' => $config]);
     ob_start();
     $data->perform();
     $isSuccess = $volume->perform();
     ob_end_clean();
     $this->assertTrue($isSuccess);
 }
 public function testSetupTriggers()
 {
     $helper = \Migration\TestFramework\Helper::getInstance();
     $objectManager = $helper->getObjectManager();
     $objectManager->get('\\Migration\\Config')->init(dirname(__DIR__) . '/_files/' . $helper->getFixturePrefix() . 'config.xml');
     /** @var \Migration\Resource\Source $source */
     $source = $objectManager->create('\\Migration\\Resource\\Source');
     /** @var \Migration\App\SetupDeltaLog $setupDeltaLog */
     $setupDeltaLog = $objectManager->create('\\Migration\\App\\SetupDeltaLog');
     ob_start();
     $this->assertTrue($setupDeltaLog->perform());
     ob_end_clean();
     $dataTable = 'table_with_data';
     $this->checkDeltaLogTable($dataTable, $source);
     $this->checkDeltaLogTable('source_table_1', $source);
     $this->checkDeltaLogTable('source_table_2', $source);
     $sourceAdapter = $source->getAdapter();
     $sourceAdapter->insertRecords($dataTable, ['field1' => 100, 'field2' => 2, 'field3' => 3]);
     $sourceAdapter->insertRecords($dataTable, ['field1' => 101, 'field2' => 22, 'field3' => 33]);
     $sourceAdapter->updateDocument($dataTable, ['field2' => 12, 'field3' => 13], 'field1 = 100');
     $expectedData = [['key' => '8', 'operation' => 'UPDATE', 'processed' => 0], ['key' => '9', 'operation' => 'INSERT', 'processed' => 0]];
     $this->assertEquals($expectedData, $source->getRecords($source->getDeltaLogName($dataTable), 0));
 }
Exemple #12
0
 public function __construct()
 {
     $this->helper = \Migration\TestFramework\Helper::getInstance();
 }