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