variableTest.php

  1. 8.0.x tests/variableTest.php
  2. 6.x tests/variableTest.php
  3. 7.x tests/variableTest.php
  4. 4.x tests/variableTest.php
  5. 5.x tests/variableTest.php
  6. master tests/variableTest.php

Namespace

Unish

Classes

Namesort descending Description
VariableCase @group commands

File

tests/variableTest.php
View source
  1. <?php
  2. namespace Unish;
  3. /**
  4. * @group commands
  5. */
  6. class VariableCase extends CommandUnishTestCase {
  7. function testVariable() {
  8. if (UNISH_DRUPAL_MAJOR_VERSION >= 8) {
  9. $this->markTestSkipped("Variable system was removed in Drupal 8.");
  10. }
  11. $sites = $this->setUpDrupal(1, TRUE);
  12. $options_without_pipe = array(
  13. 'yes' => NULL,
  14. 'root' => $this->webroot(),
  15. 'uri' => key($sites),
  16. );
  17. $options = $options_without_pipe + array(
  18. 'pipe' => NULL,
  19. );
  20. $this->drush('variable-set', array('test_integer', '3.14159'), $options);
  21. $this->drush('variable-get', array('test_integer'), $options);
  22. $var_export = $this->getOutput();
  23. eval($var_export);
  24. $this->assertEquals("3.14159", $variables['test_integer'], 'Integer variable was successfully set and get.');
  25. $this->drush('variable-set', array('date_default_timezone', 'US/Mountain'), $options);
  26. $this->drush('variable-get', array('date_default_timezone'), $options); // Wildcard get.
  27. $var_export = $this->getOutput();
  28. eval($var_export);
  29. $this->assertEquals('US/Mountain', $variables['date_default_timezone'], 'Variable was successfully set and get.');
  30. $this->drush('variable-set', array('site_name', 'control'), $options + array('exact' => NULL));
  31. $this->drush('variable-set', array('site_na', 'unish'), $options + array('always-set' => NULL));
  32. $this->drush('variable-get', array('site_na'), $options + array('exact' => NULL));
  33. $var_export = $this->getOutput();
  34. eval($var_export);
  35. $this->assertEquals('unish', $variables['site_na'], '--always-set option works as expected.');
  36. $this->drush('variable-set', array('site_n', 'exactish'), $options + array('exact' => NULL));
  37. $this->drush('variable-get', array('site_n'), $options + array('exact' => NULL));
  38. $var_export = $this->getOutput();
  39. eval($var_export);
  40. $this->assertEquals('exactish', $variables['site_n'], '--exact option works as expected.');
  41. $this->drush('variable-get', array('site_n'), $options_without_pipe + array('exact' => NULL));
  42. $site_n_value = $this->getOutput();
  43. $this->assertEquals('exactish', $site_n_value, '--exact option works as expected with --pipe.');
  44. $this->drush('variable-delete', array('site_name'), $options);
  45. $output = $this->getOutput();
  46. $this->assertEmpty($output, 'Variable was successfully deleted.');
  47. }
  48. }