Yaffs site version 1.1
[yaffs-website] / vendor / drush / drush / tests / generateMakeTest.php
1 <?php
2
3 namespace Unish;
4
5 /**
6  * Generate makefile tests
7  *
8  * @group make
9  * @group slow
10  */
11 class generateMakeCase extends CommandUnishTestCase {
12   function testGenerateMake() {
13     return $this->_testGenerateMake('devel', 'bootstrap');
14   }
15
16   function testGenerateMakeOmega() {
17     # TODO: Don't skip this test by default once the underlying issue is resolved.
18     # See: https://github.com/drush-ops/drush/issues/2030
19     $run_omega_make_test = getenv("DRUSH_TEST_MAKE_OMEGA");
20     if ($run_omega_make_test) {
21       return $this->_testGenerateMake('devel', 'omega');
22     }
23     else {
24       $this->markTestSkipped('Set `DRUSH_TEST_MAKE_OMEGA=1`, in order to run this test. See: https://github.com/drush-ops/drush/issues/2028');
25     }
26   }
27
28   function _testGenerateMake($module, $theme) {
29     $sites = $this->setUpDrupal(1, TRUE);
30     $major_version = UNISH_DRUPAL_MAJOR_VERSION . '.x';
31
32     $options = array(
33       'yes' => NULL,
34       'pipe' => NULL,
35       'root' => $this->webroot(),
36       'uri' => key($sites),
37       'cache' => NULL,
38       'strict' => 0, // Don't validate options
39     );
40     // Omega requires these core modules.
41     $this->drush('pm-enable', array('block', 'search', 'help'), $options);
42     $this->drush('pm-download', array($theme, $module), $options);
43     $this->drush('pm-enable', array($theme, $module), $options);
44
45     $makefile = UNISH_SANDBOX . '/dev.make.yml';
46
47     // First generate a simple makefile with no version information
48     $this->drush('generate-makefile', array($makefile), array('exclude-versions' => NULL) + $options);
49     $expected = <<<EOD
50 core: $major_version
51 api: 2
52 projects:
53   drupal: {  }
54   $module: {  }
55   $theme: {  }
56 EOD;
57     $actual = trim(file_get_contents($makefile));
58
59     $this->assertEquals($expected, $actual);
60
61     // Next generate a simple makefile with no version information in .ini format
62     $makefile = UNISH_SANDBOX . '/dev.make';
63     $this->drush('generate-makefile', array($makefile), array('exclude-versions' => NULL, 'format' => 'ini') + $options);
64     $expected = <<<EOD
65 ; This file was auto-generated by drush make
66 core = $major_version
67 api = 2
68
69 ; Core
70 projects[] = "drupal"
71 ; Modules
72 projects[] = "$module"
73 ; Themes
74 projects[] = "$theme"
75 EOD;
76     $actual = trim(file_get_contents($makefile));
77
78     $this->assertEquals($expected, $actual);
79
80     // Download a module to a 'contrib' directory to test the subdir feature
81     mkdir($this->webroot() + '/sites/all/modules/contrib');
82     $this->drush('pm-download', array('libraries'), array('destination' => 'sites/all/modules/contrib') + $options);
83     $this->drush('pm-enable', array('libraries'), $options);
84     $makefile = UNISH_SANDBOX . '/dev.make.yml';
85     $this->drush('generate-makefile', array($makefile), array('exclude-versions' => NULL) + $options);
86     $expected = <<<EOD
87 core: $major_version
88 api: 2
89 projects:
90   drupal: {  }
91   $module: {  }
92   libraries:
93     subdir: contrib
94   $theme: {  }
95 EOD;
96     $actual = trim(file_get_contents($makefile));
97
98     $this->assertEquals($expected, $actual);
99
100     // Again in .ini format.
101     $makefile = UNISH_SANDBOX . '/dev.make';
102     $this->drush('generate-makefile', array($makefile), array('exclude-versions' => NULL, 'format' => 'ini') + $options);
103     $expected = <<<EOD
104 ; This file was auto-generated by drush make
105 core = $major_version
106 api = 2
107
108 ; Core
109 projects[] = "drupal"
110 ; Modules
111 projects[] = "$module"
112 projects[libraries][subdir] = "contrib"
113
114 ; Themes
115 projects[] = "$theme"
116 EOD;
117     $actual = trim(file_get_contents($makefile));
118
119     $this->assertEquals($expected, $actual);
120
121     // Generate a makefile with version numbers (in .ini format).
122     $this->drush('generate-makefile', array($makefile), array('format' => 'ini') + $options);
123     $actual = file_get_contents($makefile);
124     $this->assertContains('projects[' . $module . '][version] = "', $actual);
125   }
126 }