function BootableCommandTraitTest::setUp

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Command/BootableCommandTraitTest.php, line 41

Class

BootableCommandTraitTest
Tests the trait that helps console commands boot Drupal.

Namespace

Drupal\Tests\Core\Command

Code

protected function setUp() : void {
  parent::setUp();
  // To boot Drupal, we need a database. For the purposes of this test, an
  // in-memory SQLite database is sufficient.
  Database::addConnectionInfo('default', 'default', [
    'driver' => 'sqlite',
    'namespace' => 'Drupal\\sqlite\\Driver\\Database\\sqlite',
    'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
    'database' => ':memory:',
  ]);
  $class_loaders = ClassLoader::getRegisteredLoaders();
  $this->classLoader = reset($class_loaders);
  $this->application = new Application('drupal', \Drupal::VERSION);
}

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