public function AuthcacheP13nTestDatabaseKeyValueStore::testGetKeys in Authenticated User Page Caching (Authcache) 7.2
Cover AuthcacheP13nDatabaseKeyValueStore::getKeys().
File
- modules/
authcache_p13n/ tests/ authcache_p13n.db-kv-store.test, line 271 - Test case for database key-value store.
Class
- AuthcacheP13nTestDatabaseKeyValueStore
- Test database key-value store.
Code
public function testGetKeys() {
$this
->dbInsertSampleData();
$expect_store1 = array(
'k1',
'k2',
'k3',
);
$expect_store2 = array(
'k1',
);
// Get all.
$result = $this->store1
->getKeys();
$this
->assertEqual($expect_store1, $result, 'Get all keys from store1');
$result = $this->store2
->getKeys();
$this
->assertEqual($expect_store2, $result, 'Get all keys from store2');
// Get existing.
$result = $this->store1
->getKeys(array(
'k1',
'k2',
));
$this
->assertEqual(array(
'k1',
'k2',
), $result, 'Get existing keys from store1');
$result = $this->store2
->getKeys(array(
'k1',
'k2',
));
$this
->assertEqual(array(
'k1',
), $result, 'Get existing keys from store2');
$result = $this->store2Again
->getKeys(array(
'k1',
'k2',
));
$this
->assertEqual(array(
'k1',
), $result, 'Get existing keys from store2 alias');
// Get missing.
$result = $this->store1
->getKeys(array(
'k1',
'k2',
'missing-key',
));
$this
->assertEqual(array(
'k1',
'k2',
), $result, 'Get missing keys from store1');
$result = $this->store2
->getKeys(array(
'missing-key',
'k1',
));
$this
->assertEqual(array(
'k1',
), $result, 'Get missing keys from store2');
$result = $this->store2Again
->getKeys(array(
'missing-key',
));
$this
->assertEqual(array(), $result, 'Get missing keys from store2 alias');
// Remove test data.
db_delete('authcache_p13n_key_value')
->execute();
}