Example #1
0
 /**
  * Runs after all tests in a class are run. Remove sandbox directory.
  */
 public static function tearDownAfterClass()
 {
     if (file_exists(UNISH_SANDBOX)) {
         unish_file_delete_recursive(UNISH_SANDBOX, TRUE);
     }
     self::$sites = array();
 }
Example #2
0
 /**
  * Runs after all tests in a class are run. Remove sandbox directory.
  */
 public static function tearDownAfterClass()
 {
     $dirty = getenv('UNISH_DIRTY');
     if (file_exists(UNISH_SANDBOX) && empty($dirty)) {
         unish_file_delete_recursive(UNISH_SANDBOX, TRUE);
     }
     self::$sites = array();
 }
Example #3
0
 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, 'strict' => 0);
     // Default to Drupal sitewide directory.
     $options = array('root' => $root, 'uri' => $uri) + $devel_options;
     $this->drush('pm-download', array('devel'), $options);
     $this->assertFileExists($root . '/' . $this->drupalSitewideDirectory() . '/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", TRUE);
     // 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');
 }
Example #4
0
 function remove_site_local_drush($drush_base)
 {
     // Get rid of the symlink and site-local Drush we created
     unish_file_delete_recursive($this->webroot() . '/' . $drush_base . '/drush/drush');
     unlink($this->webroot() . '/' . $drush_base . '/bin/drush');
     if (file_exists($this->webroot() . '/drush.wrapper')) {
         unlink($this->webroot() . '/drush.wrapper');
     }
 }
Example #5
0
 /**
  * Test archive-restore for a site archive (--no-core).
  *
  * @depends testArchiveDumpNoCore
  */
 public function testArchiveRestoreNoCore($dump_dest)
 {
     $root = $this->webroot();
     $original_codebase = drush_dir_md5($root);
     unish_file_delete_recursive($root . '/sites/' . self::uri, TRUE);
     $options = array('yes' => NULL, 'destination' => $root);
     $this->drush('archive-restore', array($dump_dest), $options);
     $restored_codebase = drush_dir_md5($root);
     $this->assertEquals($original_codebase, $restored_codebase);
 }
Example #6
0
 /**
  * Runs after each test case. Remove sandbox directory.
  */
 public static function tearDownAfterClass()
 {
     if (file_exists(UNISH_SANDBOX)) {
         unish_file_delete_recursive(UNISH_SANDBOX);
     }
 }
Example #7
0
 protected function createGitRepository($dir)
 {
     unish_file_delete_recursive($dir . '/.git');
     $this->execute("git init && git config user.email '*****@*****.**' && git config user.name 'Unish' && git add . && git commit -m 'Initial commit.'", CommandUnishTestCase::EXIT_SUCCESS, $dir);
 }
 /**
  * Same code as drush_delete_dir().
  * @see drush_delete_dir()
  *
  * @param string $dir
  * @return boolean
  */
 static function unish_file_delete_recursive($dir)
 {
     if (!file_exists($dir)) {
         return TRUE;
     }
     if (!is_dir($dir)) {
         @chmod($dir, 0777);
         // Make file writeable
         return unlink($dir);
     }
     foreach (scandir($dir) as $item) {
         if ($item == '.' || $item == '..') {
             continue;
         }
         if (!unish_file_delete_recursive($dir . '/' . $item)) {
             return FALSE;
         }
     }
     return rmdir($dir);
 }