VariableTestCase.test 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. class Redis_Tests_Admin_VariableTestCase extends DrupalWebTestCase
  3. {
  4. public static function getInfo()
  5. {
  6. return array(
  7. 'name' => 'Redis variables',
  8. 'description' => 'Checks that Redis module variables are correctly type hinted when saved.',
  9. 'group' => 'Redis',
  10. );
  11. }
  12. protected $adminUser;
  13. public function setUp()
  14. {
  15. parent::setUp('redis');
  16. }
  17. public function testSave()
  18. {
  19. $this->adminUser = $this->drupalCreateUser(array('administer site configuration'));
  20. $this->drupalLogin($this->adminUser);
  21. // Tests port is an int.
  22. $this->drupalGet('admin/config/development/performance/redis');
  23. $edit = array(
  24. 'redis_client_base' => '',
  25. 'redis_client_port' => '1234',
  26. 'redis_client_host' => 'localhost',
  27. 'redis_client_interface' => '',
  28. );
  29. $this->drupalPost('admin/config/development/performance/redis', $edit, t('Save configuration'));
  30. // Force variable cache to refresh.
  31. $test = variable_initialize();
  32. $conf = &$GLOBALS['conf'];
  33. $this->assertFalse(array_key_exists('redis_client_base', $conf), "Empty int value has been removed");
  34. $this->assertFalse(array_key_exists('redis_client_interface', $conf), "Empty string value has been removed");
  35. $this->assertIdentical($conf['redis_client_port'], 1234, "Saved int is an int");
  36. $this->assertIdentical($conf['redis_client_host'], 'localhost', "Saved string is a string");
  37. $this->drupalGet('admin/config/development/performance/redis');
  38. $edit = array(
  39. 'redis_client_base' => '0',
  40. 'redis_client_port' => '1234',
  41. 'redis_client_host' => 'localhost',
  42. 'redis_client_interface' => '',
  43. );
  44. $this->drupalPost('admin/config/development/performance/redis', $edit, t('Save configuration'));
  45. // Force variable cache to refresh.
  46. $test = variable_initialize();
  47. $conf = &$GLOBALS['conf'];
  48. $this->assertIdentical($conf['redis_client_base'], 0, "Saved 0 valueed int is an int");
  49. }
  50. }