pmDownloadTest.php

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

Classes

Namesort ascending Description
pmDownloadCase pm-download testing

File

tests/pmDownloadTest.php
View source
  1. <?php
  2. /**
  3. * pm-download testing
  4. *
  5. * @group pm
  6. */
  7. class pmDownloadCase extends Drush_CommandTestCase {
  8. public function testPmDownload() {
  9. $this->drush('pm-download', array('devel'), array('cache' => NULL, 'skip' => NULL)); // No FirePHP
  10. $this->assertFileExists(UNISH_SANDBOX . '/devel/README.txt');
  11. }
  12. // @todo Test pure drush commandfile projects. They get special destination.
  13. public function testDestination() {
  14. // Setup two Drupal sites. Skip install for speed.
  15. $sites = $this->setUpDrupal(2, FALSE);
  16. $uri = key($sites);
  17. $root = $this->webroot();
  18. // Common options for the invocations below.
  19. $devel_options = array(
  20. 'cache' => NULL,
  21. 'skip' => NULL, // No FirePHP
  22. 'invoke' => NULL, // Invoke from script: do not verify options
  23. );
  24. // Default to sites/all.
  25. $options = array(
  26. 'root' => $root,
  27. 'uri' => $uri,
  28. ) + $devel_options;
  29. $this->drush('pm-download', array('devel'), $options);
  30. $this->assertFileExists($root . '/sites/all/modules/devel/README.txt');
  31. // --use-site-dir
  32. // Expand above $options.
  33. $options += array('use-site-dir' => NULL);
  34. $this->drush('pm-download', array('devel'), $options);
  35. $this->assertFileExists("$root/sites/$uri/modules/devel/README.txt");
  36. unish_file_delete_recursive("$root/sites/$uri/modules/devel");
  37. // If we are in site specific dir, then download belongs there.
  38. $path_stage = "$root/sites/$uri";
  39. // gets created by --use-site-dir above,
  40. // mkdir("$path_stage/modules");
  41. $options = $devel_options;
  42. $this->drush('pm-download', array('devel'), $options, NULL, $path_stage);
  43. $this->assertFileExists($path_stage . '/modules/devel/README.txt');
  44. // --destination with absolute path.
  45. $destination = UNISH_SANDBOX . '/test-destination1';
  46. mkdir($destination);
  47. $options = array(
  48. 'destination' => $destination,
  49. ) + $devel_options;
  50. $this->drush('pm-download', array('devel'), $options);
  51. $this->assertFileExists($destination . '/devel/README.txt');
  52. // --destination with a relative path.
  53. $destination = 'test-destination2';
  54. mkdir(UNISH_SANDBOX . '/' . $destination);
  55. $options = array(
  56. 'destination' => $destination,
  57. ) + $devel_options;
  58. $this->drush('pm-download', array('devel'), $options);
  59. $this->assertFileExists(UNISH_SANDBOX . '/' . $destination . '/devel/README.txt');
  60. }
  61. public function testSelect() {
  62. $options = array(
  63. 'cache' => NULL,
  64. 'no' => NULL,
  65. 'select' => NULL,
  66. );
  67. // --select. Specify 6.x since that has so many releases.
  68. $this->drush('pm-download', array('devel-6.x'), $options);
  69. $items = $this->getOutputAsList();
  70. $output = $this->getOutput();
  71. // The maximums below are higher then they usually appear since --verbose can add one.
  72. $this->assertLessThanOrEqual(8, count($items), '--select offerred no more than 3 options.');
  73. $this->assertContains('dev', $output, 'Dev release was shown by --select.');
  74. // --select --all. Specify 6.x since that has so many releases.
  75. $this->drush('pm-download', array('devel-6.x'), $options + array('all' => NULL));
  76. $items = $this->getOutputAsList();
  77. $output = $this->getOutput();
  78. $this->assertGreaterThanOrEqual(20, count($items), '--select --all offerred at least 16 options.');
  79. $this->assertContains('6.x-1.5', $output, 'Assure that --all lists very old releases.');
  80. // --select --dev. Specify 6.x since that has so many releases.
  81. $this->drush('pm-download', array('devel-6.x'), $options + array('dev' => NULL));
  82. $items = $this->getOutputAsList();
  83. $output = $this->getOutput();
  84. $this->assertLessThanOrEqual(6, count($items), '--select --dev expected to offer only one option.');
  85. $this->assertContains('6.x-1.x-dev', $output, 'Assure that --dev lists the only dev release.');
  86. }
  87. public function testPackageHandler() {
  88. $options = array(
  89. 'cache' => NULL,
  90. 'package-handler' => 'git_drupalorg',
  91. 'yes' => NULL,
  92. );
  93. $this->drush('pm-download', array('devel'), $options);
  94. $this->assertFileExists(UNISH_SANDBOX . '/devel/README.txt');
  95. $this->assertFileExists(UNISH_SANDBOX . '/devel/.git');
  96. }
  97. }