function DbImportCommandTest::testDbImportCommand

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php \Drupal\Tests\system\Kernel\Scripts\DbImportCommandTest::testDbImportCommand()
  2. 8.9.x core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php \Drupal\Tests\system\Kernel\Scripts\DbImportCommandTest::testDbImportCommand()
  3. 11.x core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php \Drupal\Tests\system\Kernel\Scripts\DbImportCommandTest::testDbImportCommand()

Tests the command directly.

@requires extension pdo_sqlite

File

core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php, line 64

Class

DbImportCommandTest
Test that the DbImportCommand works correctly.

Namespace

Drupal\Tests\system\Kernel\Scripts

Code

public function testDbImportCommand() : void {
    $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()
            ->tableExists($table), strtr('Table @table created by the database script.', [
            '@table' => $table,
        ]));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.