src/Adapter/Phpunit.php
public function getProcess(
        Container $container,
        $firstRun = false,
        $interceptFile = null,
        $mutantFile = null,
        array $testSuites = []
    ) {
        $jobopts = [
            'testdir'       => $container->getTestRunDirectory(),
            'basedir'       => $container->getBaseDirectory(),
            'timeout'       => $container->getTimeout(),
            'cachedir'      => $container->getTempDirectory(),
            'command'       => $container->getAdapterOptions(),
            'constraints'   => $container->getAdapterConstraints()
        ];

        /**
         * We like standardised easy to parse outout
         */
        array_unshift($jobopts['command'], '--teamcity');

        /*
         * We only need a single fail!
         */
        if (!in_array('--stop-on-failure', $jobopts['command'])) {
            array_unshift($jobopts['command'], '--stop-on-failure');
        }

        /**
         * Setup a PHPUnit XML config file for the purposes of explicitly setting
         * test case order (this will preserve anything else from the original)
         *
         * On first runs we log to junit XML so we can sort tests by performance.
         *
         * TODO: Assemble config just once if no coverage data available!
         */
        $xmlConfiguration = $this->assembleXmlConfiguration($container, $firstRun, $testSuites);

        $configFile = $container->getTempDirectory() . '/phpunit.humbug.xml';

        file_put_contents($configFile, $xmlConfiguration->generateXML());

        foreach ($jobopts['command'] as $key => $value) {
            if ($value == '--configuration' || $value == '-C') {
                unset($jobopts['command'][$key]);
                unset($jobopts['command'][$key+1]);
            } elseif (preg_match('%\\-\\-configuration=%', $value)) {
                unset($jobopts['command'][$key]);
            }
        }
        array_unshift($jobopts['command'], '--configuration=' . $configFile);

        /**
         * Initial command is expected, of course.
         */
        $phpunitFinder = new PhpunitExecutableFinder;
        $command = $phpunitFinder->find();
        array_unshift($jobopts['command'], $command);

        /**
         * Log the first run so we can analyse test times to make future
         * runs more efficient in terms of deferring slow test classes to last
         */
        $timeout = 0;
        if ($firstRun) {
            $jobopts['command'] = array_merge(
                $jobopts['command'],
                explode(' ', $jobopts['constraints'])
            );
        } else {
            $timeout = $container->getTimeout();
        }

        Job::generate(
            $mutantFile,
            $container->getBootstrap(),
            $interceptFile
        );
        
        $process = new Process(implode(' ', $jobopts['command']), $jobopts['testdir'], array_replace($_ENV, $_SERVER));
        $process->setTimeout($timeout);

        return $process;
    }
public function getProcess(
        Container $container,
        $firstRun = false,
        $interceptFile = null,
        $mutantFile = null,
        array $testSuites = []
    ) {
        $jobopts = [
            'testdir'       => $container->getTestRunDirectory(),
            'basedir'       => $container->getBaseDirectory(),
            'timeout'       => $container->getTimeout(),
            'cachedir'      => $container->getTempDirectory(),
            'command'       => $container->getAdapterOptions(),
            'constraints'   => $container->getAdapterConstraints()
        ];

        /**
         * We like standardised easy to parse outout
         */
        array_unshift($jobopts['command'], '--teamcity');

        /*
         * We only need a single fail!
         */
        if (!in_array('--stop-on-failure', $jobopts['command'])) {
            array_unshift($jobopts['command'], '--stop-on-failure');
        }

        /**
         * Setup a PHPUnit XML config file for the purposes of explicitly setting
         * test case order (this will preserve anything else from the original)
         *
         * On first runs we log to junit XML so we can sort tests by performance.
         *
         * TODO: Assemble config just once if no coverage data available!
         */
        $xmlConfiguration = $this->assembleXmlConfiguration($container, $firstRun, $testSuites);

        $configFile = $container->getTempDirectory() . '/phpunit.humbug.xml';

        file_put_contents($configFile, $xmlConfiguration->generateXML());

        foreach ($jobopts['command'] as $key => $value) {
            if ($value == '--configuration' || $value == '-C') {
                unset($jobopts['command'][$key]);
                unset($jobopts['command'][$key+1]);
            } elseif (preg_match('%\\-\\-configuration=%', $value)) {
                unset($jobopts['command'][$key]);
            }
        }
        array_unshift($jobopts['command'], '--configuration=' . $configFile);

        /**
         * Initial command is expected, of course.
         */
        $phpunitFinder = new PhpunitExecutableFinder;
        $command = $phpunitFinder->find();
        array_unshift($jobopts['command'], $command);

        /**
         * Log the first run so we can analyse test times to make future
         * runs more efficient in terms of deferring slow test classes to last
         */
        $timeout = 0;
        if ($firstRun) {
            $jobopts['command'] = array_merge(
                $jobopts['command'],
                explode(' ', $jobopts['constraints'])
            );
        } else {
            $timeout = $container->getTimeout();
        }

        Job::generate(
            $mutantFile,
            $container->getBootstrap(),
            $interceptFile
        );
        
        $process = new Process(implode(' ', $jobopts['command']), $jobopts['testdir'], array_replace($_ENV, $_SERVER));
        $process->setTimeout($timeout);

        return $process;
    }
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   Container         $container
@param   bool              $firstRun
@param   null|string       $interceptFile
@param   null|string       $mutantFile
@param   array             $testSuites
@return  Process