function VariableCase::testVariable

8.0.x variableTest.php VariableCase::testVariable()
6.x variableTest.php VariableCase::testVariable()
7.x variableTest.php VariableCase::testVariable()
4.x variableTest.php VariableCase::testVariable()
5.x variableTest.php VariableCase::testVariable()
master variableTest.php VariableCase::testVariable()

File

tests/variableTest.php, line 9

Class

VariableCase

Code

function testVariable() {
  $env = 'dev';
  $this->setUpDrupal($env, TRUE);
  $options = array(
    'yes' => NULL,
    'pipe' => NULL,
    'root' => $this->sites[$env]['root'],
    'uri' => $env,
  );

  $this->drush('variable-set', array('date_default_timezone', 'US/Mountain'), $options);
  $this->drush('variable-get', array('date_default_timezone'), $options); // Wildcard get.
  $var_export = $this->getOutput();
  eval($var_export);
  $this->assertEquals('US/Mountain', $variables['date_default_timezone'], 'Variable was successfully set and get.');

  $this->drush('variable-set', array('site_name', 'unish'), $options + array('always-set' => NULL));
  $this->drush('variable-get', array('site_name'), $options);
  $var_export = $this->getOutput();
  eval($var_export);
  $this->assertEquals('unish', $variables['site_name'], '--always-set option works as expected.');

  $this->drush('variable-delete', array('site_name'), $options);
  $output = $this->getOutput();
  $this->assertEmpty($output, 'Variable was successfully deleted.');
}