public function ConfigStorageTestBase::testInvalidStorage in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/config/src/Tests/Storage/ConfigStorageTestBase.php \Drupal\config\Tests\Storage\ConfigStorageTestBase::testInvalidStorage()
Tests an invalid storage.
1 method overrides ConfigStorageTestBase::testInvalidStorage()
- CachedStorageTest::testInvalidStorage in core/
modules/ config/ src/ Tests/ Storage/ CachedStorageTest.php - Tests an invalid storage.
File
- core/
modules/ config/ src/ Tests/ Storage/ ConfigStorageTestBase.php, line 130 - Contains \Drupal\config\Tests\Storage\ConfigStorageTestBase.
Class
- ConfigStorageTestBase
- Base class for testing storage operations.
Namespace
Drupal\config\Tests\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 = array(
'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) {
$class = get_class($e);
$this
->pass($class . ' thrown upon deleting from a non-existing storage bin.');
}
// Listing on a non-existing storage bin returns an empty array.
$result = $this->invalidStorage
->listAll();
$this
->assertIdentical($result, array());
// Writing to a non-existing storage bin creates the bin.
$this->invalidStorage
->write($name, array(
'foo' => 'bar',
));
$result = $this->invalidStorage
->read($name);
$this
->assertIdentical($result, array(
'foo' => 'bar',
));
}