DbImportCommand example


  public function testDbImportCommand() {
    $connection_info = [
      'driver' => 'sqlite',
      'database' => ':memory:',
    ];
    Database::addConnectionInfo($this->databasePrefix, 'default', $connection_info);

    $command = new DbImportCommand();
    $command_tester = new CommandTester($command);
    $command_tester->execute([
      'script' => __DIR__ . '/../../../fixtures/update/drupal-9.4.0.bare.standard.php.gz',
      '--database' => $this->databasePrefix,
    ]);

    // The tables should now exist.     $connection = Database::getConnection('default', $this->databasePrefix);
    foreach ($this->tables as $table) {
      $this->assertTrue($connection
        ->schema()
        

  public function __construct() {
    parent::__construct('Database Tools', \Drupal::VERSION);
  }

  /** * {@inheritdoc} */
  protected function getDefaultCommands(): array {
    $default_commands = parent::getDefaultCommands();
    $default_commands[] = new DbDumpCommand();
    $default_commands[] = new DbImportCommand();
    return $default_commands;
  }

}
Home | Imprint | This part of the site doesn't use cookies.