public function StorageTestBase::_testNonExistingKeys in Service Container 7.2
Same name and namespace in other branches
- 7 lib/Drupal/service_container/Tests/KeyValue/StorageTestBase.php \Drupal\service_container\Tests\KeyValue\StorageTestBase::_testNonExistingKeys()
Tests expected behavior for non-existing keys.
1 call to StorageTestBase::_testNonExistingKeys()
- StorageTestBase::testKeyValueStore in lib/
Drupal/ service_container/ Tests/ KeyValue/ StorageTestBase.php
File
- lib/
Drupal/ service_container/ Tests/ KeyValue/ StorageTestBase.php, line 196 - Contains Drupal\service_container\Tests\KeyValue\StorageTestBase.
Class
- StorageTestBase
- Base class for testing key-value storages.
Namespace
Drupal\service_container\Tests\KeyValueCode
public function _testNonExistingKeys() {
$stores = $this
->createStorage();
// Verify that a non-existing key returns NULL as value.
$this
->assertNull($stores[0]
->get('foo'));
// Verify that a non-existing key with a default returns the default.
$this
->assertIdentical($stores[0]
->get('foo', 'bar'), 'bar');
// Verify that a FALSE value can be stored.
$stores[0]
->set('foo', FALSE);
$this
->assertIdentical($stores[0]
->get('foo'), FALSE);
// Verify that a deleted key returns NULL as value.
$stores[0]
->delete('foo');
$this
->assertNull($stores[0]
->get('foo'));
// Verify that a non-existing key is not returned when getting multiple keys.
$stores[0]
->set('bar', 'baz');
$values = $stores[0]
->getMultiple(array(
'foo',
'bar',
));
$this
->assertFalse(isset($values['foo']), "Key 'foo' not found.");
$this
->assertIdentical($values['bar'], 'baz');
}