Issue #3107472 by ravi.shankar, alexpott, kishor_kolekar, jibran: DbDumpCommand should not hardcode the version string

merge-requests/2419/head
xjm 2020-05-05 08:58:01 -05:00
parent 214fb25b48
commit 4276e51131
4 changed files with 7 additions and 2 deletions

View File

@ -93,6 +93,8 @@ class DbDumpCommand extends DbCommandBase {
$tables .= $this->getTableScript($table, $schema, $data); $tables .= $this->getTableScript($table, $schema, $data);
} }
$script = $this->getTemplate(); $script = $this->getTemplate();
// Substitute in the version.
$script = str_replace('{{VERSION}}', \Drupal::VERSION, $script);
// Substitute in the tables. // Substitute in the tables.
$script = str_replace('{{TABLES}}', trim($tables), $script); $script = str_replace('{{TABLES}}', trim($tables), $script);
return trim($script); return trim($script);
@ -395,7 +397,7 @@ class DbDumpCommand extends DbCommandBase {
* @file * @file
* A database agnostic dump for testing purposes. * A database agnostic dump for testing purposes.
* *
* This file was generated by the Drupal 8.0 db-tools.php script. * This file was generated by the Drupal {{VERSION}} db-tools.php script.
*/ */
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;

View File

@ -13,7 +13,7 @@ class DbToolsApplication extends Application {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct() { public function __construct() {
parent::__construct('Database Tools', '8.0.x'); parent::__construct('Database Tools', \Drupal::VERSION);
} }
/** /**

View File

@ -54,6 +54,8 @@ class DbDumpCommandTest extends KernelTestBase {
$this->assertStringContainsString("'path' => 'test", $output, 'Insert path field found'); $this->assertStringContainsString("'path' => 'test", $output, 'Insert path field found');
$this->assertStringContainsString("'pattern_outline' => 'test", $output, 'Insert pattern_outline field found'); $this->assertStringContainsString("'pattern_outline' => 'test", $output, 'Insert pattern_outline field found');
$this->assertStringContainsString("// @codingStandardsIgnoreFile", $output); $this->assertStringContainsString("// @codingStandardsIgnoreFile", $output);
$version = \Drupal::VERSION;
$this->assertStringContainsString("This file was generated by the Drupal {$version} db-tools.php script.", $output);
} }
/** /**

View File

@ -22,6 +22,7 @@ class DbToolsApplicationTest extends KernelTestBase {
$application = new DbToolsApplication(); $application = new DbToolsApplication();
$command = $application->find('dump'); $command = $application->find('dump');
$this->assertInstanceOf('\Drupal\Core\Command\DbDumpCommand', $command); $this->assertInstanceOf('\Drupal\Core\Command\DbDumpCommand', $command);
$this->assertSame(\Drupal::VERSION, $application->getVersion());
} }
/** /**