function Drush_TestCase::drush

4.x Drush_TestCase::drush($command, array $args = array(), array $options = array(), $site_specification = NULL, $cd = NULL)

Invoke drush in via execute().


command: A defined drush command such as 'cron', 'status' or any of the available ones such as 'drush pm'.

args: Command arguments.

$options: An associative array containing options.

$site_specification: A site alias or site specification. Include the '@' at start of a site alias.

$cd: A directory to change into before executing.

Return value

integer An exit code.

25 calls to Drush_TestCase::drush()
archiveDumpCase::testArchiveDump in tests/archiveDumpTest.php
commandCase::testGetCommands in tests/commandTest.php
contextCase::ConfigSearchPaths in tests/contextTest.php
Assure that all possible config files get loaded.
contextCase::ConfigVersionSpecific in tests/contextTest.php
Assure that matching version-specific config files are loaded and others are ignored.
contextCase::ContextHierarchy in tests/contextTest.php
Assure that options are loaded into right context and hierarchy is respected by drush_get_option().

... See full list


tests/, line 118




function drush($command, array $args = array(), array $options = array(), $site_specification = NULL, $cd = NULL) {
  $cmd[] = $cd ? sprintf('cd %s;', self::escapeshellarg($cd)) : NULL;
  $cmd[] = UNISH_DRUSH;
  $cmd[] = empty($site_specification) ? NULL : self::escapeshellarg($site_specification);
  $cmd[] = $command;
  if (in_array('--verbose', $_SERVER['argv'])) {
    $args[] = '--verbose';
  if (in_array('--debug', $_SERVER['argv'])) {
    $args[] = '--debug';

  foreach ($args as $arg) {
    $cmd[] = self::escapeshellarg($arg);
  $options['nocolor'] = NULL;
  foreach ($options as $key => $value) {
    if (is_null($value)) {
      $cmd[] = "--$key";
    else {
      $cmd[] = "--$key=" . self::escapeshellarg($value);
  $exec = array_filter($cmd, 'strlen'); // Remove NULLs
  return $this->execute(implode(' ', $exec));