function Drush_CommandTestCase::execute

6.x drush_testcase.inc Drush_CommandTestCase::execute($command, $expected_return = self::EXIT_SUCCESS, $env = array())
5.x drush_testcase.inc Drush_CommandTestCase::execute($command, $expected_return = self::EXIT_SUCCESS, $env = array())

Actually runs the command. Does not trap the error stream output as this need PHP 4.3+.

Parameters

string $command: The actual command line to run.

integer $expected_return: The return code to expect

array $env: Extra environment variables

Return value

integer Exit code. Usually self::EXIT_ERROR or self::EXIT_SUCCESS.

11 calls to Drush_CommandTestCase::execute()
archiveDumpCase::testArchiveDump in tests/archiveDumpTest.php
Test if tarball generated by archive-dump looks right.
archiveDumpCase::unTar in tests/archiveDumpTest.php
Untar an archive and return the path to the untarred folder.
backendCase::testOrigin in tests/backendTest.php
Covers the following origin responsibilities.
backendCase::testRealtimeOutput in tests/backendTest.php
Covers the following target responsibilities.
backendCase::testTarget in tests/backendTest.php
Covers the following target responsibilities.

... See full list

File

tests/drush_testcase.inc, line 365
Initialize a sandboxed environment. Starts with call unish_init() at bottom.

Class

Drush_CommandTestCase

Code

function execute($command, $expected_return = self::EXIT_SUCCESS, $env = array()) {
  $this->_output = FALSE;
  $return = 1;
  $this->log("Executing: $command", 'notice');

  // Apply the environment variables we need for our test
  // to the head of the command
  $prefix = '';
  foreach ($env as $env_name => $env_value) {
    $prefix .= $env_name . '=' . self::escapeshellarg($env_value) . ' ';
  }
  exec($prefix . $command, $this->_output, $return);

  $this->assertEquals($expected_return, $return, 'Unexpected exit code: ' . $command);
  return $return;
}