Example #1
0
 /**
  * Assert that $command has interesting properties. Reference command by
  * it's alias (dl) to assure that those aliases are built as expected.
  */
 public function testGetCommands()
 {
     drush_preflight();
     $commands = drush_get_commands();
     $command = $commands['dl'];
     $this->assertEquals('dl', current($command['aliases']));
     $this->assertArrayHasKey('version_control', $command['engines']);
     $this->assertArrayHasKey('package_handler', $command['engines']);
     $this->assertArrayHasKey('release_info', $command['engines']);
     $this->assertEquals('pm-download', $command['command']);
     $this->assertEquals('pm', $command['commandfile']);
     $this->assertEquals('drush_command', $command['callback']);
     $this->assertArrayHasKey('examples', $command['sections']);
     $this->assertTrue($command['is_alias']);
     $command = $commands['pm-download'];
     $this->assertArrayNotHasKey('is_alias', $command);
 }
Example #2
0
 public function testGetCommands()
 {
     drush_bootstrap(DRUSH_BOOTSTRAP_DRUSH);
     $commands = drush_get_commands();
     $command = $commands['dl'];
     $this->assertEquals('dl', current($command['aliases']));
     $this->assertEquals('download', current($command['deprecated-aliases']));
     $this->assertArrayHasKey('version_control', $command['engines']);
     $this->assertArrayHasKey('package_handler', $command['engines']);
     $this->assertEquals('pm-download', $command['command']);
     $this->assertEquals('pm', $command['commandfile']);
     $this->assertEquals('drush_command', $command['callback']);
     $this->assertArrayHasKey('examples', $command['sections']);
     $this->assertTrue($command['is_alias']);
     $command = $commands['pm-download'];
     $this->assertArrayNotHasKey('is_alias', $command);
 }
Example #3
0
 /**
  * Get the names of all the checks within the report.
  *
  * Uses the key 'checks' within the command to populate. Order matters, so
  * if you implement hook_drush_command_alter(), try to add checks in a logical
  * order, IE don't check for something specific about Views if Views is
  * disabled.
  *
  * @return array
  *   Machine readable names.
  */
 public function getCheckNames()
 {
     $commands = drush_get_commands();
     // Guess the name of the Drush command.
     $command_name_pieces = preg_split('/(?=[A-Z])/', get_called_class());
     unset($command_name_pieces[0], $command_name_pieces[1], $command_name_pieces[3]);
     $command_name = strtolower(implode('_', $command_name_pieces));
     $command = $commands[$command_name];
     drush_command_invoke_all_ref('drush_command_alter', $command);
     $checks = array();
     foreach ($command['checks'] as $check) {
         if (is_array($check)) {
             $checks[] = $check['name'];
             require_once $check['location'];
         } else {
             $checks[] = $check;
             $base_class_name = 'SiteAuditCheck' . $this->getReportName();
             $class_name = $base_class_name . $check;
             if (!class_exists($class_name)) {
                 require_once SITE_AUDIT_BASE_PATH . "/Check/{$this->getReportName()}/{$check}.php";
             }
         }
     }
     return $checks;
 }
Example #4
0
 /**
  * Check if the given command belongs to a disabled module.
  *
  * @return array
  *   Array with a command-like bootstrap error or FALSE if Drupal was not
  *   bootstrapped fully or the command does not belong to a disabled module.
  */
 function drush_command_belongs_to_disabled_module()
 {
     if (drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
         _drush_find_commandfiles(DRUSH_BOOTSTRAP_DRUPAL_SITE, DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
         drush_get_commands(TRUE);
         $commands = drush_get_commands();
         $arguments = drush_get_arguments();
         $command_name = array_shift($arguments);
         if (isset($commands[$command_name])) {
             // We found it. Load its module name and set an error.
             if (is_array($commands[$command_name]['drupal dependencies']) && count($commands[$command_name]['drupal dependencies'])) {
                 $modules = implode(', ', $commands[$command_name]['drupal dependencies']);
             } else {
                 // The command does not define Drupal dependencies. Derive them.
                 $command_files = commandfiles_cache()->get();
                 $command_path = $commands[$command_name]['path'] . DIRECTORY_SEPARATOR . $commands[$command_name]['commandfile'] . '.drush.inc';
                 $modules = array_search($command_path, $command_files);
             }
             return array('bootstrap_errors' => array('DRUSH_COMMAND_DEPENDENCY_ERROR' => dt('Command !command needs the following module(s) enabled to run: !dependencies.', array('!command' => $command_name, '!dependencies' => $modules))));
         }
     }
     return FALSE;
 }