74eb64eb7c68df83898cab85c2ae0055af2453c8
[yaffs-website] / vendor / drush / drush / tests / variableTest.php
1 <?php
2
3 namespace Unish;
4
5 /**
6  * @group commands
7  */
8 class VariableCase extends CommandUnishTestCase {
9
10   function testVariable() {
11     if (UNISH_DRUPAL_MAJOR_VERSION >= 8) {
12       $this->markTestSkipped("Variable system was removed in Drupal 8.");
13     }
14
15     $sites = $this->setUpDrupal(1, TRUE);
16     $options_without_pipe = array(
17       'yes' => NULL,
18       'root' => $this->webroot(),
19       'uri' => key($sites),
20     );
21     $options = $options_without_pipe + array(
22       'pipe' => NULL,
23     );
24
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();
28     eval($var_export);
29     $this->assertEquals("3.14159", $variables['test_integer'], 'Integer variable was successfully set and get.');
30
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();
34     eval($var_export);
35     $this->assertEquals('US/Mountain', $variables['date_default_timezone'], 'Variable was successfully set and get.');
36
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();
41     eval($var_export);
42     $this->assertEquals('unish', $variables['site_na'], '--always-set option works as expected.');
43
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();
47     eval($var_export);
48     $this->assertEquals('exactish', $variables['site_n'], '--exact option works as expected.');
49
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.');
53
54     $this->drush('variable-delete', array('site_name'), $options);
55     $output = $this->getOutput();
56     $this->assertEmpty($output, 'Variable was successfully deleted.');
57   }
58 }