function DbDumpCommandTest::setUp

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php \Drupal\Tests\system\Kernel\Scripts\DbDumpCommandTest::setUp()
  2. 10 core/modules/mysql/tests/src/Kernel/mysql/Console/DbDumpCommandTest.php \Drupal\Tests\mysql\Kernel\mysql\Console\DbDumpCommandTest::setUp()
  3. 11.x core/modules/mysql/tests/src/Kernel/mysql/Console/DbDumpCommandTest.php \Drupal\Tests\mysql\Kernel\mysql\Console\DbDumpCommandTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php, line 25

Class

DbDumpCommandTest
Test that the DbDumpCommand works correctly.

Namespace

Drupal\Tests\system\Kernel\Scripts

Code

protected function setUp() : void {
    parent::setUp();
    // Determine what database backend is running, and set the skip flag.
    if (Database::getConnection()->databaseType() !== 'mysql') {
        $this->markTestSkipped("Skipping test since the DbDumpCommand is currently only compatible with MySQL");
    }
    // Rebuild the router to ensure a routing table.
    \Drupal::service('router.builder')->rebuild();
    
    /** @var \Drupal\Core\Database\Connection $connection */
    $connection = $this->container
        ->get('database');
    $connection->insert('router')
        ->fields([
        'name',
        'path',
        'pattern_outline',
    ])
        ->values([
        'test',
        'test',
        'test',
    ])
        ->execute();
    // Create a table with a field type not defined in
    // \Drupal\Core\Database\Schema::getFieldTypeMap.
    $table_name = $connection->tablePrefix() . 'foo';
    $sql = "create table if not exists `{$table_name}` (`test` datetime NOT NULL);";
    $connection->query($sql)
        ->execute();
}

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