DatabaseStorageTest.php in Drupal 9
File
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;
class DatabaseStorageTest extends ConfigStorageTestBase {
protected function setUp() : void {
parent::setUp();
$this->storage = new DatabaseStorage($this->container
->get('database'), 'config');
$this->invalidStorage = new DatabaseStorage($this->container
->get('database'), 'invalid');
$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();
}
}