class pmDownloadCase

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

pm-download testing

@group pm

Hierarchy

Expanded class hierarchy of pmDownloadCase

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
Drush_CommandTestCase::drush function Invoke drush in via execute().
Drush_CommandTestCase::drush_major_version function
Drush_CommandTestCase::execute function Actually runs the command. Does not trap the error stream output as this need PHP 4.3+.
Drush_CommandTestCase::EXIT_ERROR constant
Drush_CommandTestCase::EXIT_SUCCESS constant
Drush_CommandTestCase::file_aliases function
Drush_TestCase::bit_bucket function Borrowed from Drush. Checks operating system and returns supported bit bucket folder.
Drush_TestCase::convert_path function Converts a Windows path (dir1\dir2\dir3) into a Unix path (dir1/dir2/dir3). Also converts a cygwin "drive emulation" path (/cygdrive/c/dir1) into a proper drive path, still with Unix slashes (c:/dir1).
Drush_TestCase::db_url function
Drush_TestCase::directory_cache function
Drush_TestCase::escapeshellarg public static function
Drush_TestCase::fetchInstallDrupal function
Drush_TestCase::getOutput function Accessor for the last output.
Drush_TestCase::getOutputAsList function Accessor for the last output.
Drush_TestCase::get_tar_executable public static function
Drush_TestCase::is_windows public static function
Drush_TestCase::log function Print a log message to the console.
Drush_TestCase::log_level function
Drush_TestCase::randomString public function Helper function to generate a random string of arbitrary length.
Drush_TestCase::setUpBeforeClass public static function Assure that each class starts with an empty sandbox directory and a clean environment - http://drupal.org/node/1103568.
Drush_TestCase::setUpDrupal function
Drush_TestCase::setUpFreshSandBox public static function Remove any pre-existing sandbox, then create a new one.
Drush_TestCase::tearDownAfterClass public static function Runs after all tests in a class are run. Remove sandbox directory.
Drush_TestCase::webroot function
Drush_TestCase::_escapeshellarg_windows public static function
Drush_TestCase::__construct function
pmDownloadCase::testDestination public function
pmDownloadCase::testPackageHandler public function
pmDownloadCase::testPmDownload public function
pmDownloadCase::testSelect public function

File

tests/pmDownloadTest.php, line 8

View source
class pmDownloadCase extends Drush_CommandTestCase {
  public function testPmDownload() {
    $this->drush('pm-download', array('devel'), array('cache' => NULL, 'skip' => NULL)); // No FirePHP
    $this->assertFileExists(UNISH_SANDBOX . '/devel/README.txt');
  }

  // @todo Test pure drush commandfile projects. They get special destination.
  public function testDestination() {
    // Setup two Drupal sites. Skip install for speed.
    $sites = $this->setUpDrupal(2, FALSE);
    $uri = key($sites);
    $root = $this->webroot();

    // Common options for the invocations below.
    $devel_options = array(
      'cache' => NULL,
      'skip' => NULL, // No FirePHP
      'invoke' => NULL, // Invoke from script: do not verify options
    );

    // Default to sites/all.
    $options = array(
      'root' => $root,
      'uri' => $uri,
    ) + $devel_options;
    $this->drush('pm-download', array('devel'), $options);
    $this->assertFileExists($root . '/sites/all/modules/devel/README.txt');

    //  --use-site-dir
    // Expand above $options.
    $options += array('use-site-dir' => NULL);
    $this->drush('pm-download', array('devel'), $options);
    $this->assertFileExists("$root/sites/$uri/modules/devel/README.txt");
    unish_file_delete_recursive("$root/sites/$uri/modules/devel");

    // If we are in site specific dir, then download belongs there.
    $path_stage = "$root/sites/$uri";
    // gets created by --use-site-dir above,
    // mkdir("$path_stage/modules");
    $options = $devel_options;
    $this->drush('pm-download', array('devel'), $options, NULL, $path_stage);
    $this->assertFileExists($path_stage . '/modules/devel/README.txt');

    // --destination with absolute path.
    $destination = UNISH_SANDBOX . '/test-destination1';
    mkdir($destination);
    $options = array(
      'destination' => $destination,
    ) + $devel_options;
    $this->drush('pm-download', array('devel'), $options);
    $this->assertFileExists($destination . '/devel/README.txt');

    // --destination with a relative path.
    $destination = 'test-destination2';
    mkdir(UNISH_SANDBOX . '/' . $destination);
    $options = array(
      'destination' => $destination,
    ) + $devel_options;
    $this->drush('pm-download', array('devel'), $options);
    $this->assertFileExists(UNISH_SANDBOX . '/' . $destination . '/devel/README.txt');
  }

  public function testSelect() {
    $options = array(
      'cache' => NULL,
      'no' => NULL,
      'select' => NULL,
    );
    // --select. Specify 6.x since that has so many releases.
    $this->drush('pm-download', array('devel-6.x'), $options);
    $items = $this->getOutputAsList();
    $output = $this->getOutput();

    // The maximums below are higher then they usually appear since --verbose can add one.
    $this->assertLessThanOrEqual(8, count($items), '--select offerred no more than 3 options.');
    $this->assertContains('dev', $output, 'Dev release was shown by --select.');

    // --select --all. Specify 6.x since that has so many releases.
    $this->drush('pm-download', array('devel-6.x'), $options + array('all' => NULL));
    $items = $this->getOutputAsList();
    $output = $this->getOutput();
    $this->assertGreaterThanOrEqual(20, count($items), '--select --all offerred at least 16 options.');
    $this->assertContains('6.x-1.5', $output, 'Assure that --all lists very old releases.');

    // --select --dev. Specify 6.x since that has so many releases.
    $this->drush('pm-download', array('devel-6.x'), $options + array('dev' => NULL));
    $items = $this->getOutputAsList();
    $output = $this->getOutput();
    $this->assertLessThanOrEqual(6, count($items), '--select --dev expected to offer only one option.');
    $this->assertContains('6.x-1.x-dev', $output, 'Assure that --dev lists the only dev release.');
  }

  public function testPackageHandler() {
    $options = array(
      'cache' => NULL,
      'package-handler' => 'git_drupalorg',
      'yes' => NULL,
    );
    $this->drush('pm-download', array('devel'), $options);
    $this->assertFileExists(UNISH_SANDBOX . '/devel/README.txt');
    $this->assertFileExists(UNISH_SANDBOX . '/devel/.git');
  }
}