You are here

class DatabaseStorageTest in Drupal 10

Same name in this branch
  1. 10 core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php \Drupal\KernelTests\Core\KeyValueStore\DatabaseStorageTest
  2. 10 core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php \Drupal\KernelTests\Core\Config\Storage\DatabaseStorageTest
Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php \Drupal\KernelTests\Core\Config\Storage\DatabaseStorageTest
  2. 9 core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php \Drupal\KernelTests\Core\Config\Storage\DatabaseStorageTest

Tests DatabaseStorage operations.

@group config

Hierarchy

  • class \Drupal\KernelTests\Core\Config\Storage\DatabaseStorageTest extends \Drupal\KernelTests\Core\Config\Storage\ConfigStorageTestBase

Expanded class hierarchy of DatabaseStorageTest

File

core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php, line 13

Namespace

Drupal\KernelTests\Core\Config\Storage
View source
class DatabaseStorageTest extends ConfigStorageTestBase {

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->storage = new DatabaseStorage($this->container
      ->get('database'), 'config');
    $this->invalidStorage = new DatabaseStorage($this->container
      ->get('database'), 'invalid');

    // ::listAll() verifications require other configuration data to exist.
    $this->storage
      ->write('system.performance', []);
  }
  protected function read($name) {
    $data = Database::getConnection()
      ->select('config', 'c')
      ->fields('c', [
      'data',
    ])
      ->condition('name', $name)
      ->execute()
      ->fetchField();
    return unserialize($data);
  }
  protected function insert($name, $data) {
    Database::getConnection()
      ->insert('config')
      ->fields([
      'name' => $name,
      'data' => $data,
    ])
      ->execute();
  }
  protected function update($name, $data) {
    Database::getConnection()
      ->update('config')
      ->fields([
      'data' => $data,
    ])
      ->condition('name', $name)
      ->execute();
  }
  protected function delete($name) {
    Database::getConnection()
      ->delete('config')
      ->condition('name', $name)
      ->execute();
  }

}

Members