public function ConfigStorageTestBase::testInvalidStorage in Drupal 8
Same name and namespace in other branches
- 9 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 119
Class
- ConfigStorageTestBase
- Base class for testing storage operations.
Namespace
Drupal\KernelTests\Core\Config\StorageCode
public function testInvalidStorage() {
$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
->assertIdentical($result, TRUE);
$raw_data = $this
->read($name);
$this
->assertIdentical($raw_data, $data);
// Reading from a non-existing storage bin returns FALSE.
$result = $this->invalidStorage
->read($name);
$this
->assertIdentical($result, FALSE);
// 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 $e) {
// An exception occurred as expected; just continue.
}
// Listing on a non-existing storage bin returns an empty array.
$result = $this->invalidStorage
->listAll();
$this
->assertIdentical($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
->assertIdentical($result, [
'foo' => 'bar',
]);
}