Yaffs site version 1.1
[yaffs-website] / vendor / drush / drush / tests / siteIntallD6Test.php
1 <?php
2
3 namespace Unish;
4
5 /**
6  * Tests for site-install on a Drupal 6 installation.
7  *
8  * @group commands
9  */
10 class siteInstallD6Case extends CommandUnishTestCase {
11
12   function setUp() {
13     if (UNISH_DRUPAL_MAJOR_VERSION != 6) {
14       $this->markTestSkipped('This test class is designed for Drupal 6.');
15       return;
16     }
17   }
18
19   /**
20    * Test a D6 install with extra options.
21    */
22   public function testExtraConfigurationOptions() {
23     // Set up codebase without installing Drupal.
24     $sites = $this->setUpDrupal(1, FALSE, '6');
25     $root = $this->webroot();
26     $site = key($sites);
27
28     // Copy the "example" test profile into the newly created site's profiles directory
29     $profile_dir = "$root/profiles/example";
30     mkdir($profile_dir);
31     copy(dirname(__FILE__) . '/resources/example.profile', $profile_dir . '/example.profile');
32
33     $test_string = $this->randomString();
34     // example.profile Has values 0-2 defined as allowed.
35     $test_int = rand(0, 2);
36     $site_name = $this->randomString();
37
38     $this->drush('site-install', array(
39         // First argument is the profile name
40         'example',
41         // Then the extra profile options
42         "myopt1=$test_string",
43         "myopt2=$test_int",
44       ),
45       array(
46         'db-url' => $this->db_url($site),
47         'yes' => NULL,
48         'sites-subdir' => $site,
49         'root' => $root,
50         'site-name' => $site_name,
51         'uri' => $site,
52     ));
53
54     $this->checkVariable('site_name', $site_name, $site);
55     $this->checkVariable('myopt1', $test_string, $site);
56     $this->checkVariable('myopt2', $test_int, $site);
57   }
58
59   /**
60    * Check the value of a Drupal variable against an expectation using drush.
61    *
62    * @param $name
63    *   The variable name.
64    * @param $value
65    *   The expected value of this variable.
66    * @param $site
67    *   The name of an individual multisite installation site.
68    */
69   private function checkVariable($name, $value, $site) {
70     $options = array(
71       'root' => $this->webroot(),
72       'uri' => $site,
73     );
74
75     $this->drush('variable-get', array($name), $options);
76     $this->assertEquals("$name: $value", $this->getOutput());
77   }
78 }