8 class VariableCase extends CommandUnishTestCase {
10 function testVariable() {
11 if (UNISH_DRUPAL_MAJOR_VERSION >= 8) {
12 $this->markTestSkipped("Variable system was removed in Drupal 8.");
15 $sites = $this->setUpDrupal(1, TRUE);
16 $options_without_pipe = array(
18 'root' => $this->webroot(),
21 $options = $options_without_pipe + array(
25 $this->drush('variable-set', array('test_integer', '3.14159'), $options);
26 $this->drush('variable-get', array('test_integer'), $options);
27 $var_export = $this->getOutput();
29 $this->assertEquals("3.14159", $variables['test_integer'], 'Integer variable was successfully set and get.');
31 $this->drush('variable-set', array('date_default_timezone', 'US/Mountain'), $options);
32 $this->drush('variable-get', array('date_default_timezone'), $options); // Wildcard get.
33 $var_export = $this->getOutput();
35 $this->assertEquals('US/Mountain', $variables['date_default_timezone'], 'Variable was successfully set and get.');
37 $this->drush('variable-set', array('site_name', 'control'), $options + array('exact' => NULL));
38 $this->drush('variable-set', array('site_na', 'unish'), $options + array('always-set' => NULL));
39 $this->drush('variable-get', array('site_na'), $options + array('exact' => NULL));
40 $var_export = $this->getOutput();
42 $this->assertEquals('unish', $variables['site_na'], '--always-set option works as expected.');
44 $this->drush('variable-set', array('site_n', 'exactish'), $options + array('exact' => NULL));
45 $this->drush('variable-get', array('site_n'), $options + array('exact' => NULL));
46 $var_export = $this->getOutput();
48 $this->assertEquals('exactish', $variables['site_n'], '--exact option works as expected.');
50 $this->drush('variable-get', array('site_n'), $options_without_pipe + array('exact' => NULL));
51 $site_n_value = $this->getOutput();
52 $this->assertEquals('exactish', $site_n_value, '--exact option works as expected with --pipe.');
54 $this->drush('variable-delete', array('site_name'), $options);
55 $output = $this->getOutput();
56 $this->assertEmpty($output, 'Variable was successfully deleted.');