You are here

public function AuthcacheP13nTestDatabaseKeyValueStore::testGetOne in Authenticated User Page Caching (Authcache) 7.2

Cover AuthcacheP13nDatabaseKeyValueStore::getOne().

File

modules/authcache_p13n/tests/authcache_p13n.db-kv-store.test, line 240
Test case for database key-value store.

Class

AuthcacheP13nTestDatabaseKeyValueStore
Test database key-value store.

Code

public function testGetOne() {
  $this
    ->dbInsertSampleData();
  $result = $this->store1
    ->getOne('k1');
  $this
    ->assertEqual('v1', $result);
  $result = $this->store1
    ->getOne('k2');
  $this
    ->assertEqual(array(
    'some',
    'stuff',
  ), $result);
  $result = $this->store1
    ->getOne('k3');
  $this
    ->assertEqual((object) array(
    'a' => 1,
    'b' => 2,
  ), $result);
  $result = $this->store1
    ->getOne('missing-key');
  $this
    ->assertNull($result);
  $result = $this->store2
    ->getOne('k1');
  $this
    ->assertEqual('same key, other store', $result);
  $result = $this->store2Again
    ->getOne('k1');
  $this
    ->assertEqual('same key, other store', $result);
  $result = $this->store2
    ->getOne('missing-key');
  $this
    ->assertNull($result);

  // Remove test data.
  db_delete('authcache_p13n_key_value')
    ->execute();
}