Unverified Commit 65656ac6 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3152398 by Hardik_Patel_12, ravi.shankar, rajandro, siddhant.bhosale,...

Issue #3152398 by Hardik_Patel_12, ravi.shankar, rajandro, siddhant.bhosale, daffie, mondrake, mondrake, longwave, voleger, andypost, catch, Berdir: Change static queries to dynamic queries in core/tests/Drupal
parent 46da61e3
Loading
Loading
Loading
Loading
+11 −1
Changes for core/tests/Drupal/FunctionalTests/Installer/InstallerDatabaseErrorMessagesTest.php: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -24,7 +24,17 @@ protected function setUpSettings() {
    // it will try and create the drupal_install_test table as this is part of
    // the standard database tests performed by the installer in
    // Drupal\Core\Database\Install\Tasks.
    Database::getConnection('default')->query('CREATE TABLE {drupal_install_test} (id int NOT NULL PRIMARY KEY)');
    $spec = [
      'fields' => [
        'id' => [
          'type' => 'int',
          'not null' => TRUE,
        ],
      ],
      'primary key' => ['id'],
    ];

    Database::getConnection('default')->schema()->createTable('drupal_install_test', $spec);
    parent::setUpSettings();
  }

+12 −2
Changes for core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php: 12 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -53,7 +53,17 @@ protected function setUpSettings() {
    // it will try and create the drupal_install_test table as this is part of
    // the standard database tests performed by the installer in
    // Drupal\Core\Database\Install\Tasks.
    Database::getConnection('default')->query('CREATE TABLE {drupal_install_test} (id int NOT NULL PRIMARY KEY)');
    $spec = [
      'fields' => [
        'id' => [
          'type' => 'int',
          'not null' => TRUE,
        ],
      ],
      'primary key' => ['id'],
    ];

    Database::getConnection('default')->schema()->createTable('drupal_install_test', $spec);
    parent::setUpSettings();

    // Ensure that the error message translation is working.
@@ -63,7 +73,7 @@ protected function setUpSettings() {
    // cSpell:enable

    // Now do it successfully.
    Database::getConnection('default')->query('DROP TABLE {drupal_install_test}');
    Database::getConnection('default')->schema()->dropTable('drupal_install_test');
    parent::setUpSettings();
  }

+4 −1
Changes for core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -41,7 +41,10 @@ public function testDatabaseLoaded() {
    // Ensure that all {router} entries can be unserialized. If they cannot be
    // unserialized a notice will be thrown by PHP.

    $result = \Drupal::database()->query("SELECT name, route from {router}")->fetchAllKeyed(0, 1);
    $result = \Drupal::database()->select('router', 'r')
      ->fields('r', ['name', 'route'])
      ->execute()
      ->fetchAllKeyed(0, 1);
    // For the purpose of fetching the notices and displaying more helpful error
    // messages, let's override the error handler temporarily.
    set_error_handler(function ($severity, $message, $filename, $lineno) {
+1 −1
Changes for core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -213,7 +213,7 @@ public function testScriptLoad() {
    }

    // Ensure the test config has been replaced.
    $config = unserialize($connection->query("SELECT data FROM {config} WHERE name = 'test_config'")->fetchField());
    $config = unserialize($connection->select('config', 'c')->fields('c', ['data'])->condition('name', 'test_config')->execute()->fetchField());
    $this->assertIdentical($config, $this->data, 'Script has properly restored the config table data.');

    // Ensure the cache data was not exported.
+1 −1
Changes for core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ protected function setUp(): void {
  }

  protected function read($name) {
    $data = Database::getConnection()->query('SELECT data FROM {config} WHERE name = :name', [':name' => $name])->fetchField();
    $data = Database::getConnection()->select('config', 'c')->fields('c', ['data'])->condition('name', $name)->execute()->fetchField();
    return unserialize($data);
  }

Loading