ensureTables example

public function getDatabase() {
    $this->init();
    return $this->database;
  }

  /** * Initialize the plugin. */
  protected function init() {
    if (!$this->initialized) {
      $this->initialized = TRUE;
      $this->ensureTables();
    }
  }

  /** * {@inheritdoc} */
  public function setMessage(MigrateMessageInterface $message) {
    $this->message = $message;
  }

  /** * Create the map and message tables if they don't already exist. * * @throws \Drupal\Core\Database\DatabaseExceptionWrapper */


      default:
        throw new MigrateException($id_definition['type'] . ' not supported');
    }
  }

  /** * {@inheritdoc} */
  public function ensureTables() {
    parent::ensureTables();
  }

  /** * {@inheritdoc} */
  public function getMigrationPluginManager() {
    return parent::getMigrationPluginManager();
  }

}
/** * Tests that ensureTables creates the migrate map table. * * @dataProvider providerTestEnsureTables */
  public function testEnsureTables($ids) {
    $this->migrationDefinition['source']['ids'] = $ids;
    $migration = $this->migrationPluginManager->createStubMigration($this->migrationDefinition);

    $map = new TestSqlIdMap($this->database, [], 'test', []$migration$this->eventDispatcher, $this->migrationPluginManager);
    $map->ensureTables();

    // Checks that the map table was created.     $exists = $this->database->schema()->tableExists('migrate_map_test');
    $this->assertTrue($exists);
  }

  /** * Provides data for testEnsureTables. */
  public function providerTestEnsureTables() {
    return [
      
Home | Imprint | This part of the site doesn't use cookies.