class StorageReplaceDataWrapperTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php \Drupal\KernelTests\Core\Config\Storage\StorageReplaceDataWrapperTest
- 10 core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php \Drupal\KernelTests\Core\Config\Storage\StorageReplaceDataWrapperTest
Tests StorageReplaceDataWrapper operations.
@group config
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Config\Storage\ConfigStorageTestBase implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Config\Storage\StorageReplaceDataWrapperTest implements \Drupal\KernelTests\Core\Config\Storage\ConfigStorageTestBase
- class \Drupal\KernelTests\Core\Config\Storage\ConfigStorageTestBase implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of StorageReplaceDataWrapperTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ Storage/ StorageReplaceDataWrapperTest.php, line 13
Namespace
Drupal\KernelTests\Core\Config\StorageView source
class StorageReplaceDataWrapperTest extends ConfigStorageTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->storage = new StorageReplaceDataWrapper($this->container
->get('config.storage'));
// ::listAll() verifications require other configuration data to exist.
$this->storage
->write('system.performance', []);
$this->storage
->replaceData('system.performance', [
'foo' => 'bar',
]);
}
/**
* {@inheritdoc}
*/
protected function read($name) {
return $this->storage
->read($name);
}
/**
* {@inheritdoc}
*/
protected function insert($name, $data) {
$this->storage
->write($name, $data);
}
/**
* {@inheritdoc}
*/
protected function update($name, $data) {
$this->storage
->write($name, $data);
}
/**
* {@inheritdoc}
*/
protected function delete($name) {
$this->storage
->delete($name);
}
/**
* {@inheritdoc}
*/
public function testInvalidStorage() {
$this->markTestSkipped('No-op as this test does not make sense');
}
/**
* Tests if new collections created correctly.
*
* @param string $collection
* The collection name.
*
* @dataProvider providerCollections
*/
public function testCreateCollection($collection) {
$initial_collection_name = $this->storage
->getCollectionName();
// Create new storage with given collection and check it is set correctly.
$new_storage = $this->storage
->createCollection($collection);
$this->assertSame($collection, $new_storage->getCollectionName());
// Check collection not changed in the current storage instance.
$this->assertSame($initial_collection_name, $this->storage
->getCollectionName());
}
/**
* Data provider for testing different collections.
*
* @return array
* Returns an array of collection names.
*/
public function providerCollections() {
return [
[
StorageInterface::DEFAULT_COLLECTION,
],
[
'foo.bar',
],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.