function simpletest_phpunit_run_command

Executes the phpunit command.

Parameters

array $unescaped_test_classnames: An array of test class names, including full namespaces, to be passed as a regular expression to phpunit's --filter option.

string $phpunit_file: A filepath to use for phpunit's --log-junit option.

1 call to simpletest_phpunit_run_command()
simpletest_run_phpunit_tests in drupal/core/modules/simpletest/simpletest.module
Executes phpunit tests and returns the results of the run.

File

drupal/core/modules/simpletest/simpletest.module, line 235
Provides testing functionality.

Code

function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpunit_file) {
  $phpunit_bin = simpletest_phpunit_command();

  // Double escape namespaces so they'll work in a regexp.
  $escaped_test_classnames = array_map(function ($class) {
    return addslashes($class);
  }, $unescaped_test_classnames);
  $filter_string = implode("|", $escaped_test_classnames);
  $command = array(
    $phpunit_bin,
    '--filter',
    escapeshellarg($filter_string),
    '--log-junit',
    escapeshellarg($phpunit_file),
  );

  // Need to change directories before running the command so that we can use
  // relative paths in the configuration file's exclusions.
  $old_cwd = getcwd();
  chdir(DRUPAL_ROOT . "/core");

  // exec in a subshell so that the environment is isolated when running tests
  // via the simpletest UI.
  $ret = exec(join($command, " "));
  chdir($old_cwd);
  return $ret;
}