You are here

protected function CommerceMigrateBaseTestCase::migrate in Commerce Migrate 7

Performs migration action.

Parameters

string $action: One of two possible actions: "import" or "rollback".

Throws

\Exception

See also

\MigrationBase::processImport()

\MigrationBase::processRollback()

2 calls to CommerceMigrateBaseTestCase::migrate()
CommerceMigrateBaseTestCase::setUp in tests/commerce_migrate_base.test
Sets up a Drupal site for running functional and integration tests.
CommerceMigrateTestCase::testRollback in tests/commerce_migrate_tests.test
Tests of removing imported data.

File

tests/commerce_migrate_base.test, line 178
Base facade for "Commerce Migrate" tests.

Class

CommerceMigrateBaseTestCase
Class CommerceMigrateBaseTestCase.

Code

protected function migrate($action) {
  $action = ucfirst($action);
  $method = "process{$action}";
  if (!method_exists('MigrationBase', $method)) {
    throw new \Exception(format_string('Wrong action! Read documentation for "@method" method!', array(
      '@method' => __METHOD__,
    )));
  }
  $info = module_invoke('commerce_migrate_example', 'migrate_api');

  // Rollback should be in a reverse order.
  if ('Rollback' === $action) {
    $info['migrations'] = array_reverse($info['migrations']);
  }
  foreach ($info['migrations'] as $migration => $definition) {
    $this
      ->assertEqual(\Migration::getInstance($migration)
      ->{$method}(), \Migration::RESULT_COMPLETED, format_string('@action of "@migration" completed.', array(
      '@action' => $action,
      '@migration' => $migration,
    )));
  }
}