Beispiel #1
0
 /**
  * Test various combinations of XHProf flag options.
  *
  * @dataProvider xhOptionProvider
  */
 public function testFlags($name, $options, $expected)
 {
     drush_preflight();
     foreach ($options as $option_name => $option_value) {
         drush_set_option($option_name, $option_value);
     }
     $this->assertEquals($expected, xh_flags(), $name);
 }
Beispiel #2
0
 public function downloadCore()
 {
     $www_dir = $this->getProjectDir() . '/' . $this->getDocumentRoot();
     if (!is_file($www_dir . '/misc/drupal.js')) {
         $core_version = $this->getCoreVersion();
         $core = "drupal-" . $core_version . ".x";
         drush_log(dt('Downloading Drupal core...'), 'status');
         drush_set_option('backend', TRUE);
         drush_set_option('destination', $this->getProjectDir());
         drush_set_option('drupal-project-rename', $this->getDocumentRoot());
         if (drush_invoke('pm-download', array($core)) === FALSE) {
             return drush_set_error('', 'Drupal core download/extract failed.');
         }
         drush_set_option('backend', FALSE);
     } else {
         drush_log(dt('Drupal already downloaded and unpacked for this project.'));
     }
 }
Beispiel #3
0
 /**
  * Execute the BackdropBoot::BOOTSTRAP_CONFIGURATION phase.
  *
  * Load in the settings.php file an initialize the database information,
  * config directories, and $settings variable.
  */
 function bootstrap_backdrop_configuration()
 {
     backdrop_bootstrap(BACKDROP_BOOTSTRAP_CONFIGURATION);
     // Set the Drush option for "databases" to work with existing SQL commands
     // as though a --db-url or --databases option were passed in.
     // In the future it should be possible for bootstrap classes like this one
     // to provide the database string directly.
     // See https://github.com/drush-ops/drush/issues/1750.
     $database = drush_get_option('database', 'default');
     $target = drush_get_option('target', 'default');
     $db_url = $url = drush_get_option('db-url');
     $databases = drush_get_option('databases');
     if (!$databases) {
         if ($db_url) {
             $db_spec = drush_convert_db_from_db_url($url);
             $db_spec['db_prefix'] = drush_get_option('db-prefix');
             drush_set_option('databases', array($database => array($target => $db_spec)));
         } else {
             drush_set_option('databases', $GLOBALS['databases']);
         }
     }
     // Unset Backdrop error handler and restore drush's one.
     restore_error_handler();
 }
Beispiel #4
0
 /**
  * Initializes Drush which boostraps Drupal core
  */
 public function initializeDrush()
 {
     define('DRUSH_BASE_PATH', sprintf('%s/../drush', $this->root));
     define('DRUSH_REQUEST_TIME', microtime(TRUE));
     require_once DRUSH_BASE_PATH . '/includes/bootstrap.inc';
     require_once DRUSH_BASE_PATH . '/includes/environment.inc';
     require_once DRUSH_BASE_PATH . '/includes/command.inc';
     require_once DRUSH_BASE_PATH . '/includes/drush.inc';
     require_once DRUSH_BASE_PATH . '/includes/backend.inc';
     require_once DRUSH_BASE_PATH . '/includes/batch.inc';
     require_once DRUSH_BASE_PATH . '/includes/context.inc';
     require_once DRUSH_BASE_PATH . '/includes/sitealias.inc';
     require_once DRUSH_BASE_PATH . '/includes/exec.inc';
     require_once DRUSH_BASE_PATH . '/includes/drupal.inc';
     require_once DRUSH_BASE_PATH . '/includes/output.inc';
     require_once DRUSH_BASE_PATH . '/includes/cache.inc';
     require_once DRUSH_BASE_PATH . '/includes/filesystem.inc';
     require_once DRUSH_BASE_PATH . '/includes/dbtng.inc';
     $drush_info = drush_read_drush_info();
     define('DRUSH_VERSION', $drush_info['drush_version']);
     $version_parts = explode('.', DRUSH_VERSION);
     define('DRUSH_MAJOR_VERSION', $version_parts[0]);
     define('DRUSH_MINOR_VERSION', $version_parts[1]);
     $GLOBALS['argv'][0] = 'default';
     drush_set_context('arguments', array('default', 'help'));
     drush_set_context('argc', $GLOBALS['argc']);
     drush_set_context('argv', $GLOBALS['argv']);
     drush_set_option('root', $this->root);
     // make sure the default path point to the correct instance
     $currentDirectory = getcwd();
     chdir($this->root);
     $phases = _drush_bootstrap_phases(FALSE, TRUE);
     drush_set_context('DRUSH_BOOTSTRAP_PHASE', DRUSH_BOOTSTRAP_NONE);
     // We need some global options processed at this early stage. Namely --debug.
     _drush_bootstrap_global_options();
     $return = '';
     $command_found = FALSE;
     foreach ($phases as $phase) {
         drush_bootstrap_to_phase($phase);
     }
     chdir($currentDirectory);
 }
Beispiel #5
0
 /**
  * Tests for pm_parse_version() with project versions.
  */
 public function testVersionParserContrib()
 {
     _drush_add_commandfiles(array(DRUSH_BASE_PATH . '/commands/pm'));
     drush_set_option('default-major', UNISH_DRUPAL_MAJOR_VERSION);
     $version = '';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('', $version_parts['version']);
     $this->assertEquals(UNISH_DRUPAL_MAJOR_VERSION . '.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
     $version = '7';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('', $version_parts['version']);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
     $version = '7.x';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('', $version_parts['version']);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
     $version = '7.x-1.0-beta1';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('1', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('0', $version_parts['version_patch']);
     $this->assertEquals('beta1', $version_parts['version_extra']);
     $this->assertEquals('1.0-beta1', $version_parts['project_version']);
     $version = '7.x-1.0-beta1+30-dev';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('1', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('0', $version_parts['version_patch']);
     $this->assertEquals('beta1', $version_parts['version_extra']);
     $this->assertEquals('30', $version_parts['version_offset']);
     $this->assertEquals('1.0-beta1+30-dev', $version_parts['project_version']);
     $version = '7.x-1.0';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('1', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('0', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('1.0', $version_parts['project_version']);
     $version = '7.x-1.0+30-dev';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('7.x', $version_parts['drupal_version']);
     $this->assertEquals('1', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('0', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('30', $version_parts['version_offset']);
     $this->assertEquals('1.0+30-dev', $version_parts['project_version']);
     // Since we're not on a bootstrapped site, the version string
     // for the following cases is interpreted as a core version.
     // Tests on a bootstrapped site are in \pmRequestCase::testVersionParser()
     $version = '6.x';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('6.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
     $version = '6.22';
     $version_parts = pm_parse_version($version);
     $this->assertEquals('6.x', $version_parts['drupal_version']);
     $this->assertEquals('', $version_parts['version_major']);
     $this->assertEquals('', $version_parts['version_minor']);
     $this->assertEquals('', $version_parts['version_patch']);
     $this->assertEquals('', $version_parts['version_extra']);
     $this->assertEquals('', $version_parts['project_version']);
 }