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

Namespace

Unish

Classes

Namesort descending Description
pmDownloadCase @group pm

File

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