public function pmDownloadCase::testDestination

8.0.x pmDownloadTest.php public pmDownloadCase::testDestination()
6.x pmDownloadTest.php public pmDownloadCase::testDestination()
7.x pmDownloadTest.php public pmDownloadCase::testDestination()
4.x pmDownloadTest.php public pmDownloadCase::testDestination()
5.x pmDownloadTest.php public pmDownloadCase::testDestination()
master pmDownloadTest.php public pmDownloadCase::testDestination()

File

tests/pmDownloadTest.php, line 15

Class

pmDownloadCase
pm-download testing

Code

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');
}