function DbCommandBaseTest::testSpecifyDatabaseKey

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

Tests specifying a database key.

File

core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php, line 28

Class

DbCommandBaseTest
Test that the DbToolsApplication works correctly.

Namespace

Drupal\Tests\system\Kernel\Scripts

Code

public function testSpecifyDatabaseKey() : void {
    $command = new DbCommandBaseTester();
    $command_tester = new CommandTester($command);
    Database::addConnectionInfo('magic_db', 'default', Database::getConnectionInfo('default')['default']);
    $command_tester->execute([
        '--database' => 'magic_db',
    ]);
    $this->assertEquals('magic_db', $command->getDatabaseConnection($command_tester->getInput())
        ->getKey(), 'Special db key is returned');
}

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