DatabaseStorageTest.php
Same filename in this branch
Same filename in other branches
- 9 core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
- 9 core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php
- 10 core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
- 10 core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php
- 11.x core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
- 11.x core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php
Namespace
Drupal\KernelTests\Core\Config\StorageFile
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ Storage/ DatabaseStorageTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Config\Storage;
use Drupal\Core\Config\DatabaseStorage;
use Drupal\Core\Database\Database;
/**
* Tests DatabaseStorage operations.
*
* @group config
*/
class DatabaseStorageTest extends ConfigStorageTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
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()->query('SELECT data FROM {config} WHERE name = :name', [
':name' => $name,
])
->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();
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
DatabaseStorageTest | Tests DatabaseStorage operations. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.