You are here

public function RestfulVariableTestCase::testRenderCache in RESTful 7

Same name and namespace in other branches
  1. 7.2 tests/RestfulVariableTestCase.test \RestfulVariableTestCase::testRenderCache()

Test the render cache.

File

tests/RestfulVariableTestCase.test, line 135
Contains RestfulVariableTestCase.

Class

RestfulVariableTestCase
@file Contains RestfulVariableTestCase.

Code

public function testRenderCache() {

  // Create a test variable.
  $handler = restful_get_restful_handler('variables');
  $request = array(
    'variable_name' => 'test_variable_cache',
    'variable_value' => TRUE,
  );
  $handler
    ->post('', $request);
  $created = variable_get('test_variable_cache');
  $this
    ->assertNotNull($created, 'The cache variable has been created.');

  // Populate the cache entries.
  $account = $this
    ->drupalCreateUser();
  $handler
    ->setAccount($account);
  $handler
    ->get('test_variable_cache');

  // Get the cache value.
  $cache = $handler
    ->getCacheController();
  $version = $handler
    ->getVersion();
  $cid = 'v' . $version['major'] . '.' . $version['minor'] . '::variables::uu' . $account->uid . '::patb:variable::id:' . 'test_variable_cache';
  $cache_data = $cache
    ->get($cid);
  $this
    ->assertNotNull($cache_data->data, 'Cache data is present.');
  $this
    ->assertEqual($cache_data->data['variable_name'], 'test_variable_cache', 'The variable name was retrieved from the cache.');
  $this
    ->assertEqual($cache_data->data['variable_value'], TRUE, 'The variable value was retrieved from the cache.');
}