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. // dir gets created by --use-site-dir above,
  42. $options = $devel_options;
  43. $this->drush('pm-download', array('devel'), $options, NULL, $path_stage);
  44. $this->assertFileExists($path_stage . '/modules/devel/README.txt');
  45. // --destination with absolute path.
  46. $destination = UNISH_SANDBOX . '/test-destination1';
  47. mkdir($destination);
  48. $options = array(
  49. 'destination' => $destination,
  50. ) + $devel_options;
  51. $this->drush('pm-download', array('devel'), $options);
  52. $this->assertFileExists($destination . '/devel/README.txt');
  53. // --destination with a relative path.
  54. $destination = 'test-destination2';
  55. mkdir(UNISH_SANDBOX . '/' . $destination);
  56. $options = array(
  57. 'destination' => $destination,
  58. ) + $devel_options;
  59. $this->drush('pm-download', array('devel'), $options);
  60. $this->assertFileExists(UNISH_SANDBOX . '/' . $destination . '/devel/README.txt');
  61. }
  62. public function testSelect() {
  63. $options = array(
  64. 'select' => NULL,
  65. 'choice' => 0, // Cancel.
  66. );
  67. // --select. Specify 6.x since that has so many releases.
  68. $this->drush('pm-download', array('devel-6.x'), $options, NULL, NULL, CommandUnishTestCase::UNISH_EXITCODE_USER_ABORT);
  69. $items = $this->getOutputAsList();
  70. $output = $this->getOutput();
  71. // 4 items are: Select message + Cancel + 2 versions.
  72. $this->assertEquals(4, count($items), '--select offerred 2 options.');
  73. $this->assertContains('6.x-1.x-dev', $output, 'Dev release was shown by --select.');
  74. // --select --dev. Specify 6.x since that has so many releases.
  75. $this->drush('pm-download', array('devel-6.x'), $options + array('dev' => NULL), NULL, NULL, CommandUnishTestCase::UNISH_EXITCODE_USER_ABORT);
  76. $items = $this->getOutputAsList();
  77. $output = $this->getOutput();
  78. // 12 items are: Select message + Cancel + 1 option.
  79. $this->assertEquals(3, count($items), '--select --dev expected to offer only one option.');
  80. $this->assertContains('6.x-1.x-dev', $output, 'Assure that --dev lists the only dev release.');
  81. // --select --all. Specify 5.x since this is frozen.
  82. $this->drush('pm-download', array('devel-5.x'), $options + array('all' => NULL), NULL, NULL, CommandUnishTestCase::UNISH_EXITCODE_USER_ABORT);
  83. $items = $this->getOutputAsList();
  84. $output = $this->getOutput();
  85. // 12 items are: Select message + Cancel + 9 options.
  86. $this->assertEquals(11, count($items), '--select --all offerred 8 options.');
  87. $this->assertContains('5.x-0.1', $output, 'Assure that --all lists very old releases.');
  88. }
  89. public function testPackageHandler() {
  90. $options = array(
  91. 'cache' => NULL,
  92. 'package-handler' => 'git_drupalorg',
  93. 'yes' => NULL,
  94. );
  95. $this->drush('pm-download', array('devel'), $options);
  96. $this->assertFileExists(UNISH_SANDBOX . '/devel/README.txt');
  97. $this->assertFileExists(UNISH_SANDBOX . '/devel/.git');
  98. }
  99. }