public function AuthcacheP13nTestDatabaseKeyValueStore::testGet in Authenticated User Page Caching (Authcache) 7.2
Cover AuthcacheP13nDatabaseKeyValueStore::get().
File
- modules/
authcache_p13n/ tests/ authcache_p13n.db-kv-store.test, line 165 - Test case for database key-value store.
Class
- AuthcacheP13nTestDatabaseKeyValueStore
- Test database key-value store.
Code
public function testGet() {
$this
->dbInsertSampleData();
$expect_store1 = array(
'k1' => 'v1',
'k2' => array(
'some',
'stuff',
),
'k3' => (object) array(
'a' => 1,
'b' => 2,
),
);
$expect_store2 = array(
'k1' => 'same key, other store',
);
// Get all.
$result = $this->store1
->get();
$this
->assertEqual($expect_store1, $result, 'Get all from store1');
$result = $this->store2
->get();
$this
->assertEqual($expect_store2, $result, 'Get all from store2');
// Get existing.
$result = $this->store1
->get(array(
'k1',
'k2',
));
$this
->assertEqual(array(
'k1' => 'v1',
'k2' => array(
'some',
'stuff',
),
), $result, 'Get existing values from store1');
$result = $this->store2
->get(array(
'k1',
'k2',
));
$this
->assertEqual(array(
'k1' => 'same key, other store',
), $result, 'Get existing values from store2');
$result = $this->store2Again
->get(array(
'k1',
'k2',
));
$this
->assertEqual(array(
'k1' => 'same key, other store',
), $result, 'Get existing values from store2 alias');
// Get missing.
$result = $this->store1
->get(array(
'k1',
'k2',
'missing-key',
));
$this
->assertEqual(array(
'k1' => 'v1',
'k2' => array(
'some',
'stuff',
),
), $result, 'Get missing values from store1');
$result = $this->store2
->get(array(
'missing-key',
'k1',
));
$this
->assertEqual(array(
'k1' => 'same key, other store',
), $result, 'Get missing values from store2');
$result = $this->store2Again
->get(array(
'missing-key',
));
$this
->assertEqual(array(), $result, 'Get missing values from store2 alias');
// Remove test data.
db_delete('authcache_p13n_key_value')
->execute();
}