Executes the phpunit command.
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.
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;
}