public static function main(array $arguments, $useStdout = false)
{
if (!$useStdout) {
array_unshift($arguments['clioptions'], '--stderr');
}
if (!in_array('--stop-on-failure', $arguments['clioptions'])) {
array_unshift($arguments['clioptions'], '--stop-on-failure');
}
array_unshift($arguments['clioptions'], 'phpunit');
$originalWorkingDirectory = getcwd();
if (isset($arguments['tests'])) {
chdir($arguments['tests']);
}
$command = new \PHPUnit_TextUI_Command();
$command->run($arguments['clioptions'], false);
chdir($originalWorkingDirectory);
}