コード例 #1
0
ファイル: UnishTestCase.php プロジェクト: catch56/drush
 /**
  * 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();
 }
コード例 #2
0
ファイル: UnishTestCase.php プロジェクト: nietzcheson/drush
 /**
  * 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();
 }
コード例 #3
0
ファイル: pmDownloadTest.php プロジェクト: catch56/drush
 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');
 }
コード例 #4
0
ファイル: drushScriptTest.php プロジェクト: nietzcheson/drush
 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');
     }
 }
コード例 #5
0
ファイル: archiveDumpTest.php プロジェクト: leolandotan/drush
 /**
  * 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);
 }
コード例 #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);
     }
 }
コード例 #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);
 }
コード例 #8
0
 /**
  * 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);
 }