class DbImportCommandTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php \Drupal\Tests\system\Kernel\Scripts\DbImportCommandTest
Test that the DbImportCommand works correctly.
@group console
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Kernel\Scripts\DbImportCommandTest implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of DbImportCommandTest
File
-
core/
modules/ system/ tests/ src/ Kernel/ Scripts/ DbImportCommandTest.php, line 15
Namespace
Drupal\Tests\system\Kernel\ScriptsView source
class DbImportCommandTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'config',
'dblog',
'menu_link_content',
'link',
'block_content',
'file',
'user',
];
/**
* Tables that should be part of the exported script.
*
* @var array
*/
protected $tables = [
'block_content',
'block_content_field_data',
'block_content_field_revision',
'block_content_revision',
'cachetags',
'config',
'cache_discovery',
'cache_bootstrap',
'file_managed',
'key_value_expire',
'menu_link_content',
'menu_link_content_data',
'path_alias',
'sessions',
'user__roles',
'users',
'users_field_data',
'watchdog',
];
/**
* Tests the command directly.
*
* @requires extension pdo_sqlite
*/
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-8.8.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.