You are here

public function Redis_Tests_Admin_VariableTestCase::testSave in Redis 7.3

Same name and namespace in other branches
  1. 7.2 lib/Redis/Tests/Admin/VariableTestCase.test \Redis_Tests_Admin_VariableTestCase::testSave()

File

lib/Redis/Tests/Admin/VariableTestCase.test, line 21

Class

Redis_Tests_Admin_VariableTestCase

Code

public function testSave() {
  $this->adminUser = $this
    ->drupalCreateUser(array(
    'administer site configuration',
  ));
  $this
    ->drupalLogin($this->adminUser);

  // Tests port is an int.
  $this
    ->drupalGet('admin/config/development/performance/redis');
  $edit = array(
    'redis_client_base' => '',
    'redis_client_port' => '1234',
    'redis_client_host' => 'localhost',
    'redis_client_interface' => '',
  );
  $this
    ->drupalPost('admin/config/development/performance/redis', $edit, t('Save configuration'));

  // Force variable cache to refresh.
  $test = variable_initialize();
  $conf =& $GLOBALS['conf'];
  $this
    ->assertFalse(array_key_exists('redis_client_base', $conf), "Empty int value has been removed");
  $this
    ->assertFalse(array_key_exists('redis_client_interface', $conf), "Empty string value has been removed");
  $this
    ->assertIdentical($conf['redis_client_port'], 1234, "Saved int is an int");
  $this
    ->assertIdentical($conf['redis_client_host'], 'localhost', "Saved string is a string");
  $this
    ->drupalGet('admin/config/development/performance/redis');
  $edit = array(
    'redis_client_base' => '0',
    'redis_client_port' => '1234',
    'redis_client_host' => 'localhost',
    'redis_client_interface' => '',
  );
  $this
    ->drupalPost('admin/config/development/performance/redis', $edit, t('Save configuration'));

  // Force variable cache to refresh.
  $test = variable_initialize();
  $conf =& $GLOBALS['conf'];
  $this
    ->assertIdentical($conf['redis_client_base'], 0, "Saved 0 valueed int is an int");
}