PageRenderTime 23ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/sites/all/modules/drush/tests/pmDownloadTest.php

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