generateMakeTest.php

  1. 8.0.x tests/generateMakeTest.php
  2. 6.x tests/generateMakeTest.php
  3. 7.x tests/generateMakeTest.php
  4. 5.x tests/generateMakeTest.php
  5. master tests/generateMakeTest.php

Namespace

Unish

Classes

Namesort descending Description
generateMakeCase Generate makefile tests

File

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