/**
* Runs the tests suite according to Runner set options and the execution
* order of test case (if any). It then returns an array of two elements.
* First element is a boolean result value indicating if tests passed or not.
* Second element is an array containing the key "stdout" which stores the
* output from the last test run.
*
* @param BaseRunner $runner
* @param bool $useStdout
* @param bool $firstRun
* @param MutantInterface|bool $mutant
* @param array $testCases
*
* @return array
*/
public function runTests(BaseRunner $runner, $useStdout = true, $firstRun = false, $mutant = false, array $testCases = array())
{
$options = $runner->getOptions();
$job = new Job();
$outputKey = 'stdout';
if (!$useStdout) {
array_unshift($options['clioptions'], '--stderr');
$outputKey = 'stderr';
}
if (!in_array('--stop-on-failure', $options['clioptions'])) {
array_unshift($options['clioptions'], '--stop-on-failure');
}
array_unshift($options['clioptions'], 'phpunit');
if ($firstRun) {
$options['clioptions'] = array_merge($options['clioptions'], array('--log-junit', $options['cache'] . '/mutagenesis.xml'), explode(' ', $options['constraint']));
}
if (count($testCases) > 0) {
// tests cases always 0 on first run
foreach ($testCases as $className => $case) {
$args = $options;
$args['clioptions'][] = $className;
$args['clioptions'][] = $case['file'];
$output = self::execute($job->generate($mutant, $args, $runner->getTimeout(), $runner->getBootstrap()));
$res = $this->processOutput($output[$outputKey]);
if (false === $res) {
return array($res, $output);
}
}
} else {
$output = self::execute($job->generate($mutant, $options, 0, $runner->getBootstrap()));
$res = $this->processOutput($output[$outputKey]);
if (!$res) {
return array(false, $output);
}
}
return array($res, $output);
}