4 use Webmozart\PathUtil\Path;
7 * Generate makefile tests
12 class generateMakeCase extends CommandUnishTestCase {
13 function testGenerateMake() {
14 return $this->_testGenerateMake('devel', 'bootstrap');
17 function testGenerateMakeOmega() {
18 # TODO: Don't skip this test by default once the underlying issue is resolved.
19 # See: https://github.com/drush-ops/drush/issues/2030
20 $run_omega_make_test = getenv("DRUSH_TEST_MAKE_OMEGA");
21 if ($run_omega_make_test) {
22 return $this->_testGenerateMake('devel', 'omega');
25 $this->markTestSkipped('Set `DRUSH_TEST_MAKE_OMEGA=1`, in order to run this test. See: https://github.com/drush-ops/drush/issues/2028');
29 function _testGenerateMake($module, $theme) {
30 $sites = $this->setUpDrupal(1, TRUE);
31 $major_version = UNISH_DRUPAL_MAJOR_VERSION . '.x';
36 'root' => $this->webroot(),
39 'strict' => 0, // Don't validate options
41 // Omega requires these core modules.
42 $this->drush('pm-enable', array('block', 'search', 'help'), $options);
43 $this->drush('pm-download', array($theme, $module), $options);
44 $this->drush('pm-enable', array($theme, $module), $options);
46 $makefile = UNISH_SANDBOX . '/dev.make.yml';
48 // First generate a simple makefile with no version information
49 $this->drush('generate-makefile', array($makefile), array('exclude-versions' => NULL) + $options);
58 $actual = trim(file_get_contents($makefile));
60 $this->assertEquals($expected, $actual);
62 // Next generate a simple makefile with no version information in .ini format
63 $makefile = UNISH_SANDBOX . '/dev.make';
64 $this->drush('generate-makefile', array($makefile), array('exclude-versions' => NULL, 'format' => 'ini') + $options);
66 ; This file was auto-generated by drush make
73 projects[] = "$module"
77 $actual = trim(file_get_contents($makefile));
79 $this->assertEquals($expected, $actual);
81 // Download a module to a 'contrib' directory to test the subdir feature
82 $this->mkdir(Path::join($this->webroot(). '/sites/all/modules/contrib'));
83 $this->drush('pm-download', array('libraries'), array('destination' => 'sites/all/modules/contrib') + $options);
84 $this->drush('pm-enable', array('libraries'), $options);
85 $makefile = UNISH_SANDBOX . '/dev.make.yml';
86 $this->drush('generate-makefile', array($makefile), array('exclude-versions' => NULL) + $options);
97 $actual = trim(file_get_contents($makefile));
99 $this->assertEquals($expected, $actual);
101 // Again in .ini format.
102 $makefile = UNISH_SANDBOX . '/dev.make';
103 $this->drush('generate-makefile', array($makefile), array('exclude-versions' => NULL, 'format' => 'ini') + $options);
105 ; This file was auto-generated by drush make
106 core = $major_version
110 projects[] = "drupal"
112 projects[] = "$module"
113 projects[libraries][subdir] = "contrib"
116 projects[] = "$theme"
118 $actual = trim(file_get_contents($makefile));
120 $this->assertEquals($expected, $actual);
122 // Generate a makefile with version numbers (in .ini format).
123 $this->drush('generate-makefile', array($makefile), array('format' => 'ini') + $options);
124 $actual = file_get_contents($makefile);
125 $this->assertContains('projects[' . $module . '][version] = "', $actual);