function ConfigStorageTestBase::testInvalidStorage
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php \Drupal\KernelTests\Core\Config\Storage\ConfigStorageTestBase::testInvalidStorage()
- 8.9.x core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php \Drupal\KernelTests\Core\Config\Storage\ConfigStorageTestBase::testInvalidStorage()
- 10 core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php \Drupal\KernelTests\Core\Config\Storage\ConfigStorageTestBase::testInvalidStorage()
Tests an invalid storage.
4 methods override ConfigStorageTestBase::testInvalidStorage()
- CachedStorageTest::testInvalidStorage in core/
tests/ Drupal/ KernelTests/ Core/ Config/ Storage/ CachedStorageTest.php - Tests an invalid storage.
- ManagedStorageTest::testInvalidStorage in core/
tests/ Drupal/ KernelTests/ Core/ Config/ Storage/ ManagedStorageTest.php - Tests an invalid storage.
- MemoryStorageTest::testInvalidStorage in core/
tests/ Drupal/ KernelTests/ Core/ Config/ Storage/ MemoryStorageTest.php - Tests an invalid storage.
- StorageReplaceDataWrapperTest::testInvalidStorage in core/
tests/ Drupal/ KernelTests/ Core/ Config/ Storage/ StorageReplaceDataWrapperTest.php - Tests an invalid storage.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ Storage/ ConfigStorageTestBase.php, line 128
Class
- ConfigStorageTestBase
- Base class for testing storage operations.
Namespace
Drupal\KernelTests\Core\Config\StorageCode
public function testInvalidStorage() : void {
$name = 'config_test.storage';
// Write something to the valid storage to prove that the storages do not
// pollute one another.
$data = [
'foo' => 'bar',
];
$result = $this->storage
->write($name, $data);
$this->assertTrue($result);
$raw_data = $this->read($name);
$this->assertSame($data, $raw_data);
// Reading from a non-existing storage bin returns FALSE.
$result = $this->invalidStorage
->read($name);
$this->assertFalse($result);
// Deleting from a non-existing storage bin throws an exception.
try {
$this->invalidStorage
->delete($name);
$this->fail('Exception not thrown upon deleting from a non-existing storage bin.');
} catch (\Exception) {
// An exception occurred as expected; just continue.
}
// Listing on a non-existing storage bin returns an empty array.
$result = $this->invalidStorage
->listAll();
$this->assertSame([], $result);
// Getting all collections on a non-existing storage bin return an empty
// array.
$this->assertSame([], $this->invalidStorage
->getAllCollectionNames());
// Writing to a non-existing storage bin creates the bin.
$this->invalidStorage
->write($name, [
'foo' => 'bar',
]);
$result = $this->invalidStorage
->read($name);
$this->assertSame([
'foo' => 'bar',
], $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.